28#ifndef HDRL_SPECTRUM_H
29#define HDRL_SPECTRUM_H
35#include "hdrl_image.h"
36#include "hdrl_correlation.h"
37#include "hdrl_spectrum_defs.h"
43#if defined HDRL_USE_EXPERIMENTAL || defined HDRL_USE_PRIVATE
48void hdrl_spectrum1D_save(
const hdrl_spectrum1D * s,
const char * fname);
56 const cpl_image * arg_flux_e,
57 const cpl_array * wavelength,
58 hdrl_spectrum1D_wave_scale wave_scale);
61 (
const cpl_image * arg_flux,
62 const cpl_array * wavelength,
63 hdrl_spectrum1D_wave_scale scale);
66 (
const cpl_image * arg_flux,
68 const cpl_array * wavelength,
69 hdrl_spectrum1D_wave_scale scale);
71typedef hdrl_value (* calculate_analytic_spectrum_point) (hdrl_data_t lambda);
74 calculate_analytic_spectrum_point func,
75 const cpl_array * wavelength,
76 hdrl_spectrum1D_wave_scale scale);
94 const cpl_array * wavelength;
96 hdrl_spectrum1D_wave_scale scale;
97}hdrl_spectrum1D_wavelength;
99hdrl_spectrum1D_wavelength
102hdrl_spectrum1D_wave_scale
119 const hdrl_spectrum1D_wavelength* s2);
122 const cpl_array* w2);
125 const hdrl_spectrum1D * den);
129 const hdrl_spectrum1D * f2);
133 const hdrl_spectrum1D * f2);
137 const hdrl_spectrum1D * f2);
141 const hdrl_spectrum1D * other);
144 const hdrl_spectrum1D * other);
147 const hdrl_spectrum1D * other);
150 const hdrl_spectrum1D * other);
158 hdrl_value scalar_operator);
162 hdrl_value scalar_operator);
166 hdrl_value scalar_operator);
170 hdrl_value scalar_operator);
174 hdrl_value scalar_operator);
178 hdrl_value scalar_operator);
181 hdrl_value scalar_operator);
184 hdrl_value scalar_operator);
187 hdrl_value scalar_operator);
190 hdrl_value scalar_operator);
193 hdrl_value scalar_operator);
196 hdrl_value scalar_operator);
203 hdrl_data_t scale_linear);
207 hdrl_data_t scale_linear);
235 const cpl_bivector * windows,
const cpl_boolean is_internal);
239 const cpl_array * bad_samples);
247(
const hdrl_spectrum1D * self,
const char * flux_col_name,
248const char* wavelength_col_name,
const char * flux_e_col_name,
249const char * flux_bpm_col_name);
252(
const cpl_table * self,
const char * flux_col_name,
253const char* wavelength_col_name,
const char * flux_e_col_name,
254const char * flux_bpm_col_name, hdrl_spectrum1D_wave_scale scale);
257(
const hdrl_spectrum1D * self, cpl_table * dest,
258const char * flux_col_name,
const char* wavelength_col_name,
259const char * flux_e_col_name,
const char * flux_bpm_col_name);
hdrl_spectrum1D * hdrl_spectrum1D_pow_scalar_create(const hdrl_spectrum1D *self, hdrl_value scalar_operator)
subtract a scalar from a spectrum
const hdrl_image * hdrl_spectrum1D_get_flux(const hdrl_spectrum1D *self)
hdrl_spectrum1D getter flux
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_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...
cpl_error_code hdrl_spectrum1D_wavelength_convert_to_linear(hdrl_spectrum1D *self)
converts the wavelength scale to linear.
hdrl_spectrum1D * hdrl_spectrum1D_sub_spectrum_create(const hdrl_spectrum1D *f1, const hdrl_spectrum1D *f2)
subtract two spectra
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 modifi...
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_pow_scalar(hdrl_spectrum1D *self, hdrl_value scalar_operator)
computes the elementwise power of the flux to the scalar, the self parameter is modified
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_duplicate(const hdrl_spectrum1D *self)
hdrl_spectrum1D copy constructor
cpl_size hdrl_spectrum1D_get_size(const hdrl_spectrum1D *self)
hdrl_spectrum1D getter for size
void hdrl_spectrum1D_delete(hdrl_spectrum1D **p_self)
hdrl_spectrum1D destructor
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_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_div_spectrum_create(const hdrl_spectrum1D *num, const hdrl_spectrum1D *den)
divide one spectrum by another spectrum
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
hdrl_spectrum1D * hdrl_spectrum1D_mul_scalar_create(const hdrl_spectrum1D *self, hdrl_value scalar_operator)
multiply a spectrum by a scalar
cpl_error_code hdrl_spectrum1D_sub_spectrum(hdrl_spectrum1D *self, const hdrl_spectrum1D *other)
subtract two spectra
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.
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_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 es...
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
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....
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_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_boolean hdrl_spectrum1D_is_uniformly_sampled(const hdrl_spectrum1D *self, double *bin)
checks if the spectrum is defined on uniformly sampled wavelengths.
CPL_BEGIN_DECLS 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
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_add_spectrum(hdrl_spectrum1D *self, const hdrl_spectrum1D *other)
sum two spectra
hdrl_spectrum1D * hdrl_spectrum1D_exp_scalar_create(const hdrl_spectrum1D *self, hdrl_value scalar_operator)
subtract a scalar from 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_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...
hdrl_spectrum1D_wave_scale hdrl_spectrum1D_get_scale(const hdrl_spectrum1D *self)
hdrl_spectrum1D getter for scale
hdrl_spectrum1D_wavelength hdrl_spectrum1D_get_wavelength(const hdrl_spectrum1D *self)
hdrl_spectrum1D getter for wavelengths
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 fo...
hdrl_spectrum1D * hdrl_spectrum1D_add_scalar_create(const hdrl_spectrum1D *self, hdrl_value scalar_operator)
add a scalar to a spectrum
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_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
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_wavelength_convert_to_linear_create(const hdrl_spectrum1D *self)
converts the wavelength scale to linear.
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.
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 wave...
hdrl_spectrum1D * hdrl_spectrum1D_add_spectrum_create(const hdrl_spectrum1D *f1, const hdrl_spectrum1D *f2)
sum one spectrum to another 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_boolean hdrl_spectrum1D_are_spectra_compatible(const hdrl_spectrum1D_wavelength *s1, const hdrl_spectrum1D_wavelength *s2)
checks if two spectrum wavelengths are equal.
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 mar...
hdrl_value hdrl_spectrum1D_get_flux_value(const hdrl_spectrum1D *self, int idx, int *rej)
hdrl_spectrum1D getter for a flux value