NSClean

class jwst.clean_flicker_noise.lib.NSClean(detector, mask, fc=0.00390625, kill_width=0.0009765625, buffer_sigma=1.5, sigrej=3.0, weights_kernel_sigma=32)[source]

Bases: object

JWST NIRSpec background modeling and subtraction -AKA “clean” (NSClean).

Fit and remove 1/f noise in NIR detectors in frequency space.

NSClean is the base class for removing residual correlated read noise from JWST NIRSpec images. It is intended for use on Level 2a pipeline products, i.e., IRS2 corrected slope images. All processing is done in detector coordinates, with arrays transposed and flipped so that the IRS2 “zipper” appears along the bottom. For most users, NSClean’s clean() method automatically transposes and flips the data as necessary.

Parameters:
detectorstr

A string selected from {'NRS1', 'NRS2'}

maskndarray of bool

The background model is fitted to pixels set to True. Pixels set to False are ignored.

fcfloat

Critical frequency. This is the 1/2 power point for NSClean’s low pass filter. The units are 1/pixels.

kill_widthfloat

“Kill width”. The low pass filter’s cutoff is 1/2 of a cosine. The filter function goes from 1x to 0x gain over this bandwidth. The units are 1/pixels.

buffer_sigmafloat

Standard deviation of the buffer’s Gaussian smooth. This is an optional 1-dimensional smooth in the spectral dispersion direction only. If selected, buffing is done after modeling the background but before subtracting it.

sigrejfloat

Standard deviation threshold for flagging statistical outliers, to exclude them from use in fitting the background model.

weights_kernel_sigmaint

Used to assign weights for MASK mode fitting.

Methods Summary

clean(data[, buff])

Clean residual noise in NIRSpec images.

fit(data)

Fit a background model to the supplied frame of data.

Methods Documentation

clean(data, buff=True)[source]

Clean residual noise in NIRSpec images.

“Clean” NIRspec images by fitting and subtracting the instrumental background. This is intended to improve the residual correlated noise (vertical banding) that is sometimes seen. Because the banding is not seen by the reference pixels, normal IRS^2 processing does not remove it.

This is an ad-hoc correction. We model the background by fitting it in Fourier space. There is an option to “improve” the result by “buffing” in the spectral dispersion direction. “Buffing” is light smoothing using a 1-dimensional Gaussian.

Parameters:
datandarray

The input data. This should be the normal end result of Stage 1 processing.

buffbool

“Buff” the fitted spectrum by applying a slight Gaussian blur in the spectral dispersion direction.

Returns:
datandarray

The data, but with less striping and the background subtracted.

fit(data)[source]

Fit a background model to the supplied frame of data.

Parameters:
datandarray of float

A NIRSpec image. The image must be in the detector-space orientation with the IRS2 zipper running along the bottom as displayed in SAOImage DS9.

Returns:
bkgndarray of float

The fitted background model.

Notes

Fitting is done line by line because the matrices get very big if one tries to project out Fourier vectors from the entire 2K x 2K image area.