Skip to content

Commit

Permalink
Add from_hdul kwarg to CubeField instead of messy meta :P
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg committed Sep 17, 2024
1 parent 12fc225 commit 5d7f74f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scopesim/source/source_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,11 @@ def __post_init__(self):
class CubeSourceField(HDUSourceField):
"""Source field with 3D data cube."""

from_hdul: bool = False

def __post_init__(self):
"""Validate input."""
if self.wcs is None and not self.meta.get("from_hdul", False):
if self.wcs is None and not self.from_hdul:
self.wcs = WCS(self.field)

Check warning on line 282 in scopesim/source/source_fields.py

View check run for this annotation

Codecov / codecov/patch

scopesim/source/source_fields.py#L282

Added line #L282 was not covered by tests

try:
Expand All @@ -295,7 +297,7 @@ def from_hdulist(cls, hdulist: fits.HDUList, ext: int = 0, **kwargs):
"""Load source cube from HDUL."""
cube = fits.ImageHDU(header=hdulist[ext].header.copy(),

Check warning on line 298 in scopesim/source/source_fields.py

View check run for this annotation

Codecov / codecov/patch

scopesim/source/source_fields.py#L298

Added line #L298 was not covered by tests
data=deepcopy(hdulist[ext].data))
new_csf = cls(field=cube, meta=kwargs | {"from_hdul": True})
new_csf = cls(field=cube, meta=kwargs, from_hdul=True)
new_csf.wcs = WCS(hdulist[ext], fobj=hdulist)
return new_csf

Check warning on line 302 in scopesim/source/source_fields.py

View check run for this annotation

Codecov / codecov/patch

scopesim/source/source_fields.py#L300-L302

Added lines #L300 - L302 were not covered by tests

Expand Down

0 comments on commit 5d7f74f

Please sign in to comment.