StreamCleanStep#

snowblind.StreamCleanStep, run with strun stream_clean. Removes 1/f noise (striping) from the ramp along each output channel’s readout stream, with the same linear filter on every group difference. Replaces the jwst clean_flicker_noise step. Guide: 1/f cleaning along the readout stream and reset-anchored ramp fitting.

Parameters:
fit_methodone of 'wiener', 'row_median', 'none', 'auto', default 'auto'

noise estimator per channel; auto is wiener, except none (no stream filter, only the even-odd and column offsets) on a grism whose dispersion runs along the readout stream (NIRISS GR150R, NIRCam GRISMR), where faint trace shapes would be read as noise; naming wiener or row_median there runs it at that risk

background_methodone of 'mean', 'median', 'integration_model', 'exposure_model', 'crds_background', None, default 'mean'

background removed before fitting and put back after, so it sets the sky level: mean leaves the sky as it was (imaging and darks), median puts it at the median, integration_model and exposure_model (box models) also keep extended structure above their box, crds_background (the scaled CRDS background reference) is the default on WFSS exposures, None removes the mean level (sky or dark current) too

background_box_sizelist of 2 integers, default None

box size of the box-spline background (integration_model, exposure_model); default 32 by 32

apply_flat_fieldboolean, default True

measure the background on the flat-fielded difference (the sky times the response); without a flat reference the raw difference is used

reference_unitsone of 'auto', 'raw', 'flat_fielded', default 'auto'

units of the CRDS background reference: raw (it carries the detector’s pixel response, as the NIRISS files do), flat_fielded (as the NIRCam files are), or auto (decided from its pixel pattern against the flat)

user_maskstring, default None

path to a user-supplied background mask

mask_dilationinteger, default 0

pixels by which to grow the masked (source) regions, for source wings

mask_spikesboolean, default True

mask the column-aligned spikes of saturated stars along their extent (chisel mask only)

allow_dispersion_along_streamboolean, default None

deprecated, will be removed: True is fit_method wiener on a grism whose dispersion runs along the readout stream; use fit_method

clean_first_groupboolean, default True

also clean group 1, against zero or against the reset prior; needed for reset_rampfit, harmless for OLS

reset_calibstring, default None

snowblind-reset-calib ASDF; with it the first read is cleaned against its reset-level prior, as reset_rampfit will use it

scene_modelstring, default None

FITS image of the scene in DN/s, detector frame, before flat-fielding (e.g. the blotted mosaic); replaces the background model

min_densityfloat, default 0.2

local background fraction below which the estimate tapers off

outlier_sigmafloat, default 10.0

a background pixel further than this many robust sigma from the background of a group difference, and its four neighbours, are left out of that difference’s fit (an unflagged cosmic ray, a pixel recovering from saturation); None keeps them

first_directioninteger, default 1

readout direction of channel 0 in the detector frame, 1 or -1

even_odd_columnsboolean, default None

remove the per-channel even-odd column offset of each difference; the default, None, is on, except on WFSS exposures whose traces run along the columns (NIRISS GR150C, NIRCam GRISMC); True or False overrides

column_offsetsboolean, default None

remove each column’s masked mean from each difference (a per-column offset that drifts during the integration); the default, None, is on, except on WFSS exposures whose traces run along the columns (NIRISS GR150C, NIRCam GRISMC), where they would bias the means, and on NIRSpec spectroscopy, where a column runs the length of a spectrum and its offset would come from the few pixels outside the slits; True or False overrides

anchor_meanboolean, default True

set each channel’s mean removed noise to the masked mean of the residual, so a robust estimator cannot bias the sky

max_laginteger, default 65536

autocorrelation length in pixel times for the noise spectrum; wiener only

min_periodinteger, default None

pixel times (10 microseconds each); the wiener gain is zero for shorter periods. None is the instrument default, 300 on NIRCam and NIRISS, 600 on NIRSpec IRS2 and 442 on the other NIRSpec read patterns (the same length of stream); 0 keeps all periods

edge_couplingboolean, default True

measure how much of its channel’s 1/f noise each column near the physical edges of the detector carries, and the noise those edges carry on their own, and correct for both (NRS2 has both, at about half the interior’s amplitude); measures 1 and nothing on the other detectors, where it then changes nothing; wiener only

save_maskboolean, default False

save the background mask

save_noiseboolean, default False

save the removed noise

save_spectraboolean, default False

save per-channel spectra and gains; wiener only

override_flatis_string_or_datamodel, default None

Override the flat reference file

override_bkgis_string_or_datamodel, default None

Override the bkg reference file

The parameters every stpipe step has (skip, save_results, output_dir, suffix, pre_hooks, post_hooks and the others) are described in the stpipe documentation.

class snowblind.StreamCleanStep(name=None, parent=None, config_file=None, _validate_kwds=True, **kws)#

Remove 1/f noise from NIR group data by filtering each channel’s readout stream.

Input is a ~stdatamodels.jwst.datamodels.RampModel after the jump step, or any group-level product with groupdq populated. Output is the same model type with cleaned data and meta.cal_step.stream_clean set to COMPLETE. Reference pixels are expected to have been handled upstream by the refpix step; they take part in the clock grid but are not used to fit the noise.

The main options (see spec for the full list and defaults): fit_method picks the per-channel noise estimator (wiener, row_median or none; the default auto is wiener, or none on a grism that disperses along the readout stream); background_method and scene_model choose the background removed before the fit (crds_background, the default on WFSS exposures, scales the CRDS background reference once to the ramp); user_mask, mask_dilation and mask_spikes control which pixels count as background; clean_first_group and reset_calib extend the cleaning to group 1 (and the zeroframe) against zero or the reset-level prior; even_odd_columns, column_offsets and anchor_mean remove per-channel offsets around the stream filter; save_mask, save_noise and save_spectra write intermediate products. The step records what it did to the sky level in meta.snowblind.stream_clean: sky_mean_minus_median of the background pixels (the shift a median background would impose, header card SKYMNMED) and sky_change_by_cleaning (card SKYCHG), both in DN/s of the flat-fielded sky, and each per integration.

process(input_data)#

Clean the group data of a ramp.

The input is copied, the scene mask is built, every group difference is cleaned with clean_ramp and the optional mask, noise and spectra products are saved. Unsupported input (see _unsupported_reason) or a mask whose shape does not match the data leaves the copy unchanged with the step marked SKIPPED.

Parameters:
input_datastr or ~stdatamodels.jwst.datamodels.RampModel

Group-level data with groupdq populated; a filename is opened with jwst.datamodels.open.

Returns:
~stdatamodels.jwst.datamodels.RampModel

Cleaned copy of the input, with data (and zeroframe when it was cleaned) replaced and meta.cal_step.stream_clean set to COMPLETE, or the unchanged copy marked SKIPPED.