Skip to content

Commit 9c7fc0b

Browse files
committed
cleaned up
1 parent 6528125 commit 9c7fc0b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

autoarray/inversion/inversion/abstract.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,13 +854,18 @@ def mapper_operated_mapping_matrix_dict(self) -> Dict:
854854
raise NotImplementedError
855855

856856
@property
857-
def fits_table_mapper_dict(self) -> Dict[AbstractMapper, np.ndarray]:
858-
857+
def fits_table_mapper_dict(self) -> Dict["AbstractMapper", fits.BinTableHDU]:
858+
"""
859+
Creates a dictionary mapping each AbstractMapper to a FITS BinTableHDU,
860+
where the table stores x, y, reconstruction, and noise_map columns.
861+
"""
859862
fits_table_mapper_dict = {}
860863

861864
mapper_list = self.cls_list_from(cls=AbstractMapper)
862865

863866
for mapper in mapper_list:
867+
868+
# Stack data for table: x, y, reconstruction, noise
864869
reconstruction = np.stack(
865870
[
866871
mapper.mapper_grids.source_plane_mesh_grid[:, 0],
@@ -871,15 +876,19 @@ def fits_table_mapper_dict(self) -> Dict[AbstractMapper, np.ndarray]:
871876
axis=1,
872877
)
873878

879+
# Create the Astropy Table
874880
pixels_table = Table(
875881
data=reconstruction,
876-
names=['x', 'y', 'reconstruction', 'noise_map'],
882+
names=["x", "y", "reconstruction", "noise_map"],
877883
)
878884

879-
pixels_table.meta["MESH_TYPE"] = type(mapper.mapper_grids.source_plane_mesh_grid)
885+
# Add metadata to table header
886+
pixels_table.meta["MESH"] = str(type(mapper.mapper_grids.source_plane_mesh_grid))
880887

888+
# Convert Table to FITS HDU
881889
fits_table = fits.table_to_hdu(pixels_table)
882890

891+
# Store in dictionary
883892
fits_table_mapper_dict[mapper] = fits_table
884893

885894
return fits_table_mapper_dict

0 commit comments

Comments
 (0)