hispecdrp.primitives.refpix.reference_SCALES_DRP
Functions
|
Row-dependent differences between even and odd columns (i.e. ACN that changes with row, not just a constant offset per column). |
|
ACN correction using side reference columns, without any baseline/mean removal. |
|
Compute average reference values per amplifier. |
|
|
|
Calculate average of column references Determine the average values for the column references, which is subsequently used to estimate the 1/f noise contribution. |
|
Same output as calc_avg_cols(), but does NOT remove reference pixel means / DC offsets. |
|
Perform optimal smoothing of side ref pix Generates smoothed version of column reference values. |
|
Optimal Smoothing Performs an optimal filtering of the vertical reference pixel to reduce 1/f noise (horizontal stripes). |
|
Correct amplifier offsets Matches all amplifier outputs of the detector to a common level. |
|
Correct amplifier offsets Matches all amplifier outputs of the detector to a common level. |
|
|
|
Optimal smoothing algorithm Smoothing algorithm to perform optimal filtering of the vertical reference pixel to reduce 1/f noise (horizontal stripes), based on the Kosarev & Pantos algorithm. |
- acn_filter(cube, in_place=True, avg_type='pix', perint=False, edge_wrap=False, left_ref=True, right_ref=True, nleft=4, nright=4, mean_func=<function median>, **kwargs)[source]
Row-dependent differences between even and odd columns (i.e. ACN that changes with row, not just a constant offset per column). They are row-series describing how the even or odd reference pixels vary vs row (and frame), after baseline removal.
ACN correction using side reference columns. Separately estimates row-dependent even and odd column offsets, then subtracts them from the full image.
- Parameters:
cube (ndarray) –
- Input data:
(H, W) single frame, or
(N, H, W) stack of frames.
in_place (bool) – If False, the input array will be copied.
avg_type ({'pix', 'frame', 'int'}) –
- Baseline removal mode for reference pixels:
’pix’ : remove per-pixel mean over integration (best for many frames).
’frame’ : remove per-frame global mean of refs.
’int’ : remove a single global mean over the whole ramp.
perint (bool) – Passed to calc_col_smooth: smooth per integration instead of per frame.
edge_wrap (bool) – Passed to calc_col_smooth: mirror edges before smoothing to reduce ringing.
left_ref (bool) – Whether to use left and/or right side reference columns.
right_ref (bool) – Whether to use left and/or right side reference columns.
nleft (int) – Number of left/right reference columns to use.
nright (int) – Number of left/right reference columns to use.
mean_func (callable) – Function to compute averages (e.g., np.median or robust.mean).
- Returns:
out (ndarray) – ACN-corrected array (same shape as input, float32).
- acn_filter_nobaserm(cube, in_place=True, perint=False, edge_wrap=False, left_ref=True, right_ref=True, nleft=4, nright=4, mean_func=<function median>, **kwargs)[source]
ACN correction using side reference columns, without any baseline/mean removal.
This version uses the raw left/right reference pixel values (after top/bottom correction), averaged over reference columns, then smoothed vs. row, and subtracted from even/odd columns.
- Parameters:
cube (ndarray) –
- Input data:
(H, W) single frame, or
(N, H, W) stack of frames.
in_place (bool) – If False, the input array will be copied.
perint (bool) – Passed to calc_col_smooth: smooth per integration instead of per frame.
edge_wrap (bool) – Passed to calc_col_smooth: mirror edges before smoothing to reduce ringing.
left_ref (bool) – Whether to use left and/or right side reference columns.
right_ref (bool) – Whether to use left and/or right side reference columns.
nleft (int) – Number of left/right reference columns to use.
nright (int) – Number of left/right reference columns to use.
mean_func (callable) – Function to combine multiple reference columns (e.g., np.median). NOTE: this function is not used for baseline subtraction here, only for averaging across columns.
- Returns:
out (ndarray) – ACN-corrected array (same shape as input, float32).
- calc_avg_amps(refs_all, data_shape, nchans=4, altcol=False, mean_func=<function mean>, **kwargs)[source]
Compute average reference values per amplifier.
- Parameters:
refs_all (ndarray) – Reference pixels for bottom + top rows, shape (nz, nref, nx).
data_shape (tuple) – Full data shape (nz, ny, nx) of the science cube.
nchans (int) – Number of amplifier channels along the x-axis.
altcol (bool) – If True, compute separate averages for even/odd columns (JWST-style). If False, compute a separate value for each column in each amp.
mean_func (callable) – Function used to calculate averages (e.g., robust.mean, np.nanmedian).
- calc_avg_amps_old(refs_all, data_shape, nchans=4, altcol=True, mean_func=<function mean>, **kwargs)[source]
- calc_avg_cols(refs_left=None, refs_right=None, avg_type='pix', mean_func=<function median>, **kwargs)[source]
Calculate average of column references Determine the average values for the column references, which is subsequently used to estimate the 1/f noise contribution.
- Parameters:
refs_left (ndarray) – Left reference columns.
refs_right (ndarray) – Right reference columns.
avg_type (str) –
Type of ref column averaging to perform to determine ref pixel variation. Allowed values are ‘pixel’, ‘frame’, or ‘int’.
’pixel’ : For each ref pixel, subtract its avg value from all frames.
’frame’ : For each frame, get avg ref pixel values and subtract framewise.
’int’ : Calculate avg of all ref pixels within the ramp and subtract.
mean_func (func) – Function to use to calculate averages of reference columns
- calc_avg_cols_no_baseline(refs_left=None, refs_right=None)[source]
Same output as calc_avg_cols(), but does NOT remove reference pixel means / DC offsets.
Useful for comparison — this version allows reference pixel fixed-pattern biases to leak directly into the correction vector.
- Parameters:
refs_left (ndarray or None) – Left reference strip, shape (N, H, nleft)
refs_right (ndarray or None) – Right reference strip, shape (N, H, nright)
- Returns:
refs_side_avg (ndarray (N, H)) – Row-averaged reference drift without mean removal.
- calc_col_smooth(refvals, data_shape, perint=False, edge_wrap=False, delt=0.000524, savgol=False, winsize=31, order=3, **kwargs)[source]
Perform optimal smoothing of side ref pix Generates smoothed version of column reference values. Smooths values from calc_avg_cols() via FFT.
- Parameters:
refvals (ndarray) – Averaged column reference pixels
data_shape (tuple) – Shape of original data (nz,ny,nx)
perint (bool) – Smooth side reference pixel per int, otherwise per frame.
edge_wrap (bool) – Add a partial frames to the beginning and end of each averaged time series pixels in order to get rid of edge effects.
delt (float) – Time between reference pixel samples.
savgol (bool) – Using Savitsky-Golay filter method rather than FFT.
winsize (int) – Size of the window filter.
order (int) – Order of the polynomial used to fit the samples.
- ref_filter(cube, nchans=4, in_place=True, avg_type='pix', perint=False, edge_wrap=False, left_ref=True, right_ref=True, nleft=4, nright=4, **kwargs)[source]
Optimal Smoothing Performs an optimal filtering of the vertical reference pixel to reduce 1/f noise (horizontal stripes). FFT method adapted from M. Robberto IDL code: http://www.stsci.edu/~robberto/Main/Software/IDL4pipeline/
- Parameters:
cube (ndarray) – Input datacube. Can be two or three dimensions (nz,ny,nx).
nchans (int) – Number of output amplifier channels in the detector. Default=4.
in_place (bool) – Perform calculations in place. Input array is overwritten.
perint (bool) – Smooth side reference pixel per integration, otherwise do frame-by-frame.
avg_type (str) – Type of ref col averaging to perform. Allowed values are ‘pix’, ‘frame’, or ‘int’.
left_ref (bool) – Include left reference cols when correcting 1/f noise.
right_ref (bool) – Include right reference cols when correcting 1/f noise.
nleft (int) – Specify the number of left reference columns.
nright (int) – Specify the number of right reference columns.
savgol (bool) – Using Savitsky-Golay filter method rather than FFT.
winsize (int) – Size of the window filter.
order (int) – Order of the polynomial used to fit the samples.
mean_func (func) – Function to use to calculate averages of reference columns.
- reffix_amps(cube, nchans=4, in_place=True, altcol=False, supermean=False, top_ref=True, bot_ref=True, ntop=4, nbot=4, **kwargs)[source]
Correct amplifier offsets Matches all amplifier outputs of the detector to a common level. This routine subtracts the average of the top and bottom reference rows for each amplifier and frame individually.
- Parameters:
cube (ndarray) – Input datacube. Can be two or three dimensions (nz,ny,nx).
nchans (int) – Number of output amplifier channels in the detector. Default=4.
altcol (bool) – Calculate separate reference values for even/odd columns.
supermean (bool) – Add back the overall mean of the reference pixels.
in_place (bool) – Perform calculations in place. Input array is overwritten.
top_ref (bool) – Include top reference rows when correcting channel offsets.
bot_ref (bool) – Include bottom reference rows when correcting channel offsets.
ntop (int) – Specify the number of top reference rows.
nbot (int) – Specify the number of bottom reference rows.
mean_func (func) – Function used to calculate averages.
- reffix_amps_old(cube, nchans=4, in_place=True, altcol=True, supermean=False, top_ref=True, bot_ref=True, ntop=4, nbot=4, **kwargs)[source]
Correct amplifier offsets Matches all amplifier outputs of the detector to a common level. This routine subtracts the average of the top and bottom reference rows for each amplifier and frame individually.
- Parameters:
cube (ndarray) – Input datacube. Can be two or three dimensions (nz,ny,nx).
nchans (int) – Number of output amplifier channels in the detector. Default=4.
altcol (bool) – Calculate separate reference values for even/odd columns.
supermean (bool) – Add back the overall mean of the reference pixels.
in_place (bool) – Perform calculations in place. Input array is overwritten.
top_ref (bool) – Include top reference rows when correcting channel offsets.
bot_ref (bool) – Include bottom reference rows when correcting channel offsets.
ntop (int) – Specify the number of top reference rows.
nbot (int) – Specify the number of bottom reference rows.
mean_func (func) – Function used to calculate averages.
- reffix_hxrg(cube, nchans=4, in_place=False, fixcol=True, **kwargs)[source]
- smooth_fft(data, delt, first_deriv=False, second_deriv=False)[source]
Optimal smoothing algorithm Smoothing algorithm to perform optimal filtering of the vertical reference pixel to reduce 1/f noise (horizontal stripes), based on the Kosarev & Pantos algorithm. This assumes that the data to be filtered/smoothed has been sampled evenly. If first_deriv is set, then returns two results if second_deriv is set, then returns three results. Adapted from M. Robberto IDL code: http://www.stsci.edu/~robberto/Main/Software/IDL4pipeline/