From 5272ac9387ef531471a30e7371bd93158a500213 Mon Sep 17 00:00:00 2001 From: Ned Molter Date: Tue, 27 Aug 2024 16:55:16 -0400 Subject: [PATCH] fixes per @melanieclarke comments --- CHANGES.rst | 12 +++---- docs/jwst/tweakreg/README.rst | 1 - jwst/datamodels/library.py | 5 --- jwst/lib/exposure_types.py | 4 ++- .../outlier_detection_step.py | 2 +- jwst/resample/resample.py | 11 +++++++ jwst/resample/resample_spec.py | 2 -- jwst/resample/resample_spec_step.py | 33 ++++++++----------- jwst/resample/resample_step.py | 3 -- 9 files changed, 35 insertions(+), 38 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 88347e5ae6..1cffa9946e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 @@ -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 -------- diff --git a/docs/jwst/tweakreg/README.rst b/docs/jwst/tweakreg/README.rst index cc4451397f..ea8069f0c0 100644 --- a/docs/jwst/tweakreg/README.rst +++ b/docs/jwst/tweakreg/README.rst @@ -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 diff --git a/jwst/datamodels/library.py b/jwst/datamodels/library.py index c2e9fd867b..9ba0c84ef9 100644 --- a/jwst/datamodels/library.py +++ b/jwst/datamodels/library.py @@ -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"]) diff --git a/jwst/lib/exposure_types.py b/jwst/lib/exposure_types.py index 493695d57a..bddbb720c8 100644 --- a/jwst/lib/exposure_types.py +++ b/jwst/lib/exposure_types.py @@ -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 diff --git a/jwst/outlier_detection/outlier_detection_step.py b/jwst/outlier_detection/outlier_detection_step.py index f9cf4c57ed..965b80797b 100644 --- a/jwst/outlier_detection/outlier_detection_step.py +++ b/jwst/outlier_detection/outlier_detection_step.py @@ -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) diff --git a/jwst/resample/resample.py b/jwst/resample/resample.py index f6c225398c..bd9f91051e 100644 --- a/jwst/resample/resample.py +++ b/jwst/resample/resample.py @@ -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 diff --git a/jwst/resample/resample_spec.py b/jwst/resample/resample_spec.py index 5c68827e78..3444611959 100644 --- a/jwst/resample/resample_spec.py +++ b/jwst/resample/resample_spec.py @@ -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 @@ -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): """ diff --git a/jwst/resample/resample_spec_step.py b/jwst/resample/resample_spec_step.py index 2d23472e0f..bcc3d1a95c 100755 --- a/jwst/resample/resample_spec_step.py +++ b/jwst/resample/resample_spec_step.py @@ -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: @@ -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 diff --git a/jwst/resample/resample_step.py b/jwst/resample/resample_step.py index b5f74e8168..a2fd35db96 100755 --- a/jwst/resample/resample_step.py +++ b/jwst/resample/resample_step.py @@ -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: