Description ----------- :Class: `jwst.coron.AlignRefsStep` :Alias: align_refs The ``align_refs`` step is one of the coronagraphic-specific steps in the ``coron`` sub-package that is part of Stage 3 :ref:`calwebb_coron3 ` processing. It computes offsets between science target images and reference PSF images, and shifts the PSF images into alignment. The alignment shifts are computed from the first integration and applied to all the subsequent ones for both the science target data and the reference PSF data. Each integration contained in the stacked PSF data (the result of the :ref:`stack_refs `) step is aligned to the first integration within a given science target exposure. This results in a new product for each science target exposure that contains a stack of individual PSF images that have been aligned to the first integration in the science target exposure. Note that aligning to the first science integration is sufficient because flight data shows that there are minimal drifts during an observation in line-of-sight pointing, or in PSF properties. Shifts between each PSF and target image are computed using the ``scipy.optimize.leastsq`` function. A 2D mask, supplied via a PSFMASK reference file, is used to indicate pixels to ignore when performing the minimization in the ``leastsq`` routine. The mask acts as a weighting function in performing the fit. Alignment of a PSF image is performed using the ``scipy.ndimage.fourier_shift`` function and the computed sub-pixel offsets. Arguments --------- The ``align_refs`` step has two optional arguments: ``--median_box_length`` (integer, default=3) The box size to use when replacing bad pixels with the median in a surrounding box. ``--bad_bits`` (string, default="DO_NOT_USE") The DQ bit values from the input image DQ arrays that should be considered bad and replaced with the median in a surrounding box. For example, setting to ``"OUTLIER, SATURATED"`` (or equivalently ``"16, 2"`` or ``"18"``) will treat all pixels flagged as OUTLIER or SATURATED as bad, while setting to ``""`` or ``None`` will treat all pixels as good and omit any bad pixel replacement. Inputs ------ The ``align_refs`` step takes 2 inputs: a science target exposure containing a 3D stack of calibrated per-integration images and a "_psfstack" product containing a 3D stack of reference PSF images. If the target or PSF images have any of the data quality flags set to those specified by the ``bad_bits`` argument, these pixels are replaced with the median value of a region around the flagged data. The size of the box region to use for the replacement can also be specified. These corrected images are used in the :ref:`align_refs ` step and passed along for subsequent processing. 3D calibrated images ^^^^^^^^^^^^^^^^^^^^ :Data model: `~jwst.datamodels.CubeModel` :File suffix: _calints One of the science target exposures specified in the ASN file used as input to the :ref:`calwebb_coron3 ` pipeline. This should be a "_calints" product from the :ref:`calwebb_image2 ` pipeline and contains a 3D stack of per-integration images. 3D stacked PSF images ^^^^^^^^^^^^^^^^^^^^^ :Data model: `~jwst.datamodels.CubeModel` :File suffix: _psfstack A "_psfstack" product created by the :ref:`stack_refs ` step, which contains the collection of all PSF images to be used, in the form of a 3D image stack. Outputs ------- 3D aligned PSF images ^^^^^^^^^^^^^^^^^^^^^ :Data model: `~jwst.datamodels.CubeModel` :File suffix: _psfalign The output is a CubeModel, where the 0th axis has length equal to the total number of integrations (nints x ncols x nrows). Each Image[n] in the 3D data is the n :sup:`th` PSF image aligned to the first science target integration. The file name is exposure-based, using the input science target exposure name as the root, with the addition of the association candidate ID and the "_psfalign" product type suffix, e.g. "jw8607342001_02102_00001_nrcb3_a3001_psfalign.fits." Reference Files --------------- The ``align_refs`` step uses a PSFMASK reference file. .. include:: ../references_general/psfmask_reffile.inc