|
High-Level Data Reduction Library 1.6.0
High-Level data reduction routines for ESO pipelines
|
This module defines the hdrl_spectrum1D data structure, provides basic functionalities for it (constructors, destructor, operators). More...
Data Structures | |
| struct | hdrl_spectrum1D_shift_parameter |
Typedefs | |
| typedef cpl_error_code(* | operate_image_mutable) (hdrl_image *self, const hdrl_image *other) |
| typedef cpl_error_code(* | operate_image_scalar_mutable) (hdrl_image *self, hdrl_value scalar) |
Functions | |
| hdrl_error_t | estimate_noise_window (const hdrl_data_t *flux, const cpl_binary *msk, cpl_size start, cpl_size stop, const cpl_size sz) |
| Estimate the noise in the pixels between [start, stop]. The noise calculation is done using the formula from: Stoehr, F. et al. DER SNR: A Simple & General Spectroscopic Signal-to-Noise Measurement Algorithm. | |
| cpl_image * | estimate_noise_DER_SNR (const hdrl_data_t *flux_in, const cpl_binary *msk_in, const cpl_array *wavelengths, const cpl_size length, const cpl_size half_window) |
| For every pixel in position i in img_arg, the function estimates the noise using the pixels in the window [i - half_window, i + half_window]. For details on the calculation inside the window, see estimate_noise_window() | |
| hdrl_spectrum1D * | hdrl_spectrum1D_create (const cpl_image *arg_flux, const cpl_image *arg_flux_e, const cpl_array *wavelength, hdrl_spectrum1D_wave_scale wave_scale) |
| hdrl_spectrum1D default constructor | |
| hdrl_spectrum1D * | hdrl_spectrum1D_create_analytic (calculate_analytic_spectrum_point func, const cpl_array *wavelength, hdrl_spectrum1D_wave_scale scale) |
| hdrl_spectrum1D constructor in the case of a spectrum defined by an analytical function | |
| hdrl_spectrum1D * | hdrl_spectrum1D_create_error_free (const cpl_image *arg_flux, const cpl_array *wavelength, hdrl_spectrum1D_wave_scale scale) |
| hdrl_spectrum1D constructor in the case of error-free spectrum (i.e. the error on the flux is zero for every wavelengths). | |
| hdrl_spectrum1D * | hdrl_spectrum1D_create_error_DER_SNR (const cpl_image *arg_flux, cpl_size half_window, const cpl_array *wavelength, hdrl_spectrum1D_wave_scale scale) |
| hdrl_spectrum1D constructor when no error information is available, in this case we use DER_SNR to esimate the error. Please refer to the documentation of the function estimate_noise_DER_SNR(). | |
| hdrl_spectrum1D * | hdrl_spectrum1D_duplicate (const hdrl_spectrum1D *self) |
| hdrl_spectrum1D copy constructor | |
| void | hdrl_spectrum1D_delete (hdrl_spectrum1D **p_self) |
| hdrl_spectrum1D destructor | |
| cpl_size | hdrl_spectrum1D_get_size (const hdrl_spectrum1D *self) |
| hdrl_spectrum1D getter for size | |
| const hdrl_image * | hdrl_spectrum1D_get_flux (const hdrl_spectrum1D *self) |
| hdrl_spectrum1D getter flux | |
| hdrl_spectrum1D_wavelength | hdrl_spectrum1D_get_wavelength (const hdrl_spectrum1D *self) |
| hdrl_spectrum1D getter for wavelengths | |
| hdrl_spectrum1D_wave_scale | hdrl_spectrum1D_get_scale (const hdrl_spectrum1D *self) |
| hdrl_spectrum1D getter for scale | |
| hdrl_value | hdrl_spectrum1D_get_flux_value (const hdrl_spectrum1D *self, int idx, int *rej) |
| hdrl_spectrum1D getter for a flux value | |
| hdrl_data_t | hdrl_spectrum1D_get_wavelength_value (const hdrl_spectrum1D *self, int idx, int *rej) |
| hdrl_spectrum1D getter for a wavelength value | |
| hdrl_spectrum1D * | hdrl_spectrum1D_div_spectrum_create (const hdrl_spectrum1D *num, const hdrl_spectrum1D *den) |
| divide one spectrum by another spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_mul_spectrum_create (const hdrl_spectrum1D *f1, const hdrl_spectrum1D *f2) |
| multiply one spectrum by another spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_add_spectrum_create (const hdrl_spectrum1D *f1, const hdrl_spectrum1D *f2) |
| sum one spectrum to another spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_sub_spectrum_create (const hdrl_spectrum1D *f1, const hdrl_spectrum1D *f2) |
| subtract two spectra | |
| cpl_error_code | hdrl_spectrum1D_div_spectrum (hdrl_spectrum1D *self, const hdrl_spectrum1D *other) |
| divide one spectrum by another spectrum | |
| cpl_error_code | hdrl_spectrum1D_mul_spectrum (hdrl_spectrum1D *self, const hdrl_spectrum1D *other) |
| multiply one spectrum by another spectrum | |
| cpl_error_code | hdrl_spectrum1D_add_spectrum (hdrl_spectrum1D *self, const hdrl_spectrum1D *other) |
| sum two spectra | |
| cpl_error_code | hdrl_spectrum1D_sub_spectrum (hdrl_spectrum1D *self, const hdrl_spectrum1D *other) |
| subtract two spectra | |
| hdrl_spectrum1D * | hdrl_spectrum1D_div_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| divide a spectrum by a scalar | |
| hdrl_spectrum1D * | hdrl_spectrum1D_mul_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| multiply a spectrum by a scalar | |
| hdrl_spectrum1D * | hdrl_spectrum1D_add_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| add a scalar to a spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_sub_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| subtract a scalar from a spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_pow_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| subtract a scalar from a spectrum | |
| hdrl_spectrum1D * | hdrl_spectrum1D_exp_scalar_create (const hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| subtract a scalar from a spectrum | |
| cpl_error_code | hdrl_spectrum1D_div_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise division of a spectrum by a scalar, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_mul_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise multiplication of a spectrum by a scalar, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_add_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise addition of a spectrum by a scalar, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_sub_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise subtraction of a spectrum by a scalar, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_pow_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise power of the flux to the scalar, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_exp_scalar (hdrl_spectrum1D *self, hdrl_value scalar_operator) |
| computes the elementwise power of the scalar to the flux, the self parameter is modified | |
| cpl_error_code | hdrl_spectrum1D_wavelength_mult_scalar_linear (hdrl_spectrum1D *self, hdrl_data_t scale_linear) |
| computes the elementwise multiplication of the scalar for the wavelength. The scalar is assumed to be expressed in linear units. the self parameter is modified | |
| hdrl_spectrum1D * | hdrl_spectrum1D_wavelength_mult_scalar_linear_create (const hdrl_spectrum1D *self, hdrl_data_t scale_linear) |
| computes the elementwise multiplication of the scalar for the wavelength. The scalar is assumed to be expressed in linear units. Self is unchanged and the function returns a newly allocated spectrum. | |
| cpl_error_code | hdrl_spectrum1D_wavelength_shift (hdrl_spectrum1D *self, hdrl_data_t shift) |
| computes the elementwise shift of the wavelength by the shift parameter. The self parameter is modified | |
| hdrl_spectrum1D * | hdrl_spectrum1D_wavelength_shift_create (const hdrl_spectrum1D *self, hdrl_data_t shift) |
| computes the elementwise shift of the wavelength by the shift parameter. | |
| cpl_error_code | hdrl_spectrum1D_wavelength_convert_to_linear (hdrl_spectrum1D *self) |
| converts the wavelength scale to linear. | |
| hdrl_spectrum1D * | hdrl_spectrum1D_wavelength_convert_to_linear_create (const hdrl_spectrum1D *self) |
| converts the wavelength scale to linear. | |
| cpl_error_code | hdrl_spectrum1D_wavelength_convert_to_log (hdrl_spectrum1D *self) |
| converts the wavelength scale to log. If the spectrum is already in log scale nothing is done. | |
| hdrl_spectrum1D * | hdrl_spectrum1D_wavelength_convert_to_log_create (const hdrl_spectrum1D *self) |
| converts the wavelength scale to log. It returns a modified version of self. self is not modified. If self is already in log, the function is equivalent to a duplication. | |
| hdrl_spectrum1D * | hdrl_spectrum1D_select_wavelengths (const hdrl_spectrum1D *self, const cpl_bivector *windows, const cpl_boolean is_internal) |
| the function selects or discards flux values according to whether the value of the corresponding wavelength belongs to the interval [min_lambda, max_lambda]. | |
| hdrl_spectrum1D * | hdrl_spectrum1D_reject_pixels (const hdrl_spectrum1D *self, const cpl_array *bad_samples) |
| For every i-th element in bad_samples having value CPL_TRUE, the i-th pixel in the 1D spectrum is marked as bad. | |
| cpl_table * | hdrl_spectrum1D_convert_to_table (const hdrl_spectrum1D *self, const char *flux_col_name, const char *wavelength_col_name, const char *flux_e_col_name, const char *flux_bpm_col_name) |
| converts a spectrum in a table. | |
| cpl_error_code | hdrl_spectrum1D_append_to_table (const hdrl_spectrum1D *self, cpl_table *dest, const char *flux_col_name, const char *wavelength_col_name, const char *flux_e_col_name, const char *flux_bpm_col_name) |
| append a spectrum to a table. | |
| hdrl_spectrum1D * | hdrl_spectrum1D_convert_from_table (const cpl_table *self, const char *flux_col_name, const char *wavelength_col_name, const char *flux_e_col_name, const char *flux_bpm_col_name, hdrl_spectrum1D_wave_scale scale) |
| convert a table to a spectrum | |
| void | hdrl_spectrum1D_save (const hdrl_spectrum1D *s, const char *fname) |
| cpl_boolean | hdrl_spectrum1D_are_wavelengths_compatible (const cpl_array *w1, const cpl_array *w2) |
| checks if two wavelengths array are defined on the same wavelengths. | |
| cpl_boolean | hdrl_spectrum1D_are_spectra_compatible (const hdrl_spectrum1D_wavelength *s1, const hdrl_spectrum1D_wavelength *s2) |
| checks if two spectrum wavelengths are equal. | |
| cpl_boolean | hdrl_spectrum1D_is_uniformly_sampled (const hdrl_spectrum1D *self, double *bin) |
| checks if the spectrum is defined on uniformly sampled wavelengths. | |
| hdrl_parameter * | hdrl_spectrum1D_resample_interpolate_parameter_create (const hdrl_spectrum1D_interpolation_method method) |
| constructor for the hdrl_parameter in the case of interpolation | |
| hdrl_parameter * | hdrl_spectrum1D_resample_integrate_parameter_create (void) |
| constructor for the hdrl_parameter in the case of integration | |
| hdrl_parameter * | hdrl_spectrum1D_resample_interpolate_parameter_parse_parlist (const cpl_parameterlist *parlist, const char *prefix) |
| cpl_parameterlist * | hdrl_spectrum1D_resample_interpolate_parameter_create_parlist (const char *base_context, const char *prefix, const char *method_def) |
| hdrl_parameter * | hdrl_spectrum1D_resample_fit_parameter_create (const int k, const int nCoeff) |
| constructor for the hdrl_parameter in the case of interpolation | |
| hdrl_parameter * | hdrl_spectrum1D_resample_fit_windowed_parameter_create (const int k, const int nCoeff, const long window, const double factor) |
| constructor for the hdrl_parameter in the case of interpolation | |
| cpl_error_code | hdrl_resample_parameter_verify (const hdrl_parameter *par) |
| hdrl_spectrum1D * | hdrl_spectrum1D_resample (const hdrl_spectrum1D *self, const hdrl_spectrum1D_wavelength *waves, const hdrl_parameter *par) |
| resample a hdrl_spectrum1D on the wavelengths contained in waves | |
| hdrl_spectrum1D * | hdrl_spectrum1D_resample_on_array (const hdrl_spectrum1D *self, const cpl_array *waves, const hdrl_parameter *par) |
| resample a hdrl_spectrum1D on the wavelengths contained in waves | |
| cpl_size | hdrl_spectrum1D_resample_filter_dups_and_substitute_with_median (double *x, double *y1, double *y2, cpl_size sample_len) |
| hdrl_xcorrelation_result * | hdrl_spectrum1D_compute_shift_xcorrelation (const hdrl_spectrum1D *s1, const hdrl_spectrum1D *s2, cpl_size half_win, const cpl_boolean normalize) |
| The function computes the shift between the two spectra. | |
| hdrl_parameter * | hdrl_spectrum1D_shift_fit_parameter_create (const hdrl_data_t wguess, const hdrl_data_t range_wmin, const hdrl_data_t range_wmax, const hdrl_data_t fit_wmin, const hdrl_data_t fit_wmax, const hdrl_data_t fit_half_win) |
| The function create a hdrl_spectrum1D_shift_parameter to be used in hdrl_spectrum1D_compute_shift_fit. | |
| hdrl_data_t | hdrl_spectrum1D_compute_shift_fit (const hdrl_spectrum1D *obs, const hdrl_parameter *par) |
| The function compute the shift due to radial velocity. If wguess is the reference line and wfound is its position in the obs spectrum, the function returns (wfound - wguess) / wguess. The algorithm generate a smoothed fit of the spectrum, between [range_wmin, range_wmax] but the wavelengths between [fit_wim, fit_wmax] are ignored when fitting. obs is then divided by the fitted spectrum. The ratio is then smoothed again via fitting inside the window [wguess - fit_half_win, wguess + fit_half_win]. The wavelength corresponding to the minimum value is wfound. | |
| cpl_size | convert_to_matrix_and_vector (cpl_matrix **x, cpl_vector **values, const hdrl_spectrum1D *s) |
| hdrl_spectrum1Dlist * | hdrl_spectrum1Dlist_new (void) |
| hdrl_spectrum1Dlist default constructor | |
| hdrl_spectrum1Dlist * | hdrl_spectrum1Dlist_duplicate (const hdrl_spectrum1Dlist *l) |
| hdrl_spectrum1Dlist copy-constructor | |
| hdrl_spectrum1Dlist * | hdrl_spectrum1Dlist_wrap (hdrl_spectrum1D **self, const cpl_size sz) |
| hdrl_spectrum1Dlist wrapper | |
| hdrl_spectrum1D * | hdrl_spectrum1Dlist_get (hdrl_spectrum1Dlist *self, const cpl_size idx) |
| hdrl_spectrum1Dlist getter of the i-th element | |
| const hdrl_spectrum1D * | hdrl_spectrum1Dlist_get_const (const hdrl_spectrum1Dlist *self, const cpl_size idx) |
| hdrl_spectrum1Dlist getter of the i-th element | |
| cpl_error_code | hdrl_spectrum1Dlist_set (hdrl_spectrum1Dlist *self, hdrl_spectrum1D *s, const cpl_size idx) |
| hdrl_spectrum1Dlist setter of the i-th element | |
| hdrl_spectrum1D * | hdrl_spectrum1Dlist_unset (hdrl_spectrum1Dlist *self, const cpl_size idx) |
| hdrl_spectrum1Dlist remove of the i-th element | |
| void | hdrl_spectrum1Dlist_delete (hdrl_spectrum1Dlist *l) |
| hdrl_spectrum1Dlist destructor | |
| cpl_size | hdrl_spectrum1Dlist_get_size (const hdrl_spectrum1Dlist *l) |
| hdrl_spectrum1Dlist getter for size | |
| cpl_error_code | hdrl_spectrum1Dlist_collapse (const hdrl_spectrum1Dlist *list, const hdrl_parameter *stacking_par, const cpl_array *wlengths, const hdrl_parameter *resample_par, const cpl_boolean mark_bpm_in_interpolation, hdrl_spectrum1D **result, cpl_image **contrib, hdrl_imagelist **resampled_and_aligned_fluxes) |
| collapsing a hdrl_spectrum1Dlist. The spectra in list are first resampled on the wavelengths wlengths. The resampling method is regulated by the resample_par. For more information on samplig_par see hdrl_spectrum1D_resample_on_array. The resampled fluxes are collapsed as in hdrl_imagelist_collapse and the collapsing is regulated by the parameter stacking_par. For more information on stacking_par please see the documentation of hdrl_imagelist_collapse. | |
Variables | |
| const double | wave_delta = 1.e-6 |
This module defines the hdrl_spectrum1D data structure, provides basic functionalities for it (constructors, destructor, operators).
constructors
errors
error conditions
calculation
functions
interpolation
for interpolation
fitting. We first resample .2 forward and then resample .2 backward. We expect that the flux of this 2nd spectrum has very similar errors to the original one.
| typedef cpl_error_code(* operate_image_mutable) (hdrl_image *self, const hdrl_image *other) |
| typedef cpl_error_code(* operate_image_scalar_mutable) (hdrl_image *self, hdrl_value scalar) |
| cpl_size convert_to_matrix_and_vector | ( | cpl_matrix ** | x, |
| cpl_vector ** | values, | ||
| const hdrl_spectrum1D * | s | ||
| ) |
| cpl_image * estimate_noise_DER_SNR | ( | const hdrl_data_t * | flux_in, |
| const cpl_binary * | msk_in, | ||
| const cpl_array * | wavelengths, | ||
| const cpl_size | length, | ||
| const cpl_size | half_window | ||
| ) |
For every pixel in position i in img_arg, the function estimates the noise using the pixels in the window [i - half_window, i + half_window]. For details on the calculation inside the window, see estimate_noise_window()
| flux_in | input flux |
| msk_in | bad pixels mask |
| wavelengths | wavelengths of the spectrum |
| length | length of the flux and msl |
| half_window | half window used to calculate the noise for each pixel. |
Possible cpl-error-code set in this function (which also implies that NULL is returned):
| hdrl_error_t estimate_noise_window | ( | const hdrl_data_t * | flux, |
| const cpl_binary * | msk, | ||
| cpl_size | start, | ||
| cpl_size | stop, | ||
| const cpl_size | sz | ||
| ) |
Estimate the noise in the pixels between [start, stop]. The noise calculation is done using the formula from: Stoehr, F. et al. DER SNR: A Simple & General Spectroscopic Signal-to-Noise Measurement Algorithm.
| flux | Input Flux |
| msk | Bad Pixel Mask |
| start | First Pixel |
| stop | Last Pixel |
| sz | Length of the flux (must be the same for msk) |
Possible cpl-error-code set in this function (which also implies that NAN is returned):
| cpl_error_code hdrl_resample_parameter_verify | ( | const hdrl_parameter * | par | ) |
| cpl_error_code hdrl_spectrum1D_add_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise addition of a spectrum by a scalar, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_add_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
add a scalar to a spectrum
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_add_scalar
| cpl_error_code hdrl_spectrum1D_add_spectrum | ( | hdrl_spectrum1D * | self, |
| const hdrl_spectrum1D * | other | ||
| ) |
sum two spectra
| self | first factor, it is mutated to contain self+other |
| other | second factor |
| hdrl_spectrum1D * hdrl_spectrum1D_add_spectrum_create | ( | const hdrl_spectrum1D * | f1, |
| const hdrl_spectrum1D * | f2 | ||
| ) |
sum one spectrum to another spectrum
void
| f1 | factor 1 |
| f2 | factor 2 |
Possible cpl-error-code set in this function: hdrl_image_add_image
| cpl_error_code hdrl_spectrum1D_append_to_table | ( | const hdrl_spectrum1D * | self, |
| cpl_table * | dest, | ||
| const char * | flux_col_name, | ||
| const char * | wavelength_col_name, | ||
| const char * | flux_e_col_name, | ||
| const char * | flux_bpm_col_name | ||
| ) |
append a spectrum to a table.
| self | spectrum |
| dest | table |
| flux_col_name | name of the column containing the flux |
| wavelength_col_name | name of the column containing the wavelengths |
| flux_e_col_name | name of the column containing the flux error |
| flux_bpm_col_name | name of the column containing the flux bpm |
If NULL is provided instead of a name, the corresponding column is not inserted in the table. At least one between wavelength_col_name and flux_col_name must be not NULL.
| cpl_boolean hdrl_spectrum1D_are_spectra_compatible | ( | const hdrl_spectrum1D_wavelength * | s1, |
| const hdrl_spectrum1D_wavelength * | s2 | ||
| ) |
checks if two spectrum wavelengths are equal.
| s1 | first spectrum wavelength |
| s2 | second spectrum wavelength |
| cpl_boolean hdrl_spectrum1D_are_wavelengths_compatible | ( | const cpl_array * | w1, |
| const cpl_array * | w2 | ||
| ) |
checks if two wavelengths array are defined on the same wavelengths.
| w1 | first wavelength array |
| w2 | first wavelength array |
| hdrl_data_t hdrl_spectrum1D_compute_shift_fit | ( | const hdrl_spectrum1D * | obs, |
| const hdrl_parameter * | par | ||
| ) |
The function compute the shift due to radial velocity. If wguess is the reference line and wfound is its position in the obs spectrum, the function returns (wfound - wguess) / wguess. The algorithm generate a smoothed fit of the spectrum, between [range_wmin, range_wmax] but the wavelengths between [fit_wim, fit_wmax] are ignored when fitting. obs is then divided by the fitted spectrum. The ratio is then smoothed again via fitting inside the window [wguess - fit_half_win, wguess + fit_half_win]. The wavelength corresponding to the minimum value is wfound.
| obs | The spectrum the shift has to be computed on |
| par | The shift parameter, see hdrl_spectrum1D_shift_fit_parameter_create |
| hdrl_xcorrelation_result * hdrl_spectrum1D_compute_shift_xcorrelation | ( | const hdrl_spectrum1D * | s1, |
| const hdrl_spectrum1D * | s2, | ||
| cpl_size | half_win, | ||
| const cpl_boolean | normalize | ||
| ) |
The function computes the shift between the two spectra.
| s1 | first spectrum |
| s2 | second spectrum |
| half_win | half window where the correlation will be calculated |
| normalize | normalize mean and stdev in cross-correlation calculation |
Possible cpl-error-code set in this function:
| hdrl_spectrum1D * hdrl_spectrum1D_convert_from_table | ( | const cpl_table * | self, |
| const char * | flux_col_name, | ||
| const char * | wavelength_col_name, | ||
| const char * | flux_e_col_name, | ||
| const char * | flux_bpm_col_name, | ||
| hdrl_spectrum1D_wave_scale | scale | ||
| ) |
convert a table to a spectrum
| self | table |
| flux_col_name | name of the column containing the flux |
| wavelength_col_name | name of the column containing the wavelengths |
| flux_e_col_name | name of the column containing the flux error |
| flux_bpm_col_name | name of the column containing the flux bpm |
| scale | scale of the spectrum |
Possible cpl-error-code set in this function: see error free spectrum ctor
| cpl_table * hdrl_spectrum1D_convert_to_table | ( | const hdrl_spectrum1D * | self, |
| const char * | flux_col_name, | ||
| const char * | wavelength_col_name, | ||
| const char * | flux_e_col_name, | ||
| const char * | flux_bpm_col_name | ||
| ) |
converts a spectrum in a table.
| self | spectrum |
| flux_col_name | name of the column containing the flux |
| wavelength_col_name | name of the column containing the wavelengths |
| flux_e_col_name | name of the column containing the flux error |
| flux_bpm_col_name | name of the column containing the flux bpm |
If NULL is provided instead of a name, the corresponding column is not inserted in the table. At least one between wavelength_col_name and flux_col_name must be not NULL.
Possible cpl-error-code set in this function: see cpl_table_wrap_double
| hdrl_spectrum1D * hdrl_spectrum1D_create | ( | const cpl_image * | arg_flux, |
| const cpl_image * | arg_flux_e, | ||
| const cpl_array * | wavelength, | ||
| hdrl_spectrum1D_wave_scale | wave_scale | ||
| ) |
hdrl_spectrum1D default constructor
| arg_flux | flux with bpm |
| arg_flux_e | error for the flux |
| wavelength | wavelengths |
| wave_scale | the scale of the wavelengths of the spectrum (logarithmic or linear) |
The constructor allocates memory of a hdrl_spectrum1D structure. The cpl_image(s) and the cpl_array are copied inside the newly allocated data structure. The bpm of arg_flux becomes the bpm of the spectrum.
Possible cpl-error-code set in this function:
| hdrl_spectrum1D * hdrl_spectrum1D_create_analytic | ( | calculate_analytic_spectrum_point | func, |
| const cpl_array * | wavelength, | ||
| hdrl_spectrum1D_wave_scale | scale | ||
| ) |
hdrl_spectrum1D constructor in the case of a spectrum defined by an analytical function
| func | analytical function defining the spectrum |
| wavelength | frequencies the flux is calculated on |
| scale | the scale of the spectrum (logarithmic or linear) |
The constructor allocates memory of a hdrl_spectrum1D structure. The cpl_array is copied inside the newly allocated data structure. For every wavelength inside the CPL array flux and error are calculated using func.
Possible cpl-error-code set in this function:
| hdrl_spectrum1D * hdrl_spectrum1D_create_error_DER_SNR | ( | const cpl_image * | arg_flux, |
| cpl_size | half_window, | ||
| const cpl_array * | wavelength, | ||
| hdrl_spectrum1D_wave_scale | scale | ||
| ) |
hdrl_spectrum1D constructor when no error information is available, in this case we use DER_SNR to esimate the error. Please refer to the documentation of the function estimate_noise_DER_SNR().
| arg_flux | flux with bpm |
| half_window | half window the DER_SNR is calculated on |
| wavelength | frequencies |
| scale | the scale of the spectrum (logarithmic or linear) |
The constructor allocates memory of a hdrl_spectrum1D structure. The cpl_array and the cpl_image are copied inside the newly allocated data structure. The flux error is calculated creating a window of 2 * half_window + 1 pixels around each flux pixel and then using the noise estimation used for DER_SNR calculation. The use of DER_SNR can increase the number of bad pixels, in the case of a good pixel surrounded by bad pixels. See estimate_noise_DER_SNR() for more details.
Possible cpl-error-code set in this function: see hdrl_spectrum1D_create()
| hdrl_spectrum1D * hdrl_spectrum1D_create_error_free | ( | const cpl_image * | arg_flux, |
| const cpl_array * | wavelength, | ||
| hdrl_spectrum1D_wave_scale | scale | ||
| ) |
hdrl_spectrum1D constructor in the case of error-free spectrum (i.e. the error on the flux is zero for every wavelengths).
| arg_flux | flux with bpm |
| wavelength | frequencies |
| scale | the scale of the spectrum (logarithmic or linear) |
The constructor allocates memory of a hdrl_spectrum1D structure. The cpl_array and the cpl_image are copied inside the newly allocated data structure. The flux error is considered to be zero.
Possible cpl-error-code set in this function: see hdrl_spectrum1D_create()
| void hdrl_spectrum1D_delete | ( | hdrl_spectrum1D ** | p_self | ) |
hdrl_spectrum1D destructor
| p_self | spectrum to delete. |
If p_self is NULL or *p_self is NULL nothing is done.
| cpl_error_code hdrl_spectrum1D_div_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise division of a spectrum by a scalar, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_div_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
divide a spectrum by a scalar
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_div_scalar
| cpl_error_code hdrl_spectrum1D_div_spectrum | ( | hdrl_spectrum1D * | self, |
| const hdrl_spectrum1D * | other | ||
| ) |
divide one spectrum by another spectrum
| self | numerator, it is mutated to contain self/other |
| other | denumerator |
| hdrl_spectrum1D * hdrl_spectrum1D_div_spectrum_create | ( | const hdrl_spectrum1D * | num, |
| const hdrl_spectrum1D * | den | ||
| ) |
divide one spectrum by another spectrum
| num | numerator |
| den | denumerator |
Possible cpl-error-code set in this function: hdrl_image_div_image
| hdrl_spectrum1D * hdrl_spectrum1D_duplicate | ( | const hdrl_spectrum1D * | self | ) |
hdrl_spectrum1D copy constructor
| self | spectrum that has to be duplicated |
| cpl_error_code hdrl_spectrum1D_exp_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise power of the scalar to the flux, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_exp_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
subtract a scalar from a spectrum
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_exp_scalar
| const hdrl_image * hdrl_spectrum1D_get_flux | ( | const hdrl_spectrum1D * | self | ) |
hdrl_spectrum1D getter flux
| self | the spectrum |
| hdrl_value hdrl_spectrum1D_get_flux_value | ( | const hdrl_spectrum1D * | self, |
| int | idx, | ||
| int * | rej | ||
| ) |
hdrl_spectrum1D getter for a flux value
| self | the spectrum |
| idx | position of the sample. The samples are a 0-indexed sequence. |
| rej | output, set to 0 if the value is not a valid pixel. |
| hdrl_spectrum1D_wave_scale hdrl_spectrum1D_get_scale | ( | const hdrl_spectrum1D * | self | ) |
| cpl_size hdrl_spectrum1D_get_size | ( | const hdrl_spectrum1D * | self | ) |
hdrl_spectrum1D getter for size
| self | the spectrum |
| hdrl_spectrum1D_wavelength hdrl_spectrum1D_get_wavelength | ( | const hdrl_spectrum1D * | self | ) |
hdrl_spectrum1D getter for wavelengths
| self | the spectrum |
| hdrl_data_t hdrl_spectrum1D_get_wavelength_value | ( | const hdrl_spectrum1D * | self, |
| int | idx, | ||
| int * | rej | ||
| ) |
hdrl_spectrum1D getter for a wavelength value
| self | the spectrum |
| idx | position of the sample. The samples are a 0-indexed sequence. |
| rej | output, set to 0 if the value is not a valid pixel. |
| cpl_boolean hdrl_spectrum1D_is_uniformly_sampled | ( | const hdrl_spectrum1D * | self, |
| double * | bin | ||
| ) |
checks if the spectrum is defined on uniformly sampled wavelengths.
| self | the input spectrum |
| bin | bin width - output parameter |
| cpl_error_code hdrl_spectrum1D_mul_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise multiplication of a spectrum by a scalar, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_mul_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
multiply a spectrum by a scalar
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_mul_scalar
| cpl_error_code hdrl_spectrum1D_mul_spectrum | ( | hdrl_spectrum1D * | self, |
| const hdrl_spectrum1D * | other | ||
| ) |
multiply one spectrum by another spectrum
| self | first factor, it is mutated to contain self*other |
| other | second factor |
| hdrl_spectrum1D * hdrl_spectrum1D_mul_spectrum_create | ( | const hdrl_spectrum1D * | f1, |
| const hdrl_spectrum1D * | f2 | ||
| ) |
multiply one spectrum by another spectrum
| f1 | factor 1 |
| f2 | factor 2 |
Possible cpl-error-code set in this function: hdrl_image_mul_image
| cpl_error_code hdrl_spectrum1D_pow_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise power of the flux to the scalar, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_pow_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
subtract a scalar from a spectrum
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_pow_scalar
| hdrl_spectrum1D * hdrl_spectrum1D_reject_pixels | ( | const hdrl_spectrum1D * | self, |
| const cpl_array * | bad_samples | ||
| ) |
For every i-th element in bad_samples having value CPL_TRUE, the i-th pixel in the 1D spectrum is marked as bad.
| self | spectrum |
| bad_samples | flags indicating whether the pixel is bad |
It returns a modified version of self. self is not modified. Possible cpl-error-code set in this function:
| hdrl_spectrum1D * hdrl_spectrum1D_resample | ( | const hdrl_spectrum1D * | self, |
| const hdrl_spectrum1D_wavelength * | waves, | ||
| const hdrl_parameter * | par | ||
| ) |
resample a hdrl_spectrum1D on the wavelengths contained in waves
| self | the spectrum to be resampled |
| waves | the waves the spectrum has to be resampled on |
| par | hdrl_parameter, see hdrl_spectrum1D_resample_fit_parameter_create(), hdrl_spectrum1D_resample_interpolate_parameter_create() or hdrl_spectrum1D_resample_integrate_parameter_create(). |
Possible cpl-error-code set in this function:
| cpl_size hdrl_spectrum1D_resample_filter_dups_and_substitute_with_median | ( | double * | x, |
| double * | y1, | ||
| double * | y2, | ||
| cpl_size | sample_len | ||
| ) |
| hdrl_parameter * hdrl_spectrum1D_resample_fit_parameter_create | ( | const int | k, |
| const int | nCoeff | ||
| ) |
constructor for the hdrl_parameter in the case of interpolation
| k | order of the B-spline |
| nCoeff | number of coefficients used for the fit |
| hdrl_parameter * hdrl_spectrum1D_resample_fit_windowed_parameter_create | ( | const int | k, |
| const int | nCoeff, | ||
| const long | window, | ||
| const double | factor | ||
| ) |
constructor for the hdrl_parameter in the case of interpolation
| k | order of the B-spline |
| nCoeff | number of coefficients used for the fit |
| window | number of destination wavelengths whose flux values are computed using the same model |
| factor | Given window2 = window * factor. window2 is the number of source wavelengths used to compute the fit model |
| hdrl_parameter * hdrl_spectrum1D_resample_integrate_parameter_create | ( | void | ) |
constructor for the hdrl_parameter in the case of integration
| hdrl_parameter * hdrl_spectrum1D_resample_interpolate_parameter_create | ( | const hdrl_spectrum1D_interpolation_method | method | ) |
constructor for the hdrl_parameter in the case of interpolation
| method | interpolation methods, see the enum hdrl_spectrum1D_interpolation_method |
| cpl_parameterlist * hdrl_spectrum1D_resample_interpolate_parameter_create_parlist | ( | const char * | base_context, |
| const char * | prefix, | ||
| const char * | method_def | ||
| ) |
| hdrl_parameter * hdrl_spectrum1D_resample_interpolate_parameter_parse_parlist | ( | const cpl_parameterlist * | parlist, |
| const char * | prefix | ||
| ) |
| hdrl_spectrum1D * hdrl_spectrum1D_resample_on_array | ( | const hdrl_spectrum1D * | self, |
| const cpl_array * | waves, | ||
| const hdrl_parameter * | par | ||
| ) |
resample a hdrl_spectrum1D on the wavelengths contained in waves
| self | the spectrum to be resampled |
| waves | the waves the spectrum has to be resampled on |
| par | hdrl_parameter, see hdrl_spectrum1D_resample_fit_parameter_create(), hdrl_spectrum1D_resample_interpolate_parameter_create() or hdrl_spectrum1D_resample_integrate_parameter_create(). |
Possible cpl-error-code set in this function:
| void hdrl_spectrum1D_save | ( | const hdrl_spectrum1D * | s, |
| const char * | fname | ||
| ) |
| hdrl_spectrum1D * hdrl_spectrum1D_select_wavelengths | ( | const hdrl_spectrum1D * | self, |
| const cpl_bivector * | windows, | ||
| const cpl_boolean | is_internal | ||
| ) |
the function selects or discards flux values according to whether the value of the corresponding wavelength belongs to the interval [min_lambda, max_lambda].
| self | spectrum |
| windows | the intervals required for selection |
| is_internal | parallel array to windows, specifies if selection is internal to the interval or external to the interval. |
Possible cpl-error-code set in this function:
| hdrl_parameter * hdrl_spectrum1D_shift_fit_parameter_create | ( | const hdrl_data_t | wguess, |
| const hdrl_data_t | range_wmin, | ||
| const hdrl_data_t | range_wmax, | ||
| const hdrl_data_t | fit_wmin, | ||
| const hdrl_data_t | fit_wmax, | ||
| const hdrl_data_t | fit_half_win | ||
| ) |
The function create a hdrl_spectrum1D_shift_parameter to be used in hdrl_spectrum1D_compute_shift_fit.
| wguess | Reference line wavelength position |
| range_wmin | Minimum of wavelength box for line fit |
| range_wmax | Maximum of wavelength box for line fit |
| fit_wmin | Minimum wavelength value used to fit line slope |
| fit_wmax | Maximum wavelength value used to fit line slope |
| fit_half_win | Half box where polynomial fit is performed |
| cpl_error_code hdrl_spectrum1D_sub_scalar | ( | hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
computes the elementwise subtraction of a spectrum by a scalar, the self parameter is modified
| self | spectrum |
| scalar_operator | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_sub_scalar_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_value | scalar_operator | ||
| ) |
subtract a scalar from a spectrum
| self | spectrum |
| scalar_operator | scalar factor |
Possible cpl-error-code set in this function: hdrl_image_sub_scalar
| cpl_error_code hdrl_spectrum1D_sub_spectrum | ( | hdrl_spectrum1D * | self, |
| const hdrl_spectrum1D * | other | ||
| ) |
subtract two spectra
| self | first factor, it is mutated to contain self-other |
| other | second factor |
| hdrl_spectrum1D * hdrl_spectrum1D_sub_spectrum_create | ( | const hdrl_spectrum1D * | f1, |
| const hdrl_spectrum1D * | f2 | ||
| ) |
subtract two spectra
| f1 | factor 1 |
| f2 | factor 2 |
Possible cpl-error-code set in this function: hdrl_image_sub_image
| cpl_error_code hdrl_spectrum1D_wavelength_convert_to_linear | ( | hdrl_spectrum1D * | self | ) |
converts the wavelength scale to linear.
| self | spectrum |
If the spectrum is already in linear scale nothing is done.
| hdrl_spectrum1D * hdrl_spectrum1D_wavelength_convert_to_linear_create | ( | const hdrl_spectrum1D * | self | ) |
converts the wavelength scale to linear.
| self | spectrum |
It returns a modified version of self. self is not modified. If self is already in linear, the function is equivalent to a duplication. Possible cpl-error-code set in this function: see cpl_array_exponential
| cpl_error_code hdrl_spectrum1D_wavelength_convert_to_log | ( | hdrl_spectrum1D * | self | ) |
converts the wavelength scale to log. If the spectrum is already in log scale nothing is done.
| self | spectrum |
| hdrl_spectrum1D * hdrl_spectrum1D_wavelength_convert_to_log_create | ( | const hdrl_spectrum1D * | self | ) |
converts the wavelength scale to log. It returns a modified version of self. self is not modified. If self is already in log, the function is equivalent to a duplication.
| self | spectrum |
It returns a modified version of self. self is not modified. If self is already in log, the function is equivalent to a duplication. Possible cpl-error-code set in this function: see cpl_array_logarithm
| cpl_error_code hdrl_spectrum1D_wavelength_mult_scalar_linear | ( | hdrl_spectrum1D * | self, |
| hdrl_data_t | scale_linear | ||
| ) |
computes the elementwise multiplication of the scalar for the wavelength. The scalar is assumed to be expressed in linear units. the self parameter is modified
| self | spectrum |
| scale_linear | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_wavelength_mult_scalar_linear_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_data_t | scale_linear | ||
| ) |
computes the elementwise multiplication of the scalar for the wavelength. The scalar is assumed to be expressed in linear units. Self is unchanged and the function returns a newly allocated spectrum.
| self | spectrum |
| scale_linear | scalar factor |
Possible cpl-error-code set in this function: see cpl_array_multiply_scalar and cpl_array_add_scalar.
| cpl_error_code hdrl_spectrum1D_wavelength_shift | ( | hdrl_spectrum1D * | self, |
| hdrl_data_t | shift | ||
| ) |
computes the elementwise shift of the wavelength by the shift parameter. The self parameter is modified
| self | spectrum |
| shift | scalar factor |
| hdrl_spectrum1D * hdrl_spectrum1D_wavelength_shift_create | ( | const hdrl_spectrum1D * | self, |
| hdrl_data_t | shift | ||
| ) |
computes the elementwise shift of the wavelength by the shift parameter.
| self | spectrum |
| shift | scalar factor |
The self parameter is not modified, and a modified copy of self is returned. Possible cpl-error-code set in this function: see cpl_array_add_scalar
| cpl_error_code hdrl_spectrum1Dlist_collapse | ( | const hdrl_spectrum1Dlist * | list, |
| const hdrl_parameter * | stacking_par, | ||
| const cpl_array * | wlengths, | ||
| const hdrl_parameter * | resample_par, | ||
| const cpl_boolean | mark_bpm_in_interpolation, | ||
| hdrl_spectrum1D ** | result, | ||
| cpl_image ** | contrib, | ||
| hdrl_imagelist ** | resampled_and_aligned_fluxes | ||
| ) |
collapsing a hdrl_spectrum1Dlist. The spectra in list are first resampled on the wavelengths wlengths. The resampling method is regulated by the resample_par. For more information on samplig_par see hdrl_spectrum1D_resample_on_array. The resampled fluxes are collapsed as in hdrl_imagelist_collapse and the collapsing is regulated by the parameter stacking_par. For more information on stacking_par please see the documentation of hdrl_imagelist_collapse.
| list | hdrl_spectrum1D list |
| stacking_par | parameter regulating the stacking |
| wlengths | wavelengths the resulting spectrum is defined on |
| resample_par | parameter regulating the resampling |
| mark_bpm_in_interpolation | if true interpolated pixels whose neighbors (in the original spectrum) are rejected, are not considered during collapsing |
| result | the resulting spectrum |
| contrib | output contribution mask |
| resampled_and_aligned_fluxes | resampled and aligned fluxes to be collapsed |
Possible cpl-error-code set in this function:
| void hdrl_spectrum1Dlist_delete | ( | hdrl_spectrum1Dlist * | l | ) |
hdrl_spectrum1Dlist destructor
| l | hdrl_spectrum1Dlist |
The function deallocates the list and all the spectra it was containing. If l is NULL no operation is performed.
| hdrl_spectrum1Dlist * hdrl_spectrum1Dlist_duplicate | ( | const hdrl_spectrum1Dlist * | l | ) |
hdrl_spectrum1Dlist copy-constructor
| l | input list |
The constructor allocates memory of a new hdrl_spectrum1Dlist structure. Each element of the new list is a copy of the corresponding element in the source list.
| hdrl_spectrum1D * hdrl_spectrum1Dlist_get | ( | hdrl_spectrum1Dlist * | self, |
| const cpl_size | idx | ||
| ) |
hdrl_spectrum1Dlist getter of the i-th element
| self | hdrl_spectrum1Dlist |
| idx | index of the element we want. 0 <= index < size |
Possible cpl-error-code set in this function:
| const hdrl_spectrum1D * hdrl_spectrum1Dlist_get_const | ( | const hdrl_spectrum1Dlist * | self, |
| const cpl_size | idx | ||
| ) |
hdrl_spectrum1Dlist getter of the i-th element
| self | hdrl_spectrum1Dlist |
| idx | index of the element we want. 0 <= index < size |
Possible cpl-error-code set in this function:
| cpl_size hdrl_spectrum1Dlist_get_size | ( | const hdrl_spectrum1Dlist * | l | ) |
hdrl_spectrum1Dlist getter for size
| l | hdrl_spectrum1Dlist |
Possible cpl-error-code set in this function:
| hdrl_spectrum1Dlist * hdrl_spectrum1Dlist_new | ( | void | ) |
hdrl_spectrum1Dlist default constructor
The constructor allocates memory of a hdrl_spectrum1Dlist structure. The struct has zero capacity when allocated.
| cpl_error_code hdrl_spectrum1Dlist_set | ( | hdrl_spectrum1Dlist * | self, |
| hdrl_spectrum1D * | s, | ||
| const cpl_size | idx | ||
| ) |
hdrl_spectrum1Dlist setter of the i-th element
| self | hdrl_spectrum1Dlist |
| s | hdrl_spectrum1D we want to insert |
| idx | position the spectrum is inserted in. 0 <= index <= size |
The function insert s inside self. if index == size, the capacity of the list is increased to accommodate the new element. If a spectrum was already contained in the i-th position, it is de-allocated. The list becomes responsible for the memory management of s.
Possible cpl-error-code set in this function:
| hdrl_spectrum1D * hdrl_spectrum1Dlist_unset | ( | hdrl_spectrum1Dlist * | self, |
| const cpl_size | idx | ||
| ) |
hdrl_spectrum1Dlist remove of the i-th element
| self | hdrl_spectrum1Dlist |
| idx | position of element we want to remove from the list. 0 <= index < size |
The function extract the idx-th element from the list. It shifts all the elements from idx + 1 to size - 1 down of one position. If the new size is less than half the capacity, the capacity is reduced.
Possible cpl-error-code set in this function:
| hdrl_spectrum1Dlist * hdrl_spectrum1Dlist_wrap | ( | hdrl_spectrum1D ** | self, |
| const cpl_size | sz | ||
| ) |
hdrl_spectrum1Dlist wrapper
| self | array of pointers to hdrl_spectrum1D |
| sz | number of elements in self |
The constructor allocates memory of a new hdrl_spectrum1Dlist structure. The structure takes ownership of self, and therefore it is responsible for its de-allocation. Self must not contain duplicate or NULL pointers.
| const double wave_delta = 1.e-6 |