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
366355c2
Commit
366355c2
authored
Jul 17, 2025
by
Wu You
Browse files
Upload New File
parent
93da7e73
Changes
1
Hide whitespace changes
Inline
Side-by-side
brick_utils.py
0 → 100644
View file @
366355c2
import
numpy
as
np
import
healpy
as
hp
def
angular_distance
(
ra1
,
dec1
,
ra2
,
dec2
):
"""
Calculate the angular distance between two points on a sphere.
Parameters
----------
ra1 : float
Right Ascension of the first point (radians).
dec1 : float
Declination of the first point (radians).
ra2 : float
Right Ascension of the second point (radians).
dec2 : float
Declination of the second point (radians).
Returns
-------
float
Angular distance between the two points (radians).
"""
return
np
.
arccos
(
np
.
sin
(
dec1
)
*
np
.
sin
(
dec2
)
+
np
.
cos
(
dec1
)
*
np
.
cos
(
dec2
)
*
np
.
cos
(
ra1
-
ra2
)
)
def
radius_exact
(
nside
,
pix_id
):
"""
Compute the exact minimum enclosing circle radius of a HEALPix pixel.
Parameters
----------
nside : int
HEALPix resolution parameter.
pix_id : int
HEALPix pixel ID.
Returns
-------
float
Exact minimum enclosing circle radius of the pixel (degrees).
"""
theta_c
,
phi_c
=
hp
.
pix2ang
(
nside
,
pix_id
)
verts
=
hp
.
boundaries
(
nside
,
pix_id
,
step
=
1
)
ra_v
=
np
.
arctan2
(
verts
[
1
],
verts
[
0
])
dec_v
=
np
.
arcsin
(
verts
[
2
])
rads
=
[
angular_distance
(
phi_c
,
np
.
pi
/
2
-
theta_c
,
rv
,
dv
)
for
rv
,
dv
in
zip
(
ra_v
,
dec_v
)]
return
np
.
degrees
(
max
(
rads
))
\ 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