X-shooter Pipeline Reference Manual 3.8.15
Macros
xsh_eqwidth_lib.c File Reference
#include "xsh_eqwidth_lib.h"
#include <xsh_msg.h>
#include <gsl/gsl_version.h>

Go to the source code of this file.

Macros

#define C(i)   (gsl_vector_get(c,(i)))
 
#define COV(i, j)   (gsl_matrix_get(cov,(i),(j)))
 
#define FIT(i)   gsl_vector_get(s->x, i)
 
#define ERR(i)   sqrt(gsl_matrix_get(covar,i,i))
 

Functions

static cpl_size get_index_from_spec (cpl_table *spec_total, double lambda)
 
static cpl_size get_pixel_to_nm_scale (cpl_table *spec_total, double nm)
 get scale from nm to pixels
 
cpl_error_code select_local_spec (cpl_table *spec_total, double ew_space, double lambda, cpl_table **spec_region)
 Select_local_spec.
 
void find_left_right_continuum_pos (int *x1, int *x2, cpl_table *spec_region, double cont_rejt, double line)
 
static cpl_table * esp_spec_deriv (cpl_table *spec_region)
 
static void esp_spec_smooth (cpl_table *spec_region, int smwidth)
 
void smooth (double vec[], long n, int w, double svec[])
 
static void zeroscenterfind (double iy[], double y[], double dy[], double ddy[], long n, long center[], long *ncenter, double det_line_thres)
 
double maxele_vec (double vec[], long nvec)
 
cpl_error_code esp_fit_ngauss (cpl_table *spec_cont_region, cpl_table *line_table, double fit_ngauss_width)
 Fit a list of absorption lines with n Gaussian profiles and compute the equivalent width of each line from the fit.
 
double check_ew (cpl_table *line_table, double line, double det_line_resol, int *index_line, int *n_lines, double *ew_error)
 
static void poly_fitn (double xvec[], double yvec[], double err[], long n, long ord, double coefs[])
 
void deriv (double x[], double y[], double dy[], long n)
 
void fitngauss (double t[], double y[], double sigma[], long nvec, double acoef[], double acoef_er[], int para, int *status2)
 
cpl_error_code espda_create_line_table (cpl_table **tab, cpl_size size)
 Create a LINE table with a given row size.
 
cpl_error_code esp_fit_lcont (cpl_table *spec_region, double cont_rejt, int cont_iter)
 Performs a local normalization of the spectrum region.
 
cpl_error_code esp_det_line (cpl_table *spec_cont_region, double det_line_thres, double det_line_resol, int det_line_smwidth, cpl_table **line_table)
 Performs a local normalization of the spectrum region.
 

Macro Definition Documentation

◆ C

#define C (   i)    (gsl_vector_get(c,(i)))

◆ COV

#define COV (   i,
 
)    (gsl_matrix_get(cov,(i),(j)))

◆ ERR

#define ERR (   i)    sqrt(gsl_matrix_get(covar,i,i))

◆ FIT

#define FIT (   i)    gsl_vector_get(s->x, i)

Function Documentation

◆ check_ew()

double check_ew ( cpl_table *  line_table,
double  line,
double  det_line_resol,
int *  index_line,
int *  n_lines,
double *  ew_error 
)

Definition at line 403 of file xsh_eqwidth_lib.c.

◆ deriv()

void deriv ( double  x[],
double  y[],
double  dy[],
long  n 
)

Definition at line 476 of file xsh_eqwidth_lib.c.

References n, x, and y.

Referenced by esp_spec_deriv().

◆ esp_det_line()

cpl_error_code esp_det_line ( cpl_table *  spec_cont_region,
double  det_line_thres,
double  det_line_resol,
int  det_line_smwidth,
cpl_table **  line_table 
)

Performs a local normalization of the spectrum region.

Parameters
spec_cont_regionspectrum region table (normalized)
det_line_thresNormalized threshold for line acceptance The default value is 0.02
det_line_resolMinimum accepted separation between two lines (in Angstrom)
det_line_smwidthNumber of pixels in the boxcar to be averaged
Returns
CPL_ERROR_NONE if OK

This function detects absorption lines in a spectrum after normalizing it.

Definition at line 775 of file xsh_eqwidth_lib.c.

References esp_spec_deriv(), esp_spec_smooth(), espda_create_line_table(), n, x, y, and zeroscenterfind().

Referenced by test_spectrum_detect_lines().

◆ esp_fit_lcont()

cpl_error_code esp_fit_lcont ( cpl_table *  spec_region,
double  cont_rejt,
int  cont_iter 
)

Performs a local normalization of the spectrum region.

Parameters
spec_regionspectrum region table
cont-rejtRejection threshold for the continuum determination. The default value depends on the signal-to­-noise parameter for the interval around the line
cont-iterNumber of iterations to fit the continuum
Returns
CPL_ERROR_NONE if OK

This function updates the region of the spectra for the calculations with the normalization

Definition at line 671 of file xsh_eqwidth_lib.c.

References n, order, poly_fitn(), x, and y.

Referenced by test_spectrum_detect_lines().

◆ esp_fit_ngauss()

cpl_error_code esp_fit_ngauss ( cpl_table *  spec_cont_region,
cpl_table *  line_table,
double  fit_ngauss_width 
)

Fit a list of absorption lines with n Gaussian profiles and compute the equivalent width of each line from the fit.

Parameters
spec_cont_regionspectrum region table (normalized)
line_tabletable with the lines to be fitted
fit_ngauss_widthWidth of the interval used for fitting (nm)??? Currently being used as the guess sigma for the gaussian fitting
Returns
CPL_ERROR_NONE if OK

This function detects absorption lines in a spectrum after normalizing it.

Definition at line 332 of file xsh_eqwidth_lib.c.

References fitngauss(), and sigma.

◆ esp_spec_deriv()

static cpl_table * esp_spec_deriv ( cpl_table *  spec_region)
static

Definition at line 195 of file xsh_eqwidth_lib.c.

References deriv(), n, x, and y.

Referenced by esp_det_line().

◆ esp_spec_smooth()

static void esp_spec_smooth ( cpl_table *  spec_region,
int  smwidth 
)
static

Definition at line 221 of file xsh_eqwidth_lib.c.

References n, smooth(), and y.

Referenced by esp_det_line().

◆ espda_create_line_table()

cpl_error_code espda_create_line_table ( cpl_table **  tab,
cpl_size  size 
)

Create a LINE table with a given row size.

Parameters
tabNew table
sizeRow size
Returns
CPL_ERROR_NONE ff OK

This functions creates a CPL table with structure LINE and a given row size.

Definition at line 588 of file xsh_eqwidth_lib.c.

References size.

Referenced by esp_det_line().

◆ find_left_right_continuum_pos()

void find_left_right_continuum_pos ( int *  x1,
int *  x2,
cpl_table *  spec_region,
double  cont_rejt,
double  line 
)

Definition at line 162 of file xsh_eqwidth_lib.c.

References n, x, and y.

◆ fitngauss()

void fitngauss ( double  t[],
double  y[],
double  sigma[],
long  nvec,
double  acoef[],
double  acoef_er[],
int  para,
int *  status2 
)

Definition at line 490 of file xsh_eqwidth_lib.c.

References ERR, expb_df(), expb_f(), expb_fdf(), FIT, N, n, data::para, s, sigma, data::t, x, SimAnneal::x, and y.

Referenced by esp_fit_ngauss().

◆ get_index_from_spec()

static cpl_size get_index_from_spec ( cpl_table *  spec_total,
double  lambda 
)
static

Definition at line 36 of file xsh_eqwidth_lib.c.

Referenced by select_local_spec().

◆ get_pixel_to_nm_scale()

static cpl_size get_pixel_to_nm_scale ( cpl_table *  spec_total,
double  nm 
)
static

get scale from nm to pixels

Parameters
spec_1dspectrum table
nmspace scale
Returns
return pixel scale

This function returns a the index of the closest wavelenght greatest than lambda

Definition at line 104 of file xsh_eqwidth_lib.c.

Referenced by select_local_spec().

◆ maxele_vec()

double maxele_vec ( double  vec[],
long  nvec 
)

Definition at line 304 of file xsh_eqwidth_lib.c.

References max.

Referenced by zeroscenterfind().

◆ poly_fitn()

static void poly_fitn ( double  xvec[],
double  yvec[],
double  err[],
long  n,
long  ord,
double  coefs[] 
)
static

Definition at line 435 of file xsh_eqwidth_lib.c.

References C, n, and y.

Referenced by esp_fit_lcont().

◆ select_local_spec()

cpl_error_code select_local_spec ( cpl_table *  spec_total,
double  ew_space,
double  lambda,
cpl_table **  spec_region 
)

Select_local_spec.

Parameters
spec_1dspectrum table
ew_spaceparameter for the interval around the line
lineline center for the spectral region
spec_1d_outNumber of frames in the new frameset
Returns
CPL_ERROR_NONE if OK

This function returns a region of the spectra for the calculations

Definition at line 126 of file xsh_eqwidth_lib.c.

References get_index_from_spec(), and get_pixel_to_nm_scale().

Referenced by test_spectrum_detect_lines().

◆ smooth()

void smooth ( double  vec[],
long  n,
int  w,
double  svec[] 
)

Definition at line 243 of file xsh_eqwidth_lib.c.

References n.

Referenced by esp_spec_smooth(), and xsh_atrous().

◆ zeroscenterfind()

static void zeroscenterfind ( double  iy[],
double  y[],
double  dy[],
double  ddy[],
long  n,
long  center[],
long *  ncenter,
double  det_line_thres 
)
static

Definition at line 263 of file xsh_eqwidth_lib.c.

References maxele_vec(), and n.

Referenced by esp_det_line().