Skip to content

Commit

Permalink
fixes per @melanieclarke comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emolter committed Aug 27, 2024
1 parent e828ebc commit 5272ac9
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 38 deletions.
12 changes: 6 additions & 6 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cube_build
datamodels
----------

- Added `ModelLibrary` class to allow passing ``"on-disk"`` models between steps in the
- Added `ModelLibrary` class to allow passing on-disk models between steps in the
image3 pipeline. [#8683]

emicorr
Expand Down Expand Up @@ -68,17 +68,17 @@ outlier_detection
- Fixed failures due to a missing ``wcs.array_shape`` attribute when the
``outlier_detection`` step was run standalone using e.g. ``strun`` [#8645]

set_telescope_pointing
----------------------

- replace usage of ``copy_arrays=True`` with ``memmap=False`` [#8660]

- Refactored separate modes into submodules instead of inheriting from a base class.
Moved non-JWST-specific code to stcal. [#8613]

- For imaging modes, step now uses `ModelLibrary` to handle accessing models consistently
whether they are in memory or on disk. [#8683]

set_telescope_pointing
----------------------

- replace usage of ``copy_arrays=True`` with ``memmap=False`` [#8660]

pipeline
--------

Expand Down
1 change: 0 additions & 1 deletion docs/jwst/tweakreg/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ other ways of supplying custom source catalogs to the step:

1. Adding ``tweakreg_catalog`` attribute to the ``members`` of the input ASN
table - see `~jwst.datamodels.ModelLibrary` for more details.
# FIXME: does this still work as described?
Catalog file names are relative to ASN file path.

2. Providing a simple two-column text file, specified via step's parameter
Expand Down
5 changes: 0 additions & 5 deletions jwst/datamodels/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ def _assign_member_to_model(self, model, member):
if not hasattr(model.meta, "asn"):
model.meta["asn"] = {}

# if (model.meta.asn.table_name is None) and ("table_name" in self.asn.keys()): # do not clobber existing values
# setattr(model.meta.asn, "table_name", self.asn["table_name"])

# if (model.meta.asn.pool_name is None) and ("asn_pool" in self.asn.keys()): # do not clobber existing values
# setattr(model.meta.asn, "pool_name", self.asn["asn_pool"])
if "table_name" in self.asn.keys():
setattr(model.meta.asn, "table_name", self.asn["table_name"])

Expand Down
4 changes: 3 additions & 1 deletion jwst/lib/exposure_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def is_nrs_autoflat(datamodel):

def is_moving_target(datamodel):
""" Determine if a moving target exposure."""
if (hasattr(datamodel.meta.target, 'type') and datamodel.meta.target.type is not None and datamodel.meta.target.type.lower() == 'moving'):
if (hasattr(datamodel.meta.target, 'type') \
and datamodel.meta.target.type is not None \
and datamodel.meta.target.type.lower() == 'moving'):
return True
return False
2 changes: 1 addition & 1 deletion jwst/outlier_detection/outlier_detection_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def process(self, input_data):
else:
self.log.error("Outlier detection failed for unknown/unsupported ",
f"mode: {mode}")
return self._set_status(input_data, True)
return self._set_status(input_data, False)

return self._set_status(result_models, True)

Expand Down
11 changes: 11 additions & 0 deletions jwst/resample/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,17 @@ def compute_image_pixel_area(wcs):


def copy_asn_info_from_library(library, output_model):
"""
Transfer association information from the input library to the output model.
Parameters
----------
library : ModelLibrary
The input library of data models.
output_model : DataModel
The output data model to which the association information will be copied.
"""
if not hasattr(library, "asn"):
# No ASN table, occurs when input comes from ModelContainer in spectroscopic modes
# in this case do nothing; the asn info will be passed along later
Expand Down
2 changes: 0 additions & 2 deletions jwst/resample/resample_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from stdatamodels.jwst import datamodels

from jwst.assign_wcs.util import compute_scale, wrap_ra
from jwst.datamodels import ModelContainer
from jwst.resample import resample_utils
from jwst.resample.resample import ResampleData

Expand Down Expand Up @@ -191,7 +190,6 @@ def __init__(self, input_models, output=None, single=False, blendheaders=False,
self.blank_output.meta.photometry.pixelarea_arcsecsq = (
output_pix_area * np.rad2deg(3600)**2)

self.output_models = ModelContainer()

def build_nirspec_output_wcs(self, input_models, refmodel=None):
"""
Expand Down
33 changes: 14 additions & 19 deletions jwst/resample/resample_spec_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ def _process_multislit(self, input_models):
resamp = resample_spec.ResampleSpecData(container, **self.drizpars)

library = ModelLibrary(container, on_disk=False)
library = resamp.do_drizzle(library)
with library:
for i, model in enumerate(library):
container[i] = model
library.shelve(model, modify=False)
del library

for model in container:
self.update_slit_metadata(model)
update_s_region_spectral(model)
result.slits.append(model)
drizzled_library = resamp.do_drizzle(library)
with drizzled_library:
for i, model in enumerate(drizzled_library):
self.update_slit_metadata(model)
update_s_region_spectral(model)
result.slits.append(model)
drizzled_library.shelve(model, i, modify=False)
del library, drizzled_library

# Keep the first computed pixel scale ratio for storage
if self.pixel_scale is not None and pscale_ratio is None:
Expand Down Expand Up @@ -211,14 +208,12 @@ def _process_slit(self, input_models):
resamp = resample_spec.ResampleSpecData(input_models, **self.drizpars)

library = ModelLibrary(input_models, on_disk=False)
library = resamp.do_drizzle(library)
with library:
for i, model in enumerate(library):
input_models[i] = model
library.shelve(model, modify=False)
del library

result = input_models[0]
drizzled_library = resamp.do_drizzle(library)
with drizzled_library:
result = drizzled_library.borrow(0)
drizzled_library.shelve(result, 0, modify=False)
del library, drizzled_library

result.meta.bunit_data = input_models[0].meta.bunit_data
if self.pixel_scale is None:
result.meta.resample.pixel_scale_ratio = self.pixel_scale_ratio
Expand Down
3 changes: 0 additions & 3 deletions jwst/resample/resample_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ def process(self, input):
else:
model.meta.resample.pixel_scale_ratio = resamp.pscale_ratio
model.meta.resample.pixfrac = kwargs['pixfrac']
# update filename to reflect new product
# necessary to get source_catalog output names to match i2d filename
# model.meta.filename = self.output_file
result.shelve(model)

if len(result) == 1:
Expand Down

0 comments on commit 5272ac9

Please sign in to comment.