oversample_flux
- jwst.adaptive_trace_model.trace_model.oversample_flux(flux, alpha, region_map, spline_models, spline_scales, oversample_factor, alpha_os, require_ngood=10, slope_limit=0.1, psf_optimal=False, trim_ends=False, pad=3)[source]
Oversample a flux image from spline models fit to the data.
For each column in each slice or slit in the region map:
Check if there are enough valid data points to proceed.
Compute oversampled coordinates corresponding to the input column.
Linearly interpolate flux values onto the oversampled column.
If a spline fit is available, evaluate it for the original column coordinates.
Construct a residual between the spline fit and the original column. data, then linearly interpolate the residual onto the oversampled column.
Compute the slope of each column pixel as the difference between the normalized spline model at that pixel and its immediate neighbor.
Evaluate the spline model at the oversampled coordinates.
The oversampled flux for each slice or slit is set from the spline flux plus the interpolated residual, for pixels where the slope exceeds the
slope_limit. Otherwise, the flux is set to the linearly interpolated value.- Parameters:
- fluxndarray
The flux image to fit.
- alphandarray
Alpha coordinates for all flux values.
- region_mapndarray of int
Map containing the slice or slit number for valid regions. Values are >0 for pixels in valid regions, 0 otherwise.
- spline_modelsdict
Keys are region numbers, values are dicts containing a spline model for each column index in the region. If a spline model could not be fit, the column index number is not present.
- spline_scalesdict
Keys are region numbers, values are dicts containing a floating point scale for each spline model, by column index number. If a spline model could not be fit, the column index number is not present.
- oversample_factorfloat
Scaling factor to oversample by.
- alpha_osndarray
Alpha coordinates for the oversampled array, used to evaluate spline models at every pixel.
- require_ngoodint, optional
Minimum number of pixels required in a column to perform an interpolation.
- slope_limitfloat, optional
The slope limit in the normalized model fits above which the spline model is considered appropriate. Lower values will use spline fits for fainter sources. If less than or equal to zero, the spline fits will always be used.
- psf_optimalbool, optional
If True, residual corrections to the spline model are not included in the oversampled flux.
- trim_endsbool, optional
If True, the edges of the evaluated spline fit will be set to NaN.
- padint, optional
The number of pixels near peak data to include the spline fit for in the output array.
- Returns:
- flux_osndarray
The oversampled flux array, containing contributions from the evaluated spline models, linear interpolations, and residual corrections.
- trace_usedndarray
A trace model, generated from the spline models evaluated at pixels containing a compact source.
- full_tracendarray
A trace model, generated from the spline models evaluated at every pixel.
- linear_fluxndarray
The flux linearly interpolated onto the oversampled grid.
- residual_fluxndarray
Residuals between the spline modeled data and the original flux, linearly interpolated onto the oversampled grid.