NIRDataset

class jwst.refpix.reference_pixels.NIRDataset(input_model, odd_even_columns, use_side_ref_pixels, side_smoothing_length, side_gain, conv_kernel_params, siglimit)[source]

Bases: Dataset

Container for NIR detector datasets.

Parameters:
input_modelJwstDataModel

Science data model to be corrected.

odd_even_columnsbool

Flag that controls whether odd and even-numbered columns are processed separately.

use_side_ref_pixelsbool

Flag that controls whether the side reference pixels are used in the correction.

side_smoothing_lengthint

Smoothing length to use in calculating the running median of the side reference pixels.

side_gainfloat

Gain to use in applying the side reference pixel correction.

conv_kernel_paramsdict

Dictionary containing the parameters needed for the optimized convolution kernel.

siglimitfloat

Sigma clipping limit, in standard deviations from the mean, to use in sigma clipping for calculating the mean of reference pixels.

Methods Summary

apply_multistripe_correction(group, ...)

Remove the reference pixel signal from the data.

apply_side_correction(group, sidegroup)

Apply reference pixel correction from the side reference pixels.

average_with_none(a, b)

Average two numbers.

calculate_side_ref_signal(group, colstart, ...)

Calculate the reference pixel signal from the side reference pixels.

collect_even_refpixels(group, amplifier, ...)

Collect even reference pixels.

collect_odd_refpixels(group, amplifier, ...)

Collect odd reference pixels.

combine_ref_signals(left, right)

Combine the left and right reference signals.

combine_with_nans(a, b)

Combine 2 1-D arrays that have NaNs.

create_reflected(data, smoothing_length)

Make an array bigger by extending it at the top and bottom.

detector_to_dms(integration, group)

Convert data from detector to DMS frame.

dms_to_detector(integration, group)

Convert data from DMS to detector frame.

dms_to_detector_dq()

Convert DQ data from DMS to detector frame.

do_corrections()

Do reference pixel correction for NIR data.

do_fullframe_corrections()

Do Reference Pixels Corrections for full frame data.

do_multistripe_corrections()

Do reference pixel corrections for multistripe data.

do_side_correction(group)

Do all the steps of the side reference pixel correction.

do_subarray_corrections()

Do corrections for subarrays.

do_top_bottom_correction(group, refvalues)

Do the top/bottom correction.

get_amplifier_refvalue(group, amplifier, ...)

Calculate the reference pixel mean for a given amplifier.

get_even_refvalue(group, amplifier, ...)

Calculate the reference pixel mean in even-numbered columns.

get_multistripe_refvalues(group, stripe_idx, ...)

Collect refpix values for each amplifier.

get_odd_refvalue(group, amplifier, top_or_bottom)

Calculate the reference pixel mean in odd-numbered columns.

get_refvalues(group)

Get the reference pixel values.

make_irs2_odd_mask(input_model[, ...])

Make an odd pixel mask for IRS2 mode.

median_filter(data, dq, smoothing_length)

Perform simple median filter.

Methods Documentation

apply_multistripe_correction(group, refvalues, fastmin)[source]

Remove the reference pixel signal from the data.

Parameters:
groupndarray[float]

The current group being corrected.

refvaluesdict

The dictionary of reference pixel signals.

fastminint

The subarray offset in the fast read direction.

Returns:
ndarray[float]

The group with the reference pixel signal removed.

apply_side_correction(group, sidegroup)[source]

Apply reference pixel correction from the side reference pixels.

Parameters:
groupndarray

Group being processed

sidegroupndarray

Side reference pixel signal replicated horizontally

Returns:
corrected_groupndarray

The group corrected for the side reference pixel signal

average_with_none(a, b)[source]

Average two numbers.

If one is None, return the other. If both are None, return None.

Parameters:
afloat or None

First number to be averaged

bfloat or None

Second number to be averaged

Returns:
resultfloat or None

Average of the two numbers

calculate_side_ref_signal(group, colstart, colstop)[source]

Calculate the reference pixel signal from the side reference pixels.

Calculate by running a box up the side reference pixels and calculating the running median.

Parameters:
groupndarray

Group that is being processed

colstartint

Starting column

colstopint

Ending column

Returns:
ndarray

Median filtered version of the side reference pixels

collect_even_refpixels(group, amplifier, top_or_bottom)[source]

Collect even reference pixels.

For traditional readouts, even pixels correspond to even-numbered rows (second, fourth, sixth, etc.), which are odd array indices.

For IRS2 mode, science and traditional reference pixels have the same parity, but interleaved pixels come in two pairs. The first two are odd and the second two are even.

Parameters:
groupndarray

The group that is being processed

amplifier{‘A’, ‘B’, ‘C’, ‘D’}

String corresponding to the amplifier being processed

top_or_bottom{‘top’, ‘bottom’}

String corresponding to whether top or bottom reference pixels are bing processed

Returns:
evenrefndarray

Array containing all the even reference pixels

evendqndarray

Array containing all the even dq values for those reference pixels

collect_odd_refpixels(group, amplifier, top_or_bottom)[source]

Collect odd reference pixels.

For traditional readouts, odd pixels correspond to odd-numbered rows (first, third, fifth, etc.), which are even array indices.

For IRS2 mode, science and traditional reference pixels have the same parity, but interleaved pixels come in two pairs. The first two are odd and the second two are even.

Parameters:
groupndarray

The group that is being processed

amplifier{‘A’, ‘B’, ‘C’, ‘D’}

String corresponding to the amplifier being processed

top_or_bottom{‘top’, ‘bottom’}

String corresponding to whether top or bottom reference pixels are bing processed

Returns:
oddrefndarray

Array containing all the odd reference pixels

odddqndarray

Array containing all the odd dq values for those reference pixels

combine_ref_signals(left, right)[source]

Combine the left and right reference signals.

Average row-by-row.

Parameters:
leftndarray

1-D array of median-filtered reference pixel values from the left side

rightndarray

1-D array of median-filtered reference pixel values from the right side

Returns:
sidegroupndarray

2-D array of average reference pixel vector replicated horizontally

combine_with_nans(a, b)[source]

Combine 2 1-D arrays that have NaNs.

  • Wherever both arrays are NaN, output is 0.0.

  • Wherever a is NaN and b is not, return b.

  • Wherever b is NaN and a is not, return a.

  • Wherever neither a nor b is NaN, return the average of a and b.

Parameters:
andarray

First array to combine

bndarray

Second array to combine

Returns:
resultndarray

Combined array

create_reflected(data, smoothing_length)[source]

Make an array bigger by extending it at the top and bottom.

Extend by an amount equal to .5 (smoothing length-1), as the smoothing length will be odd. The extension is a reflection of the ends of the input array.

Parameters:
datandarray

Input data array.

smoothing_lengthint

Smoothing length; should be odd, will be converted if not. Amount by which the input array is extended is smoothing_length // 2 at the bottom and smoothing_length // 2 at the top.

Returns:
reflectedndarray

Array that has been extended at the top and bottom by reflecting the first and last few rows.

detector_to_dms(integration, group)[source]

Convert data from detector to DMS frame.

Parameters:
integrationint

Integration number

groupint

Group number

dms_to_detector(integration, group)[source]

Convert data from DMS to detector frame.

Parameters:
integrationint

Integration number

groupint

Group number

dms_to_detector_dq()[source]

Convert DQ data from DMS to detector frame.

do_corrections()[source]

Do reference pixel correction for NIR data.

do_fullframe_corrections()[source]

Do Reference Pixels Corrections for full frame data.

Correct all amplifiers, NIR detectors. The first read of each integration is NOT subtracted, as the signal is removed in the superbias subtraction step.

do_multistripe_corrections()[source]

Do reference pixel corrections for multistripe data.

Existing reference pixel algorithms assume fixed, contiguous refpix regions; multistripe needs separate methods.

do_side_correction(group)[source]

Do all the steps of the side reference pixel correction.

Parameters:
groupndarray

Group being processed

Returns:
corrected_groupndarray

Corrected group

do_subarray_corrections()[source]

Do corrections for subarrays.

Reference pixel values are calculated separately for odd and even columns if odd_even_columns is True, otherwise a single number calculated from all reference pixels

do_top_bottom_correction(group, refvalues)[source]

Do the top/bottom correction.

Parameters:
groupndarray

Group that is being processed. The parameter group is corrected for the bias drift using the top and bottom reference pixels

refvaluesdict

Dictionary of reference pixel clipped means

get_amplifier_refvalue(group, amplifier, top_or_bottom)[source]

Calculate the reference pixel mean for a given amplifier.

Parameters:
groupndarray

Group that is being processed

amplifier{‘A’, ‘B’, ‘C’, ‘D’}

Amplifier that is being processed

top_or_bottom{‘top’, ‘bottom’}

Processing top or bottom reference pixels?

Returns:
oddfloat

Value of the clipped mean of the reference pixels in odd-numbered columns (if self.odd_even_columns)

evenfloat

Value of the clipped mean of the reference pixels in even-numbered columns (if self.odd_even_columns)

meanfloat

Value of the clipped mean of the reference pixels in both odd-numbered and even-numbered columns (if not self.odd_even_columns)

get_even_refvalue(group, amplifier, top_or_bottom)[source]

Calculate the reference pixel mean in even-numbered columns.

Parameters:
groupndarray

Group that is being processed

amplifier{‘A’, ‘B’, ‘C’, ‘D’}

Amplifier that is being processed

top_or_bottom{‘top’, ‘bottom’}

Processing top or bottom reference pixels?

Returns:
evenfloat

Value of the clipped mean of the reference pixels in even-numbered columns

get_multistripe_refvalues(group, stripe_idx, fastmin)[source]

Collect refpix values for each amplifier.

If odd_even_columns, additionally separate each amplifier reference value by odd and even column. All values returned are sigma- clipped.

Parameters:
groupndarray[float]

The current group to be corrected.

stripe_idxint

The stripe index for superstripe observations. For substripe, this should be set to -1.

fastminint

The subarray offset in the fast read direction.

Returns:
refpixdict

The dictionary of reference values, keyed on amplifier name and stored either as odd and even values, or as the mean value.

get_odd_refvalue(group, amplifier, top_or_bottom)[source]

Calculate the reference pixel mean in odd-numbered columns.

Parameters:
groupndarray

Group that is being processed

amplifier{‘A’, ‘B’, ‘C’, ‘D’}

Amplifier that is being processed

top_or_bottom{‘top’, ‘bottom’}

Processing top or bottom reference pixels?

Returns:
oddfloat

Value of the clipped mean of the reference pixels in odd-numbered columns

get_refvalues(group)[source]

Get the reference pixel values.

Get values for each amplifier, odd and even columns and top and bottom reference pixels.

Parameters:
groupndarray

Group that is being processed.

Returns:
refpixdict

Dictionary containing the clipped mean of the reference pixels for each amplifier, odd and even columns (if selected, otherwise all columns) and top and bottom.

make_irs2_odd_mask(input_model, scipix_n_default=16, refpix_r_default=4)[source]

Make an odd pixel mask for IRS2 mode.

The even pixel mask can be generated by inverting the odd mask.

Parameters:
input_modelJwstDataModel

Input model containing data to mask.

scipix_n_defaultint, optional

Number of regular samples before stepping out to collect reference samples.

refpix_r_defaultint, optional

Number of reference samples before stepping back in to collect regular samples.

Returns:
odd_maskndarray

Boolean array matching data column size in detector orientation. True identifies all odd pixels (science and reference).

median_filter(data, dq, smoothing_length)[source]

Perform simple median filter.

Run a box of the same width as the data and height = smoothing_length. Reflect the data at the top and bottom.

Parameters:
datandarray

Input 2-D science array.

dqndarray

Input 2-D DQ array.

smoothing_lengthint

Height of box within which the median value is calculated. Should be odd.

Returns:
resultndarray

1-D array that is a median filtered version of the input data.