/home/amodigli/releases/xsh/2.1.1/xsh.30433/xshp/xsh/xsh_compute_response.c File Reference

#include <gsl/gsl_spline.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_bspline.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_statistics.h>
#include <xsh_dfs.h>
#include <xsh_error.h>
#include <xsh_msg.h>
#include <cpl.h>
#include <string.h>
#include <time.h>
#include <xsh_utils_table.h>
#include <xsh_data_star_flux.h>
#include <xsh_data_atmos_ext.h>
#include <xsh_data_spectrum.h>
#include <xsh_pfits.h>
#include <xsh_utils.h>
#include <xsh_utils_wrappers.h>
#include <xsh_drl.h>
#include <xsh_utils_efficiency.h>
#include <xsh_efficiency_response.h>
#include <xsh_utils_response.h>
#include <xsh_utils_vector.h>

Go to the source code of this file.

Defines

#define INTERPOL_WSTEP_NM   2
#define FILTER_MEDIAN_HSIZE   3

Functions

static int find_lambda_idx (double lambda, double *wave, int from, int to, double step)
static int find_lambda_idx_min (double lambda, double *wave, int from, int to, double step)
static int find_lambda_idx_max (double lambda, double *wave, int from, int to, double step)
static void find_lambda_idx_limit (double min, double max, double *spectrum, int from, int to, double step, int *if0, int *if1)
static cpl_error_code xsh_interpolate_atm_ext (xsh_star_flux_list *star_list, cpl_table *atmos_ext_tab, xsh_instrument *instrument, double **atmos_lambda, double **atmos_K)
static cpl_error_code xsh_interpolate_high_abs_regions (xsh_star_flux_list *star_list, xsh_star_flux_list *resp_list, HIGH_ABS_REGION *phigh)
static cpl_error_code xsh_interpolate_high_abs_regions2 (xsh_star_flux_list *star_list, xsh_star_flux_list *resp_list, HIGH_ABS_REGION *phigh)
static cpl_error_code xsh_response_crea_ascii (xsh_star_flux_list *resp_list, xsh_star_flux_list *star_list, double *lambda_spectrum, double *flux_spectrum, double *flux_added)
static cpl_error_code xsh_flux_integrate_and_corr_for_badpix (int npix_in_interval, double *flux_spectrum, int *qual_spectrum, int if0, int if1, int i, double **flux_added, int *npixels, int *nbad)
static cpl_error_code xsh_spectrum_correct (xsh_star_flux_list *star_list, xsh_star_flux_list **obj_list, xsh_spectrum *spectrum, cpl_table *atmos_ext_tab, XSH_ARM the_arm, double *atmos_K, double airmass, double exptime, double gain)
static xsh_star_flux_listxsh_response_calculate (xsh_star_flux_list *star_list, xsh_star_flux_list **obj_list, xsh_spectrum *spectrum, cpl_table *atmos_ext_tab, XSH_ARM the_arm, double *atmos_K, double airmass, double exptime, double gain)
static xsh_star_flux_listdo_compute (xsh_star_flux_list *star_list, xsh_star_flux_list **obj_list, xsh_spectrum *spectrum, cpl_table *atmos_ext_tab, HIGH_ABS_REGION *phigh, double airmass, double exptime, double gain, xsh_instrument *instrument)
cpl_error_code xsh_response_merge_obj_std_info (cpl_frame *result, xsh_star_flux_list *star_list, xsh_star_flux_list *obj_list)
static xsh_star_flux_listxsh_obs_std_correct (cpl_frame *obs_std_star, xsh_star_flux_list *ref_std_star_list, cpl_frame *atmos_ext, HIGH_ABS_REGION *phigh, xsh_instrument *instrument)
static cpl_error_code xsh_std_star_spectra_to_vector_range (xsh_star_flux_list *obs_std_star_list, const double wmin, const double wmax, cpl_vector **vec_wave, cpl_vector **vec_flux)
cpl_error_code xsh_sort_double_pairs (double *u1, double *u2, cpl_size n)
 Sort an array u1 of doubles, and permute an array u2 in the same way as u1 is permuted.
static cpl_error_code xsh_select_line_core (cpl_vector *wave, cpl_vector *flux, const double wguess, const double wrange, cpl_vector **xfit, cpl_vector **yfit)
static cpl_error_code xsh_line_balance (cpl_vector **x, cpl_vector **y, const double ymax)
static double xsh_std_star_spectra_correlate (xsh_star_flux_list *obs_std_star_list, xsh_star_flux_list *ref_std_star_list, xsh_rv_ref_wave_param *w)
static xsh_star_flux_listxsh_bspline_fit (xsh_star_flux_list *ref_std_star_list, HIGH_ABS_REGION *phigh, xsh_instrument *inst)
double * xsh_bspline_interpolate_data_at_pos (double *wave, double *flux, const int size, double *pos, const int size_pos)
double * xsh_bspline_fit_data (double *wave, double *flux, const int size, HIGH_ABS_REGION *phigh, xsh_instrument *inst, const int fit_region)
double * xsh_bspline_fit_data2 (double *wave, double *flux, const int size, HIGH_ABS_REGION *phigh, xsh_instrument *inst, const int fit_region)
cpl_frame * xsh_compute_response2 (cpl_frame *obs_std_star, cpl_frame *flux_std_star_cat, cpl_frame *atmos_ext, cpl_frame *high_abs, cpl_frame *tell_mod_cat, xsh_instrument *instrument, double exptime, const int tell_corr)
cpl_frame * xsh_compute_response (cpl_frame *spectrum_frame, cpl_frame *flux_std_star_cat_frame, cpl_frame *atmos_ext_frame, cpl_frame *high_abs_frame, xsh_instrument *instrument, double exptime)
cpl_frame * xsh_compute_response_ord (cpl_frame *spectrum_frame, cpl_frame *flux_std_star_cat_frame, cpl_frame *atmos_ext_frame, cpl_frame *high_abs_win_frame, xsh_instrument *instrument, double exptime)

Define Documentation

#define FILTER_MEDIAN_HSIZE   3

Definition at line 81 of file xsh_compute_response.c.

Referenced by xsh_response_calculate().

#define INTERPOL_WSTEP_NM   2

Definition at line 80 of file xsh_compute_response.c.

Referenced by xsh_compute_response(), and xsh_compute_response_ord().


Function Documentation

static xsh_star_flux_list* do_compute ( xsh_star_flux_list star_list,
xsh_star_flux_list **  obj_list,
xsh_spectrum spectrum,
cpl_table *  atmos_ext_tab,
HIGH_ABS_REGION phigh,
double  airmass,
double  exptime,
double  gain,
xsh_instrument instrument 
) [static]

Integrate the flux on the same sampling that the star_list, taking into account the bad pixels, apply atmos correction, and divide by the star_list table.

Parameters:
star_list Table of ref star flux
star_list Table of obs obj flux
spectrum 1./CPL/DOC/cpl_um_2.0.1.psD merged spectrum of standard star
atmos_ext_table Atmos Extinction table
airmass observed object airmass mean
exptime Exposure time
gain detector's gain
instrument instrument arm and lamp setting
Returns:
The computed response frame (table)

Definition at line 1265 of file xsh_compute_response.c.

References check, xsh_star_flux_list::lambda, HIGH_ABS_REGION::lambda_max, HIGH_ABS_REGION::lambda_min, xsh_star_flux_list::size, XSH_ASSURE_NOT_NULL, XSH_FREE, xsh_instrument_get_arm(), xsh_interpolate_atm_ext(), xsh_interpolate_high_abs_regions(), xsh_msg_dbg_low, xsh_msg_dbg_medium, and xsh_response_calculate().

Referenced by xsh_compute_response(), and xsh_compute_response_ord().

static int find_lambda_idx ( double  lambda,
double *  wave,
int  from,
int  to,
double  step 
) [static]

Definition at line 96 of file xsh_compute_response.c.

Referenced by xsh_interpolate_high_abs_regions().

static void find_lambda_idx_limit ( double  min,
double  max,
double *  spectrum,
int  from,
int  to,
double  step,
int *  if0,
int *  if1 
) [static]

Definition at line 193 of file xsh_compute_response.c.

References xsh_msg_dbg_high, and xsh_msg_dbg_low.

Referenced by xsh_response_calculate().

static int find_lambda_idx_max ( double  lambda,
double *  wave,
int  from,
int  to,
double  step 
) [static]

Definition at line 169 of file xsh_compute_response.c.

Referenced by xsh_interpolate_high_abs_regions2().

static int find_lambda_idx_min ( double  lambda,
double *  wave,
int  from,
int  to,
double  step 
) [static]

Definition at line 143 of file xsh_compute_response.c.

Referenced by xsh_interpolate_high_abs_regions2().

static xsh_star_flux_list* xsh_bspline_fit ( xsh_star_flux_list ref_std_star_list,
HIGH_ABS_REGION phigh,
xsh_instrument inst 
) [static]
double* xsh_bspline_fit_data ( double *  wave,
double *  flux,
const int  size,
HIGH_ABS_REGION phigh,
xsh_instrument inst,
const int  fit_region 
)
double* xsh_bspline_fit_data2 ( double *  wave,
double *  flux,
const int  size,
HIGH_ABS_REGION phigh,
xsh_instrument inst,
const int  fit_region 
)
double* xsh_bspline_interpolate_data_at_pos ( double *  wave,
double *  flux,
const int  size,
double *  pos,
const int  size_pos 
)

Definition at line 2407 of file xsh_compute_response.c.

Referenced by xsh_telluric_model_eval().

cpl_frame* xsh_compute_response ( cpl_frame *  spectrum_frame,
cpl_frame *  flux_std_star_cat_frame,
cpl_frame *  atmos_ext_frame,
cpl_frame *  high_abs_frame,
xsh_instrument instrument,
double  exptime 
)

Compute the instrument response using the rectified frame and the Standard star flux frame. The input should include also the Master Response Function and the Athmospheric Extinction Curve. Also should be produced the Efficiency frame.

Parameters:
spectrum_frame Rectified frame (1D spectrum)
flux_std_star_cat_frame Standard star flux catalog frame
atmos_ext_frame Atmospheric Extinction Frame
instrument Instrument strcture
exptime Exposure time
Returns:
Frame of the computed response

< computed response frame

< Std star flux

< Std star flux

< 1d spectrum

< 1d spectrum

Definition at line 3222 of file xsh_compute_response.c.

References check, check_msg, do_compute(), INTERPOL_WSTEP_NM, STAR_MATCH_DEPSILON, xsh_add_temporary_file(), XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, XSH_ATMOS_EXT, xsh_atmos_ext_list_free(), xsh_atmos_ext_list_load(), xsh_fill_high_abs_regions(), xsh_frame_product(), xsh_frame_sci_get_ra_dec_airmass(), xsh_free_frame(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_instrument_mode_tostring(), xsh_msg, xsh_msg_warning, xsh_parse_catalog_std_stars(), xsh_pfits_get_cdelt1(), xsh_pfits_get_crval1(), xsh_pfits_get_gain(), xsh_pfits_get_naxis1(), xsh_response_merge_obj_std_info(), xsh_spectrum_free(), xsh_spectrum_interpolate(), xsh_spectrum_load(), xsh_spectrum_resample(), xsh_spectrum_save(), xsh_star_flux_list_free(), xsh_star_flux_list_load(), and xsh_star_flux_list_save().

Referenced by xsh_util_integrate().

cpl_frame* xsh_compute_response2 ( cpl_frame *  obs_std_star,
cpl_frame *  flux_std_star_cat,
cpl_frame *  atmos_ext,
cpl_frame *  high_abs,
cpl_frame *  tell_mod_cat,
xsh_instrument instrument,
double  exptime,
const int  tell_corr 
)

Compute the instrument response using the rectified frame and the Standard star flux frame. The input should include also the Master Response Function and the Athmospheric Extinction Curve. Also should be produced the Efficiency frame.

Parameters:
obbs_std_star Rectified frame (1D spectrum)
flux_std_star_cat Standard star flux catalog frame
atmos_ext Atmospheric Extinction Frame
instrument Instrument structure
exptime Exposure time
tell_corr apply telluric correction
Returns:
Frame of the computed response

Definition at line 2874 of file xsh_compute_response.c.

References check, xsh_star_flux_list::flux, xsh_star_flux_list::lambda, xsh_star_flux_list::size, STAR_MATCH_DEPSILON, xsh_rv_ref_wave_param::wguess, xsh_add_temporary_file(), XSH_ARM_NIR, XSH_ARM_UVB, XSH_ASSURE_NOT_NULL, xsh_bspline_fit(), xsh_fill_high_abs_regions(), xsh_frame_product(), xsh_frame_sci_get_ra_dec_airmass(), xsh_free_frame(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_instrument_mode_tostring(), xsh_msg, xsh_msg_warning, xsh_obs_std_correct(), xsh_parse_catalog_std_stars(), xsh_pfits_get_cdelt1(), xsh_pfits_get_crval1(), xsh_pfits_get_naxis1(), xsh_response_merge_obj_std_info(), xsh_rv_ref_wave_init(), xsh_rv_ref_wave_param_create(), xsh_rv_ref_wave_param_destroy(), xsh_spectrum_interpolate_linear(), xsh_spectrum_load(), xsh_star_flux_list_divide(), xsh_star_flux_list_duplicate(), xsh_star_flux_list_extrapolate_wave_end(), xsh_star_flux_list_filter_lowpass(), xsh_star_flux_list_filter_median(), xsh_star_flux_list_free(), xsh_star_flux_list_load(), xsh_star_flux_list_load_spectrum(), xsh_star_flux_list_save(), xsh_star_flux_list_to_frame(), xsh_std_star_spectra_correlate(), xsh_table_shift_rv(), and xsh_telluric_model_eval().

Referenced by xsh_respon_slit_nod(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), and xsh_util_compute_response().

cpl_frame* xsh_compute_response_ord ( cpl_frame *  spectrum_frame,
cpl_frame *  flux_std_star_cat_frame,
cpl_frame *  atmos_ext_frame,
cpl_frame *  high_abs_win_frame,
xsh_instrument instrument,
double  exptime 
)

Compute the instrument response using the rectified frame and the Standard star flux frame. The input should include also the Master Response Function and the Athmospheric Extinction Curve. Also should be produced the Efficiency frame.

Parameters:
spectrum_frame Rectified frame (1D spectrum)
flux_std_star_cat_frame Standard star flux catalog frame
atmos_ext_frame Atmospheric Extinction Frame
instrument Instrument strcture
exptime Exposure time
Returns:
Frame of the computed response

< computed response frame

< Std star flux

< obj star flux

< 1d spectrum

< 1d spectrum

Definition at line 3408 of file xsh_compute_response.c.

References check, check_msg, do_compute(), INTERPOL_WSTEP_NM, STAR_MATCH_DEPSILON, xsh_add_temporary_file(), XSH_ARM_NIR, XSH_ASSURE_NOT_NULL, xsh_atmos_ext_list_free(), xsh_atmos_ext_list_load(), xsh_fill_high_abs_regions(), xsh_frame_product(), xsh_frame_sci_get_ra_dec_airmass(), xsh_free_frame(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_instrument_mode_tostring(), xsh_msg, xsh_msg_warning, xsh_parse_catalog_std_stars(), xsh_pfits_get_cdelt1(), xsh_pfits_get_crval1(), xsh_pfits_get_gain(), xsh_pfits_get_naxis1(), xsh_spectrum_free(), xsh_spectrum_interpolate(), xsh_spectrum_load_order(), xsh_spectrum_save_order(), xsh_star_flux_list_free(), xsh_star_flux_list_load(), and xsh_star_flux_list_save_order().

Referenced by xsh_respon_slit_nod(), xsh_respon_slit_offset(), and xsh_respon_slit_stare().

static cpl_error_code xsh_flux_integrate_and_corr_for_badpix ( int  npix_in_interval,
double *  flux_spectrum,
int *  qual_spectrum,
int  if0,
int  if1,
int  i,
double **  flux_added,
int *  npixels,
int *  nbad 
) [static]

Definition at line 590 of file xsh_compute_response.c.

References QFLAG_GOOD_PIXEL, and XSH_ASSURE_NOT_NULL_MSG.

Referenced by xsh_response_calculate().

static cpl_error_code xsh_interpolate_atm_ext ( xsh_star_flux_list star_list,
cpl_table *  atmos_ext_tab,
xsh_instrument instrument,
double **  atmos_lambda,
double **  atmos_K 
) [static]

Interpolate atms extinction at same sampling step as ref std star

Parameters:
star_list Table of ref star flux
[in] atmos_ext_tab atmospheric extinction table
[in] instrument instrument arm and lamp setting
[out] atmos_lambda interpolated wave array
[out] atmos_K interpolated atmospheric extinction K
Returns:
cpl error code

Definition at line 233 of file xsh_compute_response.c.

References xsh_star_flux_list::lambda, xsh_star_flux_list::size, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL_MSG, XSH_ATMOS_EXT_LIST_COLNAME_K, XSH_ATMOS_EXT_LIST_COLNAME_OLD, XSH_CALLOC, xsh_data_interpolate(), xsh_instrument_get_arm(), and xsh_msg_warning.

Referenced by do_compute(), and xsh_obs_std_correct().

static cpl_error_code xsh_interpolate_high_abs_regions ( xsh_star_flux_list star_list,
xsh_star_flux_list resp_list,
HIGH_ABS_REGION phigh 
) [static]

Interpolate high absorbtion regions

Parameters:
[in] star_list Table of ref star flux
[out] resp_list Table of response values
[in] HIGH_ABS_REGION pointer to hight abs regions
Returns:
cpl error code

Definition at line 304 of file xsh_compute_response.c.

References find_lambda_idx(), xsh_star_flux_list::flux, xsh_star_flux_list::lambda, HIGH_ABS_REGION::lambda_max, HIGH_ABS_REGION::lambda_min, xsh_star_flux_list::size, XSH_ASSURE_NOT_NULL_MSG, xsh_msg, xsh_msg_dbg_low, xsh_msg_dbg_medium, and xsh_msg_debug.

Referenced by do_compute().

static cpl_error_code xsh_interpolate_high_abs_regions2 ( xsh_star_flux_list star_list,
xsh_star_flux_list resp_list,
HIGH_ABS_REGION phigh 
) [static]
static cpl_error_code xsh_line_balance ( cpl_vector **  x,
cpl_vector **  y,
const double  ymax 
) [static]

Definition at line 1699 of file xsh_compute_response.c.

References size.

static xsh_star_flux_list* xsh_obs_std_correct ( cpl_frame *  obs_std_star,
xsh_star_flux_list ref_std_star_list,
cpl_frame *  atmos_ext,
HIGH_ABS_REGION phigh,
xsh_instrument instrument 
) [static]

Corrects the observed spectrum by gain, exptime, spectral bin size, atmospheric extinction, airmass. at the same wavelengths as the ones at which it is sampled the ref std star

Parameters:
obs_std_star Rectified frame (1D spectrum)
ref_std_star_list Ref std star structure
atmos_ext Atmospheric Extinction Frame
phigh pointer to high abs region structure
instrument Instrument structure
Returns:
structure with corrected observed std starspectrum

< 1d spectrum

Definition at line 1408 of file xsh_compute_response.c.

References check, check_msg, exptime, XSH_ARM_NIR, XSH_ATMOS_EXT, xsh_atmos_ext_list_free(), xsh_atmos_ext_list_load(), xsh_frame_sci_get_ra_dec_airmass(), XSH_FREE, xsh_free_propertylist(), xsh_free_table(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_interpolate_atm_ext(), xsh_msg_warning, xsh_pfits_get_airm_mean(), xsh_pfits_get_exptime(), xsh_pfits_get_gain(), xsh_spectrum_correct(), xsh_spectrum_free(), and xsh_spectrum_load().

Referenced by xsh_compute_response2().

static xsh_star_flux_list* xsh_response_calculate ( xsh_star_flux_list star_list,
xsh_star_flux_list **  obj_list,
xsh_spectrum spectrum,
cpl_table *  atmos_ext_tab,
XSH_ARM  the_arm,
double *  atmos_K,
double  airmass,
double  exptime,
double  gain 
) [static]
static cpl_error_code xsh_response_crea_ascii ( xsh_star_flux_list resp_list,
xsh_star_flux_list star_list,
double *  lambda_spectrum,
double *  flux_spectrum,
double *  flux_added 
) [static]

Integrate the flux on the same sampling that the star_list, taking into account the bad pixels, apply atmos correction, and divide by the star_list table.

Parameters:
resp_list Table of response values
star_list Table of ref star flux
lambda_spectrum array with lambda values
flux_spectrum array with flux values
flux_added array with integrated flux values
Returns:
cpl error code

Definition at line 538 of file xsh_compute_response.c.

References xsh_star_flux_list::flux, xsh_star_flux_list::lambda, xsh_star_flux_list::size, and XSH_ASSURE_NOT_NULL_MSG.

Referenced by xsh_response_calculate().

cpl_error_code xsh_response_merge_obj_std_info ( cpl_frame *  result,
xsh_star_flux_list star_list,
xsh_star_flux_list obj_list 
)
static cpl_error_code xsh_select_line_core ( cpl_vector *  wave,
cpl_vector *  flux,
const double  wguess,
const double  wrange,
cpl_vector **  xfit,
cpl_vector **  yfit 
) [static]

Definition at line 1661 of file xsh_compute_response.c.

References check, and size.

Referenced by xsh_std_star_spectra_correlate().

cpl_error_code xsh_sort_double_pairs ( double *  u1,
double *  u2,
cpl_size  n 
)

Sort an array u1 of doubles, and permute an array u2 in the same way as u1 is permuted.

Parameters:
[in,out] u1 Pointer to the first array.
[in,out] u2 Pointer to the second array.
n The common length of both arrays.
Returns:
CPL_ERROR_NONE or the appropriate error code.

Definition at line 1631 of file xsh_compute_response.c.

Referenced by xsh_std_star_spectra_correlate().

static cpl_error_code xsh_spectrum_correct ( xsh_star_flux_list star_list,
xsh_star_flux_list **  obj_list,
xsh_spectrum spectrum,
cpl_table *  atmos_ext_tab,
XSH_ARM  the_arm,
double *  atmos_K,
double  airmass,
double  exptime,
double  gain 
) [static]
static double xsh_std_star_spectra_correlate ( xsh_star_flux_list obs_std_star_list,
xsh_star_flux_list ref_std_star_list,
xsh_rv_ref_wave_param w 
) [static]
static cpl_error_code xsh_std_star_spectra_to_vector_range ( xsh_star_flux_list obs_std_star_list,
const double  wmin,
const double  wmax,
cpl_vector **  vec_wave,
cpl_vector **  vec_flux 
) [static]

Generated on 13 Mar 2013 for X-shooter Pipeline Reference Manual by  doxygen 1.6.1