ERIS Pipeline Reference Manual 1.8.14
Functions
Helper functions for lambda correction.

Functions

cpl_polynomial * eris_ifu_lcorr_get (cpl_imagelist *cube, hdrl_imagelist *hdrlCube, const cpl_propertylist *header, cpl_vector *peaks, const int pfit_order)
 Main function to create the lcal-correction.
 
cpl_bivector * eris_ifu_lcorr_extract_spectrum (const cpl_imagelist *cube, const cpl_propertylist *header, const double min_frac, const cpl_vector *range)
 Creates a vector containing the spectrum of all marked spaxels.
 
cpl_image * eris_ifu_lcorr_create_object_mask (const cpl_imagelist *cube, double min_frac, const cpl_vector *lambda, const cpl_vector *range)
 Creates a mask of the cube.
 
cpl_vector * eris_ifu_lcorr_create_lambda_vector (const cpl_propertylist *header)
 Creates a wavelength vector from an input cube.
 
cpl_bivector * eris_ifu_lcorr_read_OH_reference_spectrum (const char *filename, cpl_size ext_number)
 Creates a spectrum bivector (x: lambda) from an input FITS file.
 
cpl_array * eris_ifu_lcorr_get_peak_positions (const cpl_bivector *spectrum, double min_frac, cpl_vector *range)
 Get peaks of position of lines used in wavelength calibration.
 
cpl_vector * eris_ifu_lcorr_get_peak_lambdas (const cpl_bivector *spectrum, double min_frac, cpl_vector *range)
 Get peaks of position of lines used in wavelength calibration.
 
int gauss1d_fnc (const double x[], const double a[], double *result)
 define a Gaussian profile
 
int gauss1d_fncd (const double x[], const double a[], double result[])
 define a Gaussian profile
 
double fit_peak (const cpl_bivector *spectrum, const cpl_size size, double lambda_in, int half_width, double *sigma_par)
 fit a peak
 
cpl_polynomial * eris_ifu_lcorr_crosscorrelate_spectra (cpl_bivector *object, cpl_vector *peaks, ifsBand bandId, const int pfit_order)
 cross-correlate two input spectra
 
void eris_ifu_lcorr_open_debug_file (const char *filename)
 open ASCII file to hold debug results
 
void eris_ifu_lcorr_close_debug_file (void)
 close ASCII file that hold debug results
 

Detailed Description

Function Documentation

◆ eris_ifu_lcorr_close_debug_file()

void eris_ifu_lcorr_close_debug_file ( void  )

close ASCII file that hold debug results

Definition at line 1384 of file eris_ifu_lambda_corr.c.

◆ eris_ifu_lcorr_create_lambda_vector()

cpl_vector * eris_ifu_lcorr_create_lambda_vector ( const cpl_propertylist *  header)

Creates a wavelength vector from an input cube.

Using the WCS properties of the third axis a lambda vector is created.

Parameters
headerpropertylist property list of input cube
Returns
A vector in case of success, NULL otherwise.

The returned vector has to be deallocated with cpl_vector_delete().

Definition at line 408 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_NULL, CATCH, CATCH_MSG, and TRY.

Referenced by eris_ifu_lcorr_extract_spectrum(), and eris_ifu_sky_tweak().

◆ eris_ifu_lcorr_create_object_mask()

cpl_image * eris_ifu_lcorr_create_object_mask ( const cpl_imagelist *  cube,
double  min_frac,
const cpl_vector *  lambda,
const cpl_vector *  range 
)

Creates a mask of the cube.

For every spaxel an averaged (using median) flux is calculated. If both a lambda vector and wavelength range(s) are specified only those ranges are considered.

Both the lambda vector and the wavelength range vector must be specified or must be NULL.

Each entry in the lambda vector corresponds to the same index in the z-axis of the cube. So the lambda vector must have the same number of elements than the number of images in the cube.

The wavelength range vector contains one or more ranges as a sequence of value pairs: lower range value (inclusive), upper range value (inclusive)

Parameters
cubeinput cube
min_fracfraction of spaxels sorted according the average flux to be used
lambdawavelength vector, each entry corresponds to the z-direction of the input cube or NULL
rangewavelength ranges to be considered or NULL
Returns
An image holding the mask in case of success, NULL otherwise

The returned image has to be deallocated with cpl_image_delete().

Definition at line 258 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, eris_ifu_mask_nans_in_cube(), and TRY.

Referenced by eris_ifu_lcorr_extract_spectrum(), eris_ifu_plot_cube_background(), and eris_ifu_sky_tweak().

◆ eris_ifu_lcorr_crosscorrelate_spectra()

cpl_polynomial * eris_ifu_lcorr_crosscorrelate_spectra ( cpl_bivector *  object,
cpl_vector *  peaks,
ifsBand  bandId,
const int  pfit_order 
)

cross-correlate two input spectra

Parameters
objectinput spectrum
peakspeaks
bandIdband setup
pfit_order
Returns
polynomial with solution in case of success, NULL otherwise.

Definition at line 1090 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, CHECK_ERROR_STATE, eris_ifu_get_band_resolution(), fit_peak(), and TRY.

Referenced by eris_ifu_lcorr_get().

◆ eris_ifu_lcorr_extract_spectrum()

cpl_bivector * eris_ifu_lcorr_extract_spectrum ( const cpl_imagelist *  cube,
const cpl_propertylist *  header,
const double  min_frac,
const cpl_vector *  range 
)

Creates a vector containing the spectrum of all marked spaxels.

Parameters
cubeinput cube
headerinput fits header
min_fracminimum fraction
rangewavelength ranges to be considered or NULL
Returns
A bi-vector in case of success, NULL otherwise.

The returned bi-vector has to be deallocated with cpl_vector_delete().

Definition at line 184 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, eris_ifu_lcorr_create_lambda_vector(), eris_ifu_lcorr_create_object_mask(), and TRY.

Referenced by eris_ifu_lcorr_get().

◆ eris_ifu_lcorr_get()

cpl_polynomial * eris_ifu_lcorr_get ( cpl_imagelist *  cube,
hdrl_imagelist *  hdrlCube,
const cpl_propertylist *  header,
cpl_vector *  peaks,
const int  pfit_order 
)

Main function to create the lcal-correction.

Parameters
cubeinput data cube
hdrlCubethe header of cube
headerthe header of cube
peaksvector with the found peaks
pfit_orderorder of polynomial fit
Returns
The lcal-correction-polynomial

The returned polynomial has to be deallocated with cpl_polynomial_delete().

Definition at line 61 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CHECK_ERROR_STATE, eris_ifu_get_band(), eris_ifu_lcorr_crosscorrelate_spectra(), eris_ifu_lcorr_extract_spectrum(), eris_ifu_mask_nans_in_cube(), hdrl_image_get_image(), hdrl_imagelist_get(), hdrl_imagelist_get_size(), and TRY.

◆ eris_ifu_lcorr_get_peak_lambdas()

cpl_vector * eris_ifu_lcorr_get_peak_lambdas ( const cpl_bivector *  spectrum,
double  min_frac,
cpl_vector *  range 
)

Get peaks of position of lines used in wavelength calibration.

Parameters
spectrumFile name of input FITS file holding the reference spectrum
min_fracminimum fraction
rangewavelength ranges to be considered or NULL
Returns
An array in case of success, NULL otherwise.

The returned bivector has to be deallocated with cpl_bivector_delete().

Definition at line 680 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, BRK_WITH_ERROR, CATCH, CHECK_ERROR_STATE, eris_ifu_free_int_array(), eris_ifu_free_vector(), eris_ifu_lcorr_get_peak_positions(), fit_peak(), and TRY.

◆ eris_ifu_lcorr_get_peak_positions()

cpl_array * eris_ifu_lcorr_get_peak_positions ( const cpl_bivector *  spectrum,
double  min_frac,
cpl_vector *  range 
)

Get peaks of position of lines used in wavelength calibration.

Parameters
spectrumFile name of input FITS file holding the reference spectrum
min_fracminimum fraction
rangewavelength ranges to be considered or NULL
Returns
An array in case of success, NULL otherwise.

The returned bivector has to be deallocated with cpl_bivector_delete().

Definition at line 562 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_ERROR, BRK_IF_NULL, CATCH, CATCH_MSG, and TRY.

Referenced by eris_ifu_lcorr_get_peak_lambdas().

◆ eris_ifu_lcorr_open_debug_file()

void eris_ifu_lcorr_open_debug_file ( const char *  filename)

open ASCII file to hold debug results

Parameters
filenameinput filename

Definition at line 1374 of file eris_ifu_lambda_corr.c.

◆ eris_ifu_lcorr_read_OH_reference_spectrum()

cpl_bivector * eris_ifu_lcorr_read_OH_reference_spectrum ( const char *  filename,
cpl_size  ext_number 
)

Creates a spectrum bivector (x: lambda) from an input FITS file.

Reads a spectrum from a FITS file. If lambda is specified the spectrum is mapped on the specified lambda values using cubic splines. Otherwise the native lambda resolution is returned.

Parameters
filenameFile name of input FITS file holding the reference spectrum
ext_numberextension number
Returns
A bivector in case of success, NULL otherwise.

The returned bivector has to be deallocated with cpl_bivector_delete().

Definition at line 468 of file eris_ifu_lambda_corr.c.

References ASSURE, BRK_IF_NULL, BRK_WITH_ERROR_MSG, CATCH, CATCH_MSG, CHECK_ERROR_STATE, and TRY.

◆ fit_peak()

double fit_peak ( const cpl_bivector *  spectrum,
const cpl_size  size,
double  lambda_in,
int  half_width,
double *  sigma_par 
)

fit a peak

Parameters
spectruminput spectrum
sizesize of input spectrum
lambda_ininput lambda near which peak is found
half_widthinput half_with of range where fit is done
sigma_paroutput sigma
Returns
position of peak maximum, 0 in case of failure.

Definition at line 963 of file eris_ifu_lambda_corr.c.

References gauss1d_fnc(), and gauss1d_fncd().

Referenced by eris_ifu_lcorr_crosscorrelate_spectra(), and eris_ifu_lcorr_get_peak_lambdas().

◆ gauss1d_fnc()

int gauss1d_fnc ( const double  x[],
const double  a[],
double *  result 
)

define a Gaussian profile

Parameters
xFile name of input FITS file holding the reference spectrum
aminimum fraction
resultGaussian profile
Returns
1 in case of success, 0 otherwise.

Definition at line 891 of file eris_ifu_lambda_corr.c.

Referenced by fit_peak().

◆ gauss1d_fncd()

int gauss1d_fncd ( const double  x[],
const double  a[],
double  result[] 
)

define a Gaussian profile

Parameters
xFile name of input FITS file holding the reference spectrum
aminimum fraction
resultGaussian profile
Returns
1 in case of success, 0 otherwise.

Definition at line 920 of file eris_ifu_lambda_corr.c.

Referenced by fit_peak().