Skip to content

Commit

Permalink
explicitly import recfunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
ntessore committed Jan 31, 2025
1 parent cf88588 commit 9ea2ce6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion heracles/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ def _write_map(fits, ext, key, m, *, names=None):

def _read_map(hdu):
"""read HEALPix map from FITS table"""
from numpy.lib.recfunctions import structured_to_unstructured

# read the map from the extension
m = hdu.read()

# turn the structured array of columns into an unstructured array
# transpose so that columns become rows (as that is how maps are)
# then squeeze out degenerate axes
m = np.squeeze(np.lib.recfunctions.structured_to_unstructured(m).T)
m = np.squeeze(structured_to_unstructured(m).T)

# read and attach metadata
m.dtype = np.dtype(m.dtype, metadata=_read_metadata(hdu))
Expand Down

0 comments on commit 9ea2ce6

Please sign in to comment.