Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Wu You
brick
Commits
41d9b96a
Commit
41d9b96a
authored
Jul 17, 2025
by
Wu You
Browse files
Upload New File
parent
e57a3b18
Changes
1
Hide whitespace changes
Inline
Side-by-side
brick_core.py
0 → 100644
View file @
41d9b96a
import
healpy
as
hp
import
numpy
as
np
from
.brick_utils
import
radius_exact
class
Config
:
def
__init__
(
self
,
nside
,
overlap
):
self
.
nside
=
nside
self
.
overlap
=
overlap
class
Brick
:
"""
A class representing a sky region ("brick") generated based on HEALPix.
Attributes
----------
brick_id : int
Unique identifier of the brick (HEALPix pixel ID).
ra : float
Right Ascension of the brick center (degrees).
dec : float
Declination of the brick center (degrees).
min_radius : float
Minimum enclosing circle radius of the brick (degrees, without overlap).
radius : float
Enlarged radius of the brick (degrees, after applying overlap).
nside : int
HEALPix resolution parameter.
"""
def
__init__
(
self
,
brick_id
,
ra
,
dec
,
min_radius
,
radius
,
nside
):
self
.
brick_id
=
brick_id
self
.
ra
=
ra
self
.
dec
=
dec
self
.
min_radius
=
min_radius
self
.
radius
=
radius
self
.
nside
=
nside
def
__repr__
(
self
):
return
f
"Brick(brick_id=
{
self
.
brick_id
}
, ra=
{
self
.
ra
}
, dec=
{
self
.
dec
}
, min_radius=
{
self
.
min_radius
}
, radius=
{
self
.
radius
}
, nside=
{
self
.
nside
}
)"
def
generate_bricks
(
nside
,
brick_id
=
None
,
overlap
=
1.2
):
"""
Generate Brick objects for all HEALPix pixels or a single specified pixel.
Parameters
----------
nside : int
HEALPix resolution parameter.
brick_id : int, optional
Specific HEALPix pixel (brick) ID to generate. If None (default),
generate bricks for all pixels.
overlap : float, optional
Overlap factor to enlarge the brick radius.
- 1.0 = no overlap
- >1.0 = enlarged radius
Default is 1.2.
Returns
-------
Brick or list of Brick
- If `brick_id` is provided: a single Brick object.
- If `brick_id` is None: a list of Brick objects for all pixels.
"""
def
_create_brick
(
pix
,
nside
):
theta
,
phi
=
hp
.
pix2ang
(
nside
,
pix
)
ra
=
np
.
degrees
(
phi
)
dec
=
90
-
np
.
degrees
(
theta
)
min_radius
=
radius_exact
(
nside
,
pix
)
radius
=
min_radius
*
overlap
return
Brick
(
brick_id
=
pix
,
ra
=
ra
,
dec
=
dec
,
min_radius
=
min_radius
,
radius
=
radius
,
nside
=
nside
)
if
brick_id
is
not
None
:
return
_create_brick
(
brick_id
,
nside
)
else
:
npix
=
hp
.
nside2npix
(
nside
)
return
[
_create_brick
(
pix
,
nside
)
for
pix
in
range
(
npix
)]
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment