Ca H&K Algorithm
- class modules.ca_hk.src.alg.CaHKAlg(data, fibers, output_exts=None, output_wl_exts=None, config=None, logger=None)[source]
Ca H&K spectrum extraction.
This module defines class ‘HKExtractionAlg’ and methods to extract spectrum from H&K science data.
- Parameters:
data (numpy.ndarray) – Ca H&K 2D image data.
fibers (list) – List containing the interested fibers to be extracted.
output_exts (list) – List with the name of the extension to contain extraction data
output_wl_exts (list) – List with the name of the extension to contain wavelength data
config (configparser.ConfigParser) – config context.
logger (logging.Logger) – Instance of logging.Logger from external application.
- hk_data
Numpy array storing 2d image data.
- Type:
numpy.ndarray
- order_buffer
Buffer to contain flux computation.
- Type:
numpy.ndarray
- Raises:
AttributeError – The
Raisessection is a list of all exceptions that are relevant to the interface.TypeError – If there is type error for data or config.
Exception – If the size of data is less than 20 pixels by 20 pixels.
- extract_spectrum(fiber_name, order_set=None, show_time=False, print_debug=None)[source]
Spectrum extraction from 2D flux to 1D by doing summation on extracted data.
- Parameters:
fiber_name (str, optional) – Name of the fiber to be processed.
order_set (numpy.ndarray, optional) – Set of selected orders to extract. Defaults to None for all orders.
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:
spectral extraction result from 2D spectrum data, like:
{ 'spectral_extraction_result': Padas.DataFrame }
- Return type:
- get_config_value(param: str, default)[source]
Get defined value from the config file.
Search the value of the specified property from config section. The default value is returned if no found.
- Parameters:
param (str) – Name of the parameter to be searched.
default (str/int/float) – Default value for the searched parameter.
- Returns:
Value for the searched parameter.
- Return type:
int/float/str
- get_data_range()[source]
Get image size range
- Returns:
image range in order of y1, y2, x1 and x2.
- Return type:
numpy.ndarray
- get_order_buffer()[source]
Get a pre-allocated buffer with all zeros to contain sum of spectrum extraction
- Returns:
1 x <spectrum width> array with all zeros
- Return type:
numpy.ndarray
- get_spectral_data()[source]
Get spectral information including data and dimension.
- Returns:
Information of spectral data,
(numpy.ndarray): 2D spectral data.
nx (int): Width of the data.
ny (int): Height of the data.
- Return type:
- get_trace_location(fiber=None)[source]
Get the trace location on specified fibers
- Parameters:
fiber (str) – Fiber name. Defaults to None for all fibers
- Returns:
fiber location on one fiber or all fibers, like:
{ <fiber name 1>: {<order_1>: {'x1': , 'x2', 'y1': 'y2' }, <order_2>: {'x1': , 'x2', 'y1': 'y2' }, ...}, <fiber name n>: {<order_1>: {'x1': , 'x2', 'y1': 'y2' }, ...} }
- Return type:
- img_scaling()[source]
Scale the hk data based on the defined gain that converts the image from the count to electron charge
- img_subtraction(dark_img, bias_img)[source]
Hk image processing by subtracting the dark image and the bias image if existing.
- Parameters:
dark_img (numpy.array) – dark image
bias_img (numpy.array) – biase image
- Returns:
False in case the image size doesn’t match, or True.
- Return type:
- load_trace_location(trace_path)[source]
Load the file containing trace definition and record the trace information per order and per fiber
- Parameters:
trace_path – the path to a file with order trace information. The file is assumed in csv format containing the header and the space as the delimiter for each row.
- Returns:
each item in dict object has the trace value for each fiber, like:
{ <fiber name>: <fiber_trace> # where <fiber trace> is a dict containing location for each order, {<order_number_1>: {'x1': , 'y1':, 'x2': , 'y2': }, <order_number_2>: {'x1': , 'y1':, 'x2': , 'y2': }, ....., <order_number_n>: {'x1': , 'y1':, 'x2': , 'y2': }} }
- Return type:
- load_wavelength_table(wave_table_file: str, fiber: str)[source]
load the csv file with wavelength solution table. The table size is also checked.
- summation_extraction(trace_location, selected_orders=None)[source]
Extract spectrum for selected orders and perform summation on the extracted data
- summation_extraction_one_order(order_loc)[source]
Spectrum extraction and summation on extracted pixels per order location
- static write_data_to_dataframe(out_data, fiber_name, extraction_dim)[source]
Write Ca H&K extraction result to an instance of Pandas DataFrame.
- Parameters:
- Returns:
Instance of DataFrame containing the extraction result plus the following attributes:
FIBER: fiber name.
Ordern: Dimension data for order n.
- Return type:
Pandas.DataFrame