Skip to content

Commit e070739

Browse files
authored
Merge pull request #869 from punch-mission/polarized-starfield-dtype
Allows setting of dtype in polarization conversion
2 parents 49f8753 + 4ab7da4 commit e070739

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

changelog/869.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allows setting of dtype in polarization conversion, to assist in polarized starfield model generation.

punchbowl/level3/stellar.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
warnings.filterwarnings("ignore")
3232

3333

34-
def polarize_solar_to_celestial(input_data: NDCube) -> NDCube:
34+
def polarize_solar_to_celestial(input_data: NDCube, dtype: None | type = None) -> NDCube:
3535
"""
3636
Convert polarization from mzpsolar to Celestial frame.
3737
@@ -66,7 +66,7 @@ def polarize_solar_to_celestial(input_data: NDCube) -> NDCube:
6666
celestial_data_collection = resolve(data_collection, "npol", out_angles=new_angles)
6767

6868
valid_keys = [key for key in celestial_data_collection if key != "alpha"]
69-
new_data = [celestial_data_collection[key].data for key in valid_keys]
69+
new_data = np.array([celestial_data_collection[key].data for key in valid_keys], dtype=dtype)
7070
new_wcs = input_data.wcs.copy()
7171

7272
output_meta = NormalizedMetadata.load_template("PTM", "3")
@@ -78,7 +78,7 @@ def polarize_solar_to_celestial(input_data: NDCube) -> NDCube:
7878
return output
7979

8080

81-
def polarize_celestial_to_solar(input_data: NDCube) -> NDCube:
81+
def polarize_celestial_to_solar(input_data: NDCube, dtype: None | type = None) -> NDCube:
8282
"""
8383
Convert polarization from Celestial frame to mzpsolar.
8484
@@ -111,7 +111,7 @@ def polarize_celestial_to_solar(input_data: NDCube) -> NDCube:
111111
solar_data_collection = resolve(data_collection, "mzpsolar", in_angles=new_angles)
112112

113113
valid_keys = [key for key in solar_data_collection if key != "alpha"]
114-
new_data = [solar_data_collection[key].data for key in valid_keys]
114+
new_data = np.array([solar_data_collection[key].data for key in valid_keys], dtype=dtype)
115115
new_wcs = input_data.wcs.copy()
116116

117117
output_meta = NormalizedMetadata.load_template("PTM", "3")
@@ -143,7 +143,7 @@ def load_image(self, filename: str) -> ImageHolder:
143143
if self.layer is None: # clear data
144144
data = cube.data
145145
else: # it's polarized
146-
cube = polarize_solar_to_celestial(cube)
146+
cube = polarize_solar_to_celestial(cube, dtype=np.float32)
147147
data = cube.data[self.layer]
148148

149149
if self.apply_mask:

0 commit comments

Comments
 (0)