Skip to content

Commit

Permalink
cast to np.uint8 the maxorder
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed Sep 5, 2024
1 parent 2cc5d4a commit d6cf645
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
34 changes: 9 additions & 25 deletions notebooks/from_image_with_mask.ipynb

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion python/mocpy/moc/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ def from_fits_image(cls, hdu, max_norder, mask=None):
"""
# Only take the first HDU
header = hdu.header
max_norder = np.uint8(max_norder)

# Compute a WCS from the header of the image
w = wcs.WCS(header)
Expand Down Expand Up @@ -573,10 +574,13 @@ def from_fits_image(cls, hdu, max_norder, mask=None):
u.rad,
) # in steradians

# Division by 0 case
if px_sky_area == 0.0:
healpix_order_computed = False
else:
depth_px = np.floor(np.log2(np.pi / (3.0 * px_sky_area)) / 2.0)
depth_px = np.uint8(
np.floor(np.log2(np.pi / (3.0 * px_sky_area)) / 2.0),
)
max_norder = min(max_norder, depth_px)
else:
healpix_order_computed = False
Expand Down

0 comments on commit d6cf645

Please sign in to comment.