fit_2d_spline_trace
- jwst.adaptive_trace_model.trace_model.fit_2d_spline_trace(flux, alpha, fit_scale=None, lrange=50, col_index=None, space_ratio=1.2, sigma_low=2.5, sigma_high=2.5, fit_iter=3, require_ngood=None, spline_bkpt=None, auto_ngood_factor=0.5, auto_bkpt_factor=2.0)[source]
Create a trace model from spline fits to a single slit/slice image.
Image must be oriented so that wavelengths are along x-axis. Each column is fit separately, with a window to include nearby data.
- Parameters:
- fluxndarray
Input 2D flux image to fit.
- alphandarray
Alpha coordinates for input flux.
- fit_scalendarray, optional
Array of scale values to apply to the input flux before fitting.
- lrangeint, optional
Local column range for data to include in the fit, to the left and right of each input column.
- col_indexiterable or None, optional
Iterable or generator that produces column index values to fit. If provided, columns will be fit in the order specified. If not provided, columns will be fit left to right.
- space_ratiofloat, optional
Maximum spacing ratio to allow fitting to continue. If the tenth-largest spacing in the input
xvecis larger than the knot spacing by this ratio, then return None instead of attempting to fit the data.- sigma_lowfloat, optional
Low sigma threshold for iterative spline fit.
- sigma_highfloat, optional
High sigma threshold for iterative spline fit.
- fit_iterint, optional
Maximum number of iterations for spline fit.
- require_ngoodint or None, optional
Minimum number of data points required to attempt a fit in a column.
- spline_bkptint or None, optional
Number of spline breakpoints (knots).
- auto_ngood_factorfloat, optional
If
require_ngoodis not provided, set it to this factor times the native spacing range in the input slit/slice.- auto_bkpt_factorfloat, optional
If
spline_bkptis not provided, set it to this factor times the native spacing range in the input slit/slice.
- Returns:
- splinesdict
Keys are column index numbers, values are dicts. Each dict contains a normalized
modelwithBSplinevalue, ascalewith a float value to scale to the data, andboundswith a 2-tuple of floating point values, corresponding to the lower and upper bounds of the alpha coordinates used in the fit. If a spline model could not be fit, the column index number is not present.