Spectral Extraction Algorithm
- class modules.spectral_extraction.src.alg.SpectralExtractionAlg(target_2D, master_flat_2D, order_trace_green, order_trace_red, start_order_green, start_order_red, default_config_path, bad_pixel_mask_green=None, bad_pixel_mask_red=None, background_image_green=None, background_image_red=None, logger=None)[source]
- Parameters:
target_2D (KPF0) – A KPF 2D science object
master_flat_2D (KPF0) – A KPF 2D master flat
order_trace_green (str) – path to csv with order trace for GREEN ccd
order_trace_red (str) – path to csv with order trace for RED ccd
start_order (tuple) – index to start order trace, see caldates/start_order.csv [DEPRECATED]
config (configparser.ConfigParser) – Config context
logger (logging.Logger) – Instance of logging.Logger
- box_extraction(D, S, V, Q=1.0, M=None, W=None)[source]
Box extraction on a data array D (typical use case is a single orderlet) Variable names follow Horne 1986
- Args
D: data array S: sky/scattered/stray light background array V: variance array Q: quantum scaling (electrons/photons/ADU) M: mask (1 = good pixel, 0=bad) W: weights, typically to define order trace, assumed to be normalized
- extract_ccd(chip, fibers=None, method=None, max_iter=None, profile_filter_size=None, profile_num_knots=None, profile_sigma_clip=None, extraction_sigma_clip=None)[source]
Extract 1D spectrum and variance for all orders/orderlets on GREEN or RED ccd
- extract_orderlet(chip, order, fiber, method='auto', max_iter=None, profile_filter_size=None, profile_num_knots=None, profile_sigma_clip=None, extraction_sigma_clip=None)[source]
Extract 1D spectrum for a single orderlet
- Parameters:
- Returns:
extracted 1D spectrum v (ndarray): extracted 1D variance P (ndarray): 2D spatial profile (if ‘optimal’ extraction is used) M (ndarray): 2D boolean bad pixel mask (if ‘optimal’ extraction is used)
- Return type:
f (ndarray)
- optimal_extraction(D, S, V, Q=1.0, M=None, W=None, P=None, max_iter=None, profile_filter_size=None, profile_num_knots=None, profile_sigma_clip=None, extraction_sigma_clip=None, verbose=False, do_plot=False)[source]
Optimal extraction on a data array D (typical use case is a single orderlet) Variable names follow Horne 1986
May optionally supply a pre-computed spatial profile P Pre-computing the spatial profile from a master flat is advised
- Args
D: data array S: sky/scattered/stray light background array V: variance array Q: quantum scaling (electrons/photons/ADU) M: mask (1 = good pixel, 0=bad) W: weights, typically to define order trace P: pre-computed spatial profile max_iter (int): maximum number of iterations of algorithm profile_filter_size (int): filter size for median filter, used to identify outliers in spatial profile profile_num_knots (int): number of knots in smoothing spline for profile modeling profile_sigma_clip (float): sigma clipping used to identify outliers during profile modeling extraction_sigma_clip (float): sigma clipping used to identify cosmic rays and pixel defects
- spatial_profile(D, S, W, f, filter_size=None, num_knots=None, sigma_clip=None, do_plot=False)[source]
Estimate the spatial profile of a 2D data array (typical use is for a single orderlet) Applies a spline along detector rows, interpolating over outlier pixels
- Parameters:
D (np.ndarray) – 2D data array, bias corrected and flat fielded
S (np.ndarray) – 2D sky/scattered/stray light background
W (np.ndarray) – 2D weight array to handle order curvature/tilt
f (np.ndarray) – 1D spectrum
filter_size (int) – filter size for median filter, used to identify outliers
num_knots (int) – number of knots for spline
sigma_clip (float) – sigma clipping threshold, used to identify outliers