66__all__ = ["load_overlappogram" , "load_response_cube" , "save_em_cube" , "save_spectral_cube" , "save_prediction" ]
77
88
9- def load_overlappogram (image_path , weights_path ) -> NDCube :
9+ def load_overlappogram (image_path : str , weights_path : str | None ) -> NDCube :
1010 with fits .open (image_path ) as image_hdul :
1111 image = image_hdul [0 ].data
1212 header = image_hdul [0 ].header
1313 wcs = WCS (image_hdul [0 ].header )
14- with fits .open (weights_path ) as weights_hdul :
15- weights = weights_hdul [0 ].data
16- return NDCube (image , wcs = wcs , uncertainty = StdDevUncertainty (1 / weights ), meta = dict (header ))
1714
15+ if weights_path is None :
16+ uncertainty = None
17+ else :
18+ with fits .open (weights_path ) as weights_hdul :
19+ weights = weights_hdul [0 ].data
20+ uncertainty = StdDevUncertainty (1 / weights )
1821
19- def load_response_cube (path ) -> NDCube :
22+ return NDCube (image , wcs = wcs , uncertainty = uncertainty , meta = dict (header ))
23+
24+
25+ def load_response_cube (path : str ) -> NDCube :
2026 with fits .open (path ) as hdul :
2127 response = hdul [0 ].data
2228 header = hdul [0 ].header
@@ -28,13 +34,13 @@ def load_response_cube(path) -> NDCube:
2834 return NDCube (response , wcs = wcs , meta = meta )
2935
3036
31- def save_em_cube (cube , path , overwrite = True ) -> None :
37+ def save_em_cube (cube , path : str , overwrite : bool = True ) -> None :
3238 fits .writeto (path , cube , overwrite = overwrite )
3339
3440
35- def save_prediction (prediction , path , overwrite = True ) -> None :
41+ def save_prediction (prediction , path : str , overwrite : bool = True ) -> None :
3642 fits .writeto (path , prediction , overwrite = overwrite )
3743
3844
39- def save_spectral_cube (spectral_cube , path , overwrite = True ) -> None :
45+ def save_spectral_cube (spectral_cube , path : str , overwrite : bool = True ) -> None :
4046 fits .writeto (path , spectral_cube , overwrite = overwrite )
0 commit comments