Skip to content

Commit

Permalink
Merge branch 'main' into wcs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRyanIrish committed Apr 26, 2024
2 parents 60f9f99 + 3001645 commit bbdfba7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ndcube/ndcube.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,8 @@ class NDCubeBase(NDCubeABC, astropy.nddata.NDData, NDCubeSlicingMixin):
def __init__(self, data, wcs=None, uncertainty=None, mask=None, meta=None,
unit=None, copy=False, **kwargs):

super().__init__(data, uncertainty=uncertainty, mask=mask,
super().__init__(data, wcs=wcs, uncertainty=uncertainty, mask=mask,
meta=meta, unit=unit, copy=copy, **kwargs)
if not self.wcs:
self.wcs = wcs # This line is required as a patch for an astropy bug.
# Above line is in if statement to prevent WCS being overwritten with None
# if we are instantiating from an NDCube.

# Enforce that the WCS object is not None
if self.wcs is None:
Expand Down Expand Up @@ -1212,8 +1208,14 @@ def my_propagate(uncertainty, data, mask, **kwargs):
new_wcs = ResampledLowLevelWCS(self.wcs.low_level_wcs, bin_shape[::-1])

# Reform NDCube.
new_cube = type(self)(new_data, new_wcs, uncertainty=new_uncertainty, mask=new_mask,
meta=self.meta, unit=new_unit)
new_cube = type(self)(
data=new_data,
wcs=new_wcs,
uncertainty=new_uncertainty,
mask=new_mask,
meta=self.meta,
unit=new_unit
)
new_cube._global_coords = self._global_coords
# Reconstitute extra coords
if not self.extra_coords.is_empty:
Expand Down

0 comments on commit bbdfba7

Please sign in to comment.