Skip to content

Commit

Permalink
WCS tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
astrobc1 committed Jan 10, 2025
1 parent 1fb3d1a commit d8663c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
1 change: 1 addition & 0 deletions liger_iris_pipeline/assign_wcs/assign_wcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from astropy import coordinates as coord
from astropy import units as u
from gwcs import coordinate_frames as cf
from gwcs import WCS

log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
Expand Down
44 changes: 18 additions & 26 deletions liger_iris_pipeline/assign_wcs/assign_wcs_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,23 @@ class AssignWCSStep(LigerIRISStep):

def process(self, input, *args, **kwargs):
reference_file_names = {}
if isinstance(input, str):
input_model = datamodels.open(input)
else:
input_model = input

# If input type is not supported, log warning, set to 'skipped', exit
if not (isinstance(input_model, ImagerModel)):
log.warning("Input dataset type is not supported.")
log.warning("assign_wcs expects ImageModel as input.")
log.warning("Skipping assign_wcs step.")
result = input_model.copy()
self.status = "SKIPPED"
else:
# Get reference files
for reftype in self.reference_file_types:
reffile = self.get_reference_file(input_model, reftype)
reference_file_names[reftype] = reffile if reffile else ""
log.debug(f"reference files used in assign_wcs: {reference_file_names}")

# Assign wcs
result = load_wcs(input_model, reference_file_names)
self.status = "COMPLETE"

# Close model if opened manually
if isinstance(input, str):
input_model.close()
with datamodels.open(input) as input_model:
# If input type is not supported, log warning, set to 'skipped', exit
if not (isinstance(input_model, ImagerModel)):
log.warning("Input dataset type is not supported.")
log.warning("assign_wcs expects ImageModel as input.")
log.warning("Skipping assign_wcs step.")
result = input_model.copy()
self.status = "SKIPPED"
else:
# Get reference files
for reftype in self.reference_file_types:
reffile = self.get_reference_file(input_model, reftype)
reference_file_names[reftype] = reffile if reffile else ""
log.debug(f"reference files used in assign_wcs: {reference_file_names}")

# Assign wcs
result = load_wcs(input_model, reference_file_names)
self.status = "COMPLETE"

return result

0 comments on commit d8663c2

Please sign in to comment.