X-shooter Pipeline Reference Manual 3.8.15
xsh_molecfit_model.h
Go to the documentation of this file.
1/*
2 * This file is part of the ESO X-Shooter Pipeline
3 * Copyright (C) 2001-2018 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef XSH_MOLECFIT_MODEL_H
21#define XSH_MOLECFIT_MODEL_H
22/*----------------------------------------------------------------------------*/
26/*----------------------------------------------------------------------------*/
27
28/* Include both telluriccorr *and* our extra wrapper codes, since
29 we deliberately don't want to have them (pre-included) in telluriccorr.h
30 to ensure telluriccorr is still comptabile with molecfit_model
31*/
32
33#include <string.h>
34#include <math.h>
35
36#include <cpl.h>
37
38//#include <telluriccorr.h>
39#include "mf_wrap.h"
40#include "mf_wrap_config.h"
41#include "mf_spectrum.h"
42#include "xsh_molecfit_utils.h"
43
44/*----------------------------------------------------------------------------*/
48/*----------------------------------------------------------------------------*/
49
50/*----------------------------------------------------------------------------*/
54/*----------------------------------------------------------------------------*/
55
56
57#define XSHOOTER_INPUT_DATA_FLUX_COLUMN "Flux"
58
59//descriptions for the input parameters...
60//by default grab the DESC already defined in molecfit_config or telluriccorr
61//in case we want to define our own xshooter specific help
62#define XSH_MOLECFIT_PARAMETER_LIST_DESC "List of molecules to include in the fit (comma separated). If set to 'NULL', the values provided in MOLECULES_XXX will be used, where XXX is UVB, VIS or NIR. If not, the provided list overrides what is specified in the MOLECULES_XXX input. Note: in order to override MOLECULES_XXX, the recipe parameters REL_COL, FIT_MOLEC, and LIST_MOLEC must be all specified and different from 'NULL'."
63//#define XSH_MOLECFIT_PARAMETER_LIST_DESC MOLECFIT_PARAMETER_LIST_DESC
64
65#define XSH_MOLECFIT_PARAMETER_FIT_DESC "List of flags (1 and 0), comma separated, that specifies if a molecule has to be fitted (flag=1) or computed (flag=0). If set to 'NULL', the values provided in MOLECULES_XXX will be used, where XXX is UVB, VIS or NIR. If not, the provided list overrides what is specified in the MOLECULES_XXX input. Note: in order to override MOLECULES_XXX, the following recipe parameters rel_col, fit_molec, and list_molec must be all specified and different from 'NULL'."
66//#define XSH_MOLECFIT_PARAMETER_FIT_DESC MOLECFIT_PARAMETER_FIT_DESC
67
68#define XSH_MOLECFIT_PARAMETER_RELATIVE_VALUE_DESC "List of relative column densities of the molecules used (comma separated). If set to 'NULL', the values provided in MOLECULES_XXX will be used, where XXX is UVB, VIS or NIR. If not, the provided list overrides what is specified in the MOLECULES_XXX input. Note: in order to override MOLECULES_XXX, the following recipe parameters rel_col, fit_molec, and list_molec must be all specified and different from 'NULL'."
69//#define XSH_MOLECFIT_PARAMETER_RELATIVE_VALUE_DESC MOLECFIT_PARAMETER_RELATIVE_VALUE_DESC
70
71#define XSH_MOLECFIT_PARAMETER_WAVE_RANGE_INCLUDE_DESC "Comma separated list of values that define the boundaries of the wavelength regions to fit (low_1, upper_1, low_2, upper_2,...,low_n, upper_n), in microns. If set to 'NULL' the values specified in the fits table given by the tag WAVE_INCLUDE_XXX will be used, where XXX is UVB, VIS or NIR. If not, these values override those specified in WAVE_INCLUDE_XXX."
72//#define XSH_MOLECFIT_PARAMETER_WAVE_RANGE_INCLUDE_DESC MOLECFIT_PARAMETER_WAVE_RANGE_INCLUDE_DESC
73
74#define XSH_MOLECFIT_PARAMETER_WAVE_RANGE_EXCLUDE_DESC "Comma separated list of values that define the boundaries of the wavelength regions to exclude in the fit (low_1, upper_1, low_2, upper_2,...,low_n, upper_n), in microns. If set to 'NULL' the values specified in the fits table given by the tag WAVE_EXCLUDE_XXX will be used, where XXX is UVB, VIS or NIR. If not, these values override those specified in WAVE_EXCLUDE_XXX."
75//#define XSH_MOLECFIT_PARAMETER_WAVE_RANGE_EXCLUDE_DESC MOLECFIT_PARAMETER_WAVE_RANGE_EXCLUDE_DESC
76
77#define XSH_MOLECFIT_PARAMETER_PIXEL_RANGE_EXCLUDE_DESC "Comma separated list of values that define the boundaries of the pixel regions to exclude in the fit (low_1, upper_1, low_2, upper_2,...,low_n, upper_n), in pixel units. If set to 'NULL' the values specified in the fits table given by the tag PIXEL_EXCLUDE_XXX will be used, where XXX is UVB, VIS or NIR. If not, these values override those specified in PIXEL_EXCLUDE_XXX."
78//#define XSH_MOLECFIT_PARAMETER_PIXEL_RANGE_EXCLUDE_DESC MOLECFIT_PARAMETER_PIXEL_RANGE_EXCLUDE_DESC
79
80#define XSH_MF_PARAMETERS_COLUMN_LAMBDA_DESC "Name of the column in the input that identifies the wavelength. Note: this parameter is relevant only for inputs in binary table format."
81//#define XSH_MF_PARAMETERS_COLUMN_LAMBDA_DESC MF_PARAMETERS_COLUMN_LAMBDA_DESC
82
83#define XSH_MF_PARAMETERS_COLUMN_FLUX_DESC "Name of the column in the input that identifies the flux. Note: this parameter is relevant only for inputs in binary table format."
84//#define XSH_MF_PARAMETERS_COLUMN_FLUX_DESC MF_PARAMETERS_COLUMN_FLUX_DESC
85
86#define XSH_MF_PARAMETERS_COLUMN_DFLUX_DESC "Name of the column in the input that identifies the flux error. Note: this parameter is relevant only for inputs in binary table format."
87//#define XSH_MF_PARAMETERS_COLUMN_DFLUX_DESC MF_PARAMETERS_COLUMN_DFLUX_DESC
88
89#define XSH_MF_PARAMETERS_DEFAULT_ERROR_DESC "Default error relative to mean for the case that the error column is not provided."
90//#define XSH_MF_PARAMETERS_DEFAULT_ERROR_DESC MF_PARAMETERS_DEFAULT_ERROR_DESC
91
92#define XSH_MF_PARAMETERS_FTOL_DESC "Relative chi2 convergence criterion."
93//#define XSH_MF_PARAMETERS_FTOL_DESC MF_PARAMETERS_FTOL_DESC
94
95#define XSH_MF_PARAMETERS_XTOL_DESC "Relative parameter convergence criterion."
96//#define XSH_MF_PARAMETERS_XTOL_DESC MF_PARAMETERS_XTOL_DESC
97
98#define XSH_MF_PARAMETERS_FIT_CONTINUUM_DESC "Comma delimited string of flags (1=true, 0=false) for fitting the continuum in specific regions. The number of values must match the number of wavelength ranges to fit. If one single value is given, then it is assumed to be valid for all the wavelength ranges. If set to 'NULL', then the values are taken from the column CONT_POLY_ORDER of the input table WAVE_INCLUDE. If this file is not given, then the default is used."
99//#define XSH_MF_PARAMETERS_FIT_CONTINUUM_DESC MF_PARAMETERS_FIT_CONTINUUM_DESC
100
101#define XSH_MF_PARAMETERS_CONTINUUM_N_DESC "Polynomial order for the continuum model fit to each wavelength region, presented as a comma delimited string. If a single value is given, then it is assumed to be valid for all the wavelength ranges. If set to 'NULL', then the values are taken from the column CONT_POLY_ORDER of the input table WAVE_INCLUDE. If this file is not given, then the default is used."
102//#define XSH_MF_PARAMETERS_CONTINUUM_N_DESC MF_PARAMETERS_CONTINUUM_N_DESC
103
104#define XSH_MF_PARAMETERS_FIT_WLC_DESC "A list of flags (1 or 0) that specifies which ranges are to be included as a part of the wavelength correction fitting if wavelength fitting has been selected. If a single value is given, then it is assumed to be valid for all the wavelength ranges."
105//#define XSH_MF_PARAMETERS_FIT_WLC_DESC MF_PARAMETERS_FIT_WLC_DESC
106
107#define XSH_MF_PARAMETERS_WLC_N_DESC "Degree of the polynomial used to refine the wavelength solution."
108//#define XSH_MF_PARAMETERS_WLC_N_DESC MF_PARAMETERS_WLC_N_DESC
109
110#define XSH_MF_PARAMETERS_WLC_CONST_DESC "Initial term for refinement of the wavelength solution."
111//#define XSH_MF_PARAMETERS_WLC_CONST_DESC MF_PARAMETERS_WLC_CONST_DESC
112
113#define XSH_MF_PARAMETERS_FIT_RES_BOX_DESC "Flag that specifies if the instrumental line spread function is fitted by a Boxcar function."
114//#define XSH_MF_PARAMETERS_FIT_RES_BOX_DESC MF_PARAMETERS_FIT_RES_BOX_DESC
115
116#define XSH_MF_PARAMETERS_RES_BOX_DESC "Initial value in pixels of the Boxcar function width that fits the instrumental line spread function (only used if --FIT_RES_BOX=TRUE)."
117//#define XSH_MF_PARAMETERS_RES_BOX_DESC MF_PARAMETERS_RES_BOX_DESC
118
119#define XSH_MF_PARAMETERS_FIT_GAUSS_DESC "Flag that specifies if the instrumental line spread function is fitted by a Gaussian function."
120//#define XSH_MF_PARAMETERS_FIT_GAUSS_DESC MF_PARAMETERS_FIT_GAUSS_DESC
121
122#define XSH_MF_PARAMETERS_RES_GAUSS_DESC "Inital value in pixels of the FWHM of the Gaussian function that fits the instrumental line spread function (only used if --FIT_RES_GAUSS=TRUE)."
123//#define XSH_MF_PARAMETERS_RES_GAUSS_DESC MF_PARAMETERS_RES_GAUSS_DESC
124
125#define XSH_MF_PARAMETERS_FIT_LORENTZ_DESC "Flag that specifies if the instrumental line spread function is fitted by a Lorentzian function."
126//#define XSH_MF_PARAMETERS_FIT_LORENTZ_DESC MF_PARAMETERS_FIT_LORENTZ_DESC
127
128#define XSH_MF_PARAMETERS_RES_LORENTZ_DESC "Initial value in pixels of the FWHM of the Lorentz function that fits the instrumental line spread function (only used if --FIT_RES_LORENTZ=TRUE)."
129//#define XSH_MF_PARAMETERS_RES_LORENTZ_DESC MF_PARAMETERS_RES_LORENTZ_DESC
130
131#define XSH_MF_PARAMETERS_KERN_MODE_DESC "Flag that indicates whether to use a Voigt approximation instead of the Lorentz or Gauss functions to fit the instrumental line spread function."
132//#define XSH_MF_PARAMETERS_KERN_MODE_DESC MF_PARAMETERS_KERN_MODE_DESC
133
134#define XSH_MF_PARAMETERS_KERN_FAC_DESC "Size of the Gaussian/Lorentzian/Voigtian kernel, expressed in units of FWHM."
135//#define XSH_MF_PARAMETERS_KERN_FAC_DESC MF_PARAMETERS_KERN_FAC_DESC
136
137#define XSH_MF_PARAMETERS_VAR_KERN_DESC "Flag indicating if the kernel is constant or varies linearly with wavelength (i.e. resolving power is constant)."
138//#define XSH_MF_PARAMETERS_VAR_KERN_DESC MF_PARAMETERS_VAR_KERN_DESC
139
140#define XSH_MOLECFIT_PARAMETER_USE_INPUT_KERNEL_DESC "If TRUE, use the kernel library if it is provided."
141//#define XSH_MOLECFIT_PARAMETER_USE_INPUT_KERNEL_DESC MOLECFIT_PARAMETER_USE_INPUT_KERNEL_DESC
142
143#define XSH_MF_PARAMETERS_FIT_TELESCOPE_BACK_DESC "Flag that indicates whether the telescope background should be fitted."
144//#define XSH_MF_PARAMETERS_FIT_TELESCOPE_BACK_DESC MF_PARAMETERS_FIT_TELESCOPE_BACK_DESC
145
146#define XSH_MF_PARAMETERS_TELESCOPE_BACK_CONST_DESC "Initial value for the telescope background fit."
147//#define XSH_MF_PARAMETERS_TELESCOPE_BACK_CONST_DESC MF_PARAMETERS_TELESCOPE_BACK_CONST_DESC
148
149#define XSH_MF_PARAMETERS_PWV_DESC "Value in mm of the precipitable water vapour for the input water vapor profile. If set to a positive value, then the merged profile composed of ref_atm, GDAS, and local meteorological data will scaled to this value. If negative, then no scaling is done."
150//#define XSH_MF_PARAMETERS_PWV_DESC MF_PARAMETERS_PWV_DESC
151
152#define XSH_MF_PARAMETERS_SLIT_WIDTH_DESC "Slit width in arcsec (taken from FITS header if present)."
153//#define XSH_MF_PARAMETERS_SLIT_WIDTH_DESC MF_PARAMETERS_SLIT_WIDTH_DESC
154
155//other parameters
156//#define XSH_MF_LNFL_LINE_DB_DESC MF_LNFL_LINE_DB_DESC
157#define XSH_MF_LNFL_LINE_DB_DESC "AER version in format aer_v_X.X. For example aer_v_3.8 or aer_v_3.6."
158
159
160
161/*----------------------------------------------------------------------------*/
165/*----------------------------------------------------------------------------*/
166
167/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
173/*----------------------------------------------------------------------------*/
177/*----------------------------------------------------------------------------*/
178
179
180/*----------------------------------------------------------------------------*/
184/*----------------------------------------------------------------------------*/
185
186cpl_error_code xsh_molecfit_model_config(cpl_frameset *frameset,
187 const cpl_parameterlist *parlist,
188 cpl_parameterlist* ilist,
189 cpl_parameterlist* iframelist);
190
191cpl_error_code xsh_molecfit_model_spec_header_calcs(const char* fname,const char* arm, cpl_parameterlist* ilist);
192
193cpl_error_code xsh_molecfit_model_spec_data_calcs(mf_wrap_fits* data, const char* is_idp, cpl_parameterlist* ilist,mf_wrap_model_parameter* parameters);
194
195cpl_error_code xsh_molecfit_setup_frameset(cpl_frameset* frameset,cpl_parameterlist* list,const char* arm,const char* input_name);
196
197void xsh_molecfit_model_qc(cpl_propertylist* pl,cpl_table* tab);
198
199#endif /*XSH_MOLECFIT_MODEL_H*/
cpl_error_code xsh_molecfit_model_spec_header_calcs(const char *fname, const char *arm, cpl_parameterlist *ilist)
cpl_error_code xsh_molecfit_model_spec_data_calcs(mf_wrap_fits *data, const char *is_idp, cpl_parameterlist *ilist, mf_wrap_model_parameter *parameters)
void xsh_molecfit_model_qc(cpl_propertylist *pl, cpl_table *tab)
cpl_error_code xsh_molecfit_setup_frameset(cpl_frameset *frameset, cpl_parameterlist *list, const char *arm, const char *input_name)
cpl_error_code xsh_molecfit_model_config(cpl_frameset *frameset, const cpl_parameterlist *parlist, cpl_parameterlist *ilist, cpl_parameterlist *iframelist)