Skip to content

Commit

Permalink
Fix computation of the photometric keywords PIXAR_* and scale resampl…
Browse files Browse the repository at this point in the history
…ed intensities according to actual pixel scale ratio.
  • Loading branch information
mcara committed Sep 14, 2023
1 parent 6d78b07 commit c072859
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 28 deletions.
19 changes: 15 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ charge_migration
- Step was renamed from undersampling_migration. Changed default signal threshold,
added efficient routine to flag neighborhood pixels, added new unit test,
improved earlier unit tests, updated docs. [#7825]

cube_build
----------

Expand Down Expand Up @@ -141,7 +141,7 @@ pathloss
- Fix interpolation error for point source corrections. [#7799]

- Update the MIRI LRS fixed-slit correction to default to the center of the slit
when the computed target location is outside the slit. Add the parameter
when the computed target location is outside the slit. Add the parameter
"user_slit_loc" to allow specifying the source location to use. [#7806]

photom
Expand Down Expand Up @@ -179,12 +179,23 @@ resample
- Update the following exposure time keywords: XPOSURE (EFFEXPTM),
DURATION and TELAPSE. [#7793]

- Recognize additional keys in ASDF files that provide ``output_wcs`` for the
resample step. [#7894]

- Set output image size when ``output_wcs`` is provided based on the largest
coordinates in the bounding box of the ``output_wcs``. [#7894]

- Completely re-designed computation of the pixel area keywords
``PIXAR_SR`` and ``PIXAR_A2`` for the resampled image. This change also
results in modified values in the resampled images. New computations
significantly reduce photometric errors. [#7894]

residual_fringe
---------------

- Use scipy.interpolate.BSpline instead of astropy.modeling.Spline1D in
residual_fringe fitting utils [#7764]

undersampling_correction
------------------------

Expand All @@ -193,7 +204,7 @@ undersampling_correction

- Removed directories for undersampling_correction step, as the step has been
renamed charge_migration. [#7850]


1.11.4 (2023-08-14)
===================
Expand Down
18 changes: 17 additions & 1 deletion docs/jwst/resample/arguments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,23 @@ image.
under the root of the file. The output image size is determined from the
bounding box of the WCS (if any). Argument ``output_shape`` overrides
computed image size and it is required when output WCS does not have
``bounding_box`` property set.
``bounding_box`` property set or if ``pixel_shape`` or ``array_shape`` keys
(see below) are not provided.

Additional information may be stored under
other keys under the root of the file. Currently, the following keys are
recognized:

- ``pixel_area``: Indicates average pixel area of the output WCS in
units of steradians. When provided, this value will be used for updating
photometric quantities ``PIXAR_SR`` and ``PIXAR_A2`` of the output image.
If ``pixel_area`` is not provided, the code will attempt to estimate
this value from the WCS.

- ``pixel_shape``: dimensions of the output image in the order (nx, ny).
Overrides the value of ``array_shape`` if provided.

- ``array_shape``: shape of the output image in ``numpy`` order: (ny, nx).

.. note::
When ``output_wcs`` is specified, WCS-related arguments such as
Expand Down
8 changes: 7 additions & 1 deletion jwst/model_blender/blendmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Primary functional interface for the code


def blendmodels(product, inputs=None, output=None, verbose=False):
def blendmodels(product, inputs=None, output=None, ignore=None, verbose=False):
"""
Run main interface for blending metadata from multiple models.
Expand Down Expand Up @@ -73,6 +73,10 @@ def blendmodels(product, inputs=None, output=None, verbose=False):
If provided, update `meta.filename` in the blended `product`
to define what file this model will get written out to.
ignore : list of str, None, optional
A list of string the meta attribute names which, if provided,
will show which attributes should not be blended.
verbose : bool, optional [Default: False]
Print out additional messages during processing when specified.
Expand Down Expand Up @@ -122,6 +126,8 @@ def blendmodels(product, inputs=None, output=None, verbose=False):
# Start by identifying elements of the model which need to be ignored
ignore_list = _build_schema_ignore_list(newmeta._schema)
ignore_list += ['meta.wcs'] # Necessary since meta.wcs is not in schema
if ignore:
ignore_list.extend(ignore)

# Now assign values from new_hdrs to output_model.meta
flat_new_metadata = newmeta.to_flat_dict()
Expand Down
17 changes: 14 additions & 3 deletions jwst/resample/gwcs_drizzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def outcon(self, value):
self._product.con = value

def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
expin=1.0, in_units="cps", wt_scl=1.0):
expin=1.0, in_units="cps", wt_scl=1.0, iscale=1.0):
"""
Combine an input image with the output drizzled image.
Expand Down Expand Up @@ -185,6 +185,11 @@ def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
initialized with wt_scl set to "exptime" or "expsq", the exposure time
will be used to set the weight scaling and the value of this parameter
will be ignored.
iscale : float, optional
A scale factor to be applied to pixel intensities of the
input image before resampling.
"""
if self.wt_scl == "exptime":
wt_scl = expin
Expand All @@ -197,7 +202,8 @@ def add_image(self, insci, inwcs, inwht=None, xmin=0, xmax=0, ymin=0, ymax=0,
dodrizzle(insci, inwcs, inwht, self.outwcs, self.outsci, self.outwht,
self.outcon, expin, in_units, wt_scl, uniqid=self.uniqid,
xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
pixfrac=self.pixfrac, kernel=self.kernel, fillval=self.fillval)
iscale=iscale, pixfrac=self.pixfrac, kernel=self.kernel,
fillval=self.fillval)

def increment_id(self):
"""
Expand Down Expand Up @@ -227,7 +233,7 @@ def increment_id(self):

def dodrizzle(insci, input_wcs, inwht, output_wcs, outsci, outwht, outcon,
expin, in_units, wt_scl, uniqid=1, xmin=0, xmax=0, ymin=0, ymax=0,
pixfrac=1.0, kernel='square', fillval="INDEF"):
iscale=1.0, pixfrac=1.0, kernel='square', fillval="INDEF"):
"""
Low level routine for performing 'drizzle' operation on one image.
Expand Down Expand Up @@ -303,6 +309,10 @@ def dodrizzle(insci, input_wcs, inwht, output_wcs, outsci, outwht, outcon,
no maximum will be set in the y dimension (all pixels in a column
of the input image will be resampled).
iscale : float, optional
A scale factor to be applied to pixel intensities of the
input image before resampling.
pixfrac : float, optional
The fraction of a pixel that the pixel flux is confined to. The
default value of 1 has the pixel flux evenly spread across the image.
Expand Down Expand Up @@ -389,6 +399,7 @@ def dodrizzle(insci, input_wcs, inwht, output_wcs, outsci, outwht, outcon,
uniqid=uniqid,
xmin=xmin, xmax=xmax,
ymin=ymin, ymax=ymax,
scale=iscale,
pixfrac=pixfrac,
kernel=kernel,
in_units=in_units,
Expand Down
Loading

0 comments on commit c072859

Please sign in to comment.