Order Mask Algorithm
- class modules.order_trace.src.alg_order_mask.OrderMaskAlg(spectrum_data, order_trace_data, order_trace_header, orderlet_names=None, start_order=0, order_mask_data=None, full_coverage=0, config=None, logger=None, logger_name=None)[source]
This module defines class ‘OrderMaskAlg’ and methods to perform order trace mask. A 2D array of the same size as that of the input spectrum data is returned and the pixels that are covered by the order traces are set to be 1 or a specified value, otherwise the pixels are set to be 0 or a specified value. The coverage is determined by the order trace location, the top and bottom edges and the horizontal range defined in the order trace data plus the origin defined in the order trace header to indicate where the trace position is related to.
- Parameters:
spectrum_data (numpy.ndarray) – 2D spectrum raw data.
order_trace_data (Union[numpy.ndarray, pandas.DataFrame]) – order trace data including polynomial coefficients, top/bottom edges and horizontal coverage of the order trace.
order_trace_header (dict) – dict instance containing order trace info including the origin and polynomial degree to fit the trace.
start_order (int) – the index of the first orderlet of the first order based on the assumption that the first few traces may not be indentified by order trace process and the first trace (indexed as 0) listed in the order_trace_data may not the first orderlet of the first order. A negative number like -n means the first n traces are not included in the order_trace_data.
order_mask_data (numpy.ndarray) – 2D array to contain the order mask data. Defaults to None.
full_coverage (int) – if set order mask to cover full width for each order. Defaults to 0.
config (configparser.ConfigParser, optional) – config context. Defaults to None.
logger (logging.Logger, optional) – Instance of logging.Logger. Defaults to None.
logger_name (str, optional) – Name of the logger defined for the OrderMaskAlg instance.
- spectrum_flux
Numpy array storing 2d spectrum data for spectral extraction. None is allowed.
- Type:
numpy.ndarray
- config_ins
Instance of ConfigHandler related to section for the instrument or ‘PARAM’ section.
- Type:
ConfigHandler
- order_trace
Order trace results from order trace module including polynomial coefficients, top/bottom edges and area coverage of the order trace.
- Type:
numpy.ndarrary
- order_coeffs
Polynomial coefficients for order trace from higher to lower order.
- Type:
numpy.ndarray
- dim_w, dim_h
image dimension, width and height.
- Type:
- order_edges
Bottom and top edges along order trace.
- Type:
numpy.ndarray
- order_xrange
Left and right boundary of order trace.
- Type:
numpy.ndarray
- order_mask_data
order mask per spectrum flux and order trace result.
- Type:
numpy.ndarray
- order_mask_data
2D array to contain the order mask data.
- Type:
numpy.ndarray
- Raises:
- get_config_value(prop, default='')[source]
Get defined value from the config file.
Search the value of the specified property from instrument section. The default value is returned if not found.
- get_order_edges(idx=0)[source]
Get the top and bottom edges of the specified order.
- Parameters:
idx (int, optional) – Index of the order in the order trace array. Defaults to zero.
- Returns:
Bottom and top edges of the order, idx. The first in the array is the bottom edge, and the second in the array is the top edge.
- Return type:
numpy.ndarray
- get_order_mask(order_name, s_width=None, trace_value=1, show_time=False, print_debug=None)[source]
From 2D flux to 2D with order masked.
- Parameters:
order_name (str) – orderlet name
s_width (list) – trace widths to replace those from order trace file.
trace_value (number, optional) – value set for trace pixels. Default to 1.
show_time (bool, optional) – Show running time of the steps. Defaults to False.
print_debug (str, optional) – Print debug information to stdout if it is provided as empty string, a file with path print_debug if it is non empty string, or no print if it is None. Defaults to None.
- Returns:
order mask result, like:
{ 'order_mask_result': np.ndarray }
- Return type:
- get_order_xrange(idx=0)[source]
Get the left and right x boundaries of the specified order.
- Parameters:
idx (int, optional) – Index of the order in the order trace array. Defaults to zero.
- Returns:
Left and right boundaries of order, idx. The first in the array is the left end, and the second in the array is the right end.
- Return type:
numpy.ndarray
- get_orderlet_names()[source]
Get Orderlette names defined in config.
- Returns:
list of orderlet names
- Return type:
- get_total_orderlets_from_image()[source]
Get total orderlets from level 0 image, defined in config
- Returns:
total orderdelettes.
- Return type: