X-shooter Pipeline Reference Manual 3.8.15
Data Structures | Macros | Functions | Variables
Tools: Miscellaneous Utilities

Data Structures

struct  FRAME_DATE_IDX
 
struct  data
 

Macros

#define CPL_TYPE   float
 
#define CPL_TYPE_T   CPL_TYPE_FLOAT
 
#define CPL_IMAGE_GET_DATA   cpl_image_get_data_float
 
#define CPL_IMAGE_GET_DATA_CONST   cpl_image_get_data_float_const
 
#define CPL_IMAGE_GET_MEDIAN   cpl_tools_get_median_float
 
#define XSH_DOUBLE_SWAP(a, b)   { register double t=(a);(a)=(b);(b)=t; }
 
#define XSH_FLOAT_SWAP(a, b)   { register float t=(a);(a)=(b);(b)=t; }
 
#define XSH_INT_SWAP(a, b)   { register int t=(a);(a)=(b);(b)=t; }
 
#define XSH_PIX_STACK_SIZE   50
 

Functions

void xsh_random_init (void)
 
int xsh_get_random_int_window (const int v1, const int v2)
 generates random integer values in range [v1,v2]
 
double xsh_get_random_double_window (const double v1, const double v2)
 generates random integer values in range [v1,v2]
 
cpl_image * xsh_imagelist_collapse_sigclip_iter_create (const cpl_imagelist *imlist, double sigma_low, double sigma_upp, const int niter)
 Average with sigma-clipping rejection an imagelist to a single image.
 
double xsh_hms2deg (const double hms)
 Convert a double from hours minute seconds to deg:
 
double xsh_sess2deg (const double sess)
 Convert a double from ssessagesimal to deg: 203049.197= 20:30:49.197 = 20.5136658333.
 
cpl_error_code xsh_check_input_is_unbinned (cpl_frame *in)
 Check if an input frame is not binned.
 
int xsh_fileutils_copy (const char *srcpath, const char *dstpath)
 
int xsh_fileutils_move (const char *srcpath, const char *dstpath)
 
const char * xsh_set_recipe_sky_file_prefix (char *rec_prefix)
 Set recipe sky frames prefix.
 
char * xsh_set_recipe_file_prefix (cpl_frameset *raw, const char *recipe)
 Set recipe frames prefix.
 
cpl_error_code xsh_set_cd_matrix (cpl_propertylist *plist)
 Set CD matrix.
 
cpl_error_code xsh_set_cd_matrix1d (cpl_propertylist *plist)
 Set CD matrix.
 
cpl_error_code xsh_set_cd_matrix2d (cpl_propertylist *plist)
 Set CD matrix.
 
cpl_error_code xsh_set_cd_matrix3d (cpl_propertylist *plist)
 Set CD matrix.
 
cpl_parameterlist * xsh_parameterlist_duplicate (const cpl_parameterlist *pin)
 Extract frames with given tag from frameset.
 
static void xsh_property_dump (cpl_property *property)
 Dump property.
 
cpl_frame * xsh_frameset_average (cpl_frameset *set, const char *tag)
 Dump propertylist.
 
cpl_frame * xsh_frameset_add (cpl_frameset *set, xsh_instrument *instr, const int decode_bp)
 coadd frames in a frameset
 
void xsh_plist_dump (cpl_propertylist *plist)
 Dump propertylist.
 
cpl_error_code xsh_frameset_dump (cpl_frameset *set)
 Dump frameset.
 
cpl_error_code xsh_frameset_dump_nod_info (cpl_frameset *set)
 Dump frameset nod info.
 
void xsh_init (void)
 Reset library state.
 
char * xsh_get_basename (const char *filename)
 Return base filename.
 
const char * xsh_get_license (void)
 Get the pipeline copyright and license.
 
cpl_error_code xsh_begin (cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
 Recipe initialization.
 
void xsh_add_temporary_file (const char *name)
 Add temporary file to temprary files list.
 
void xsh_free_temporary_files (void)
 Free temprary files list.
 
void xsh_add_product_file (const char *name)
 Add temporary file to temprary files list.
 
void xsh_free_product_files (void)
 Free temprary files list.
 
cpl_error_code xsh_end (const char *recipe_id, cpl_frameset *frames, cpl_parameterlist *parameters)
 Recipe termination.
 
cpl_error_code xsh_get_property_value (const cpl_propertylist *plist, const char *keyword, cpl_type keywordtype, void *result)
 Read a property value from a property list.
 
char * xsh_stringdup (const char *s)
 String duplication.
 
char * xsh_sdate_utc (time_t *now)
 
char * xsh_stringcat (const char *s1, const char *s2)
 String concatenation.
 
char * xsh_stringcat_3 (const char *s1, const char *s2, const char *s3)
 String concatenation.
 
char * xsh_stringcat_4 (const char *s1, const char *s2, const char *s3, const char *s4)
 String concatenation.
 
char * xsh_stringcat_5 (const char *s1, const char *s2, const char *s3, const char *s4, const char *s5)
 String concatenation.
 
char * xsh_stringcat_6 (const char *s1, const char *s2, const char *s3, const char *s4, const char *s5, const char *s6)
 String concatenation.
 
char * xsh_stringcat_any (const char *s,...)
 Concatenate an arbitrary number of strings.
 
int * xsh_sort (void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
 Sort an array and give is index table.
 
void xsh_reindex (double *data, int *idx, int size)
 TO BE DESCRIBED.
 
void xsh_reindex_float (float *data, int *idx, int size)
 TO BE DESCRIBED.
 
void xsh_reindex_int (int *data, int *idx, int size)
 TO BE DESCRIBED.
 
void xsh_free (const void *mem)
 Deallocate memory.
 
void xsh_free_image (cpl_image **i)
 Deallocate an image and set the pointer to NULL.
 
void xsh_free_table (cpl_table **t)
 Deallocate a table and set the pointer to NULL.
 
void xsh_free_mask (cpl_mask **m)
 Deallocate an image mask and set the pointer to NULL.
 
void xsh_free_imagelist (cpl_imagelist **i)
 Deallocate an image list and set the pointer to NULL.
 
void xsh_free_propertylist (cpl_propertylist **p)
 Deallocate a property list and set the pointer to NULL.
 
void xsh_free_polynomial (cpl_polynomial **p)
 Deallocate a polynomial and set the pointer to NULL.
 
void xsh_free_matrix (cpl_matrix **m)
 Deallocate a matrix and set the pointer to NULL.
 
void xsh_free_parameterlist (cpl_parameterlist **p)
 Deallocate a parameter list and set the pointer to NULL.
 
void xsh_free_parameter (cpl_parameter **p)
 Deallocate a parameter and set the pointer to NULL.
 
void xsh_free_frameset (cpl_frameset **f)
 Deallocate a frame set and set the pointer to NULL.
 
void xsh_free_frame (cpl_frame **f)
 Deallocate a frame and set the pointer to NULL.
 
void xsh_free_vector (cpl_vector **v)
 Deallocate a vector and set the pointer to NULL.
 
void xsh_free_array (cpl_array **m)
 Deallocate an array and set the pointer to NULL.
 
void xsh_free_stats (cpl_stats **s)
 Deallocate a stats object and set the pointer to NULL.
 
void xsh_unwrap_image (cpl_image **i)
 Unwrap an image and set the pointer to NULL.
 
void xsh_unwrap_vector (cpl_vector **v)
 Unwrap a vector and set the pointer to NULL.
 
void xsh_unwrap_array (cpl_array **a)
 Unwrap an array and set the pointer to NULL.
 
void xsh_unwrap_bivector_vectors (cpl_bivector **b)
 Unwrap a bi-vector and set the pointer to NULL.
 
void xsh_show_time (const char *comment)
 show time
 
void xsh_tools_get_statistics (double *tab, int size, double *median, double *mean, double *stdev)
 Compute median, stdev and mean for the tab.
 
cpl_error_code xsh_tools_sort_double (double *pix_arr, int n)
 Sort a double array.
 
cpl_error_code xsh_tools_sort_float (float *pix_arr, int n)
 Sort a float array.
 
cpl_error_code xsh_tools_sort_int (int *pix_arr, int n)
 Sort an integer array.
 
double xsh_tools_get_median_double (double *array, int size)
 Calculates the median value of an array of double.
 
int xsh_tools_running_median_1d_get_max (double *tab, int size, int wsize)
 get max of a list of doubles after running median
 
void xsh_tools_min_max (int size, double *tab, double *min, double *max)
 computes min & max in ab array
 
cpl_vector * xsh_tools_tchebitchev_poly_eval (int n, double X)
 Compute tchebitchev Tn(X) first coefficient for tchebitchev polynomial.
 
void xsh_tools_tchebitchev_transform_tab (int size, double *pos, double min, double max, double *tcheb_pos)
 computes Tchebitchev transformation
 
double xsh_tools_tchebitchev_transform (double pos, double min, double max)
 computes Tchebitchev transformation
 
double xsh_tools_tchebitchev_reverse_transform (double pos, double min, double max)
 computes reverse Tchebitchev transformation
 
void xsh_image_fit_spline (cpl_image *img, xsh_grid *grid)
 perform spline fit
 
void xsh_vector_fit_gaussian (cpl_vector *x, cpl_vector *y, XSH_GAUSSIAN_FIT *result)
 set debug level
 
int xsh_debug_level_set (int level)
 set debug level
 
int xsh_debug_level_get (void)
 get debug level
 
const char * xsh_debug_level_tostring (void)
 set debug level
 
int xsh_time_stamp_set (int ts)
 set timestamp
 
int xsh_time_stamp_get (void)
 get timestamp
 
void xsh_mem_dump (const char *prompt)
 
double convert_bin_to_data (double bin_data, int binning)
 
double convert_data_to_bin (double data, int binning)
 
static double date_to_double (const char *the_date)
 
static int compare_frame_date (const void *one, const void *two)
 
cpl_frameset * xsh_order_frameset_by_date (cpl_frameset *frameset)
 Order frameset by date.
 
polynomialxsh_polynomial_regression_2d (cpl_table *t, const char *X1, const char *X2, const char *Y, const char *sigmaY, int degree1, int degree2, const char *polynomial_fit, const char *residual_square, const char *variance_fit, double *mse, double *red_chisq, polynomial **variance, double kappa, double min_reject)
 Fit a 2d polynomial to three table columns.
 
int xsh_select_table_rows (cpl_table *t, const char *column, cpl_table_select_operator operator, double value)
 Select table rows.
 
int xsh_erase_table_rows (cpl_table *t, const char *column, cpl_table_select_operator operator, double value)
 Erase table rows.
 
cpl_frame * xsh_frame_inv (cpl_frame *in, const char *filename, xsh_instrument *instr)
 Inverse the flux of a PRE frame.
 
cpl_frame * xsh_frame_abs (cpl_frame *in, xsh_instrument *instr, cpl_frame **sign)
 Computes absolute value of a frame.
 
void xsh_frame_spectrum_save (cpl_frame *frm, const char *name_o)
 save an spectrum frame
 
void xsh_frame_image_save (cpl_frame *frm, const char *name_o)
 save an image frame
 
void xsh_frame_table_save (cpl_frame *frame, const char *name_o)
 Save a table frame.
 
cpl_frame * xsh_frame_mult (cpl_frame *in, xsh_instrument *instr, cpl_frame *sign)
 Computes product of two input frames.
 
cpl_error_code xsh_monitor_flux (cpl_frame *frm_ima, const cpl_frame *frm_tab, xsh_instrument *instrument, const char *qc_key_prefix)
 
Monitor Flux level along the orders traces given by an input table
 
cpl_error_code xsh_update_pheader_in_image_multi (cpl_frame *frame, const cpl_propertylist *pheader)
 Update FITS header.
 
double xsh_vector_get_err_median (cpl_vector *vect)
 Computes median error on a data set.
 
double xsh_vector_get_err_mean (cpl_vector *vect)
 Computes mean error on a data set.
 
long xsh_round_double (double x)
 Computes round(x)
 
int xsh_min_int (int x, int y)
 Minimum of two numbers.
 
int xsh_max_int (int x, int y)
 Maximum of two numbers.
 
double xsh_min_double (double x, double y)
 Minimum of two numbers.
 
double xsh_max_double (double x, double y)
 Maximum of two numbers.
 
double xsh_pow_int (double x, int y)
 Computes x^y.
 
const char * xsh_string_tolower (char *s)
 Convert all uppercase characters in a string into lowercase characters.
 
const char * xsh_string_toupper (char *s)
 Convert all lowercase characters in a string into uppercase characters.
 
double xsh_spline_hermite (double xp, const double *x, const double *y, int n, int *istart)
 Spline interpolation based on Hermite polynomials.
 
double xsh_spline_hermite_table (double xp, const cpl_table *t, const char *column_x, const char *column_y, int *istart)
 Spline interpolation based on Hermite polynomials.
 

Variables

static char ** TempFiles = NULL
 
static int NbTemp = 0
 
static char ** ProdFiles = NULL
 
static int NbProducts = 0
 
double FRAME_DATE_IDX::frame_date
 
int FRAME_DATE_IDX::frame_idx
 
cpl_frame * FRAME_DATE_IDX::frame
 
const char * FRAME_DATE_IDX::frame_name
 
size_t data::n
 
double * data::y
 
double * data::x
 
int data::deg
 

xsh_image_to_vector()

converts a fits image to a spectral vector

Parameters
spectrum1-D Fits image that should be converted to a spectral vector
Returns
spectral vector with length lx*ly
Note
input image is destroyed
cpl_vector * xsh_image_to_vector (cpl_image *spectrum)
 
cpl_image * xsh_vector_to_image (const cpl_vector *vector, cpl_type type)
 Convert a vector to a 1d image.
 
cpl_frame * xsh_util_multiply_by_response (cpl_frame *merged_sci, cpl_frame *response, const char *tag_o)
 Multiply input frame by response frame.
 
cpl_frame * xsh_util_multiply_by_response_ord (cpl_frame *extracted_sci, cpl_frame *response, const char *tag_o)
 Multiply input frame by response frame.
 
static cpl_error_code xsh_util_get_infsup (double *piw, double w, int i_start, int i_end, int *i_inf, int *i_sup)
 
static double xsh_spectrum_integrate (double *pif, double *piw, int i1_inf, int i1_sup, int i2_inf, int i2_sup, double wave, double wstep)
 
cpl_frame * xsh_spectrum_resample (cpl_frame *frame_inp, const double wstep, const double wmin, const double wmax, xsh_instrument *instr)
 resample a spectrum
 
cpl_frame * xsh_util_frameset_collapse_mean (cpl_frameset *set, xsh_instrument *instrument)
 Compute mean frame from a list of (IMAGE) framesets.
 
cpl_error_code xsh_normalize_spectrum_image_slice (const char *name_s, const char *tag_o, const int ext, const int bin_size, const double gain, const double exptime, const double airmass, const cpl_table *tbl_atm_ext)
 Normalize spectrum slice.
 
cpl_frame * xsh_normalize_spectrum (const cpl_frame *obj_frame, const cpl_frame *atm_ext_frame, cpl_boolean correct_binning, xsh_instrument *instrument, const char *tag_o)
 Normalize a spectrum.
 
cpl_frame * xsh_normalize_spectrum_ord (const cpl_frame *obj_frame, const cpl_frame *atm_ext_frame, cpl_boolean correct_binning, xsh_instrument *instrument, const char *tag_o)
 Normalize a spectrum.
 
cpl_image * xsh_normalize_spectrum_image (const cpl_image *spectrum, const cpl_image *spectrum_error, const cpl_propertylist *spectrum_header, const int bin_size, const double gain, const double exptime, const double airmass, const int n_traces, const cpl_table *atm_extinction, cpl_image **scaled_error)
 Normalize a spectrum.
 
static double xsh_iterpol_linear (double *data_x, double *data_y, int ndata, double x, int *i_inf, int *i_sup)
 
cpl_frame * xsh_spectrum_interpolate_linear (cpl_frame *table_frame, const double wstep, const double wmin, const double wmax)
 spectra interpolation
 
cpl_frame * xsh_spectrum_interpolate (cpl_frame *table_frame, const double wstep, const double wmin, const double wmax)
 spectra interpolation
 
void xsh_array_clip_mean (cpl_array *array, double kappa, int niter, double frac_min, double *mean, double *stdev)
 mean clip of an array
 
void xsh_array_clip_median (cpl_array *array, double kappa, int niter, double frac_min, double *median, double *stdev)
 median clip of an array
 
void xsh_array_clip_poly1d (cpl_vector *pos_vect, cpl_vector *val_vect, double kappa, int niter, double frac_min, int deg, cpl_polynomial **polyp, double *chisq, int **flagsp)
 clip outliers from a 1D poly fit
 
cpl_error_code xsh_rectify_params_set_defaults (cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_rectify_param *rectify_par)
 
cpl_error_code xsh_remove_crh_single_params_set_defaults (cpl_parameterlist *pars, const char *rec_id, xsh_instrument *inst, xsh_remove_crh_single_param *crh_single_par)
 
static int expb_f (const gsl_vector *x, void *data, gsl_vector *f)
 
static int expb_df (const gsl_vector *x, void *data, gsl_matrix *J)
 
static int expb_fdf (const gsl_vector *x, void *data, gsl_vector *f, gsl_matrix *J)
 
void xsh_gsl_init_gaussian_fit (cpl_vector *xpos_vect, cpl_vector *ypos_vect, double *init_par)
 
void xsh_gsl_fit_gaussian (cpl_vector *xpos_vect, cpl_vector *ypos_vect, int deg, double *params, double *errs, int *status)
 

xsh_xcorrelate

@memo Cross-correlation of two 1d signals.

Parameters
line_iThe reference signal.
width_iNumber of samples in reference signal.
line_tCandidate signal to compare.
width_tNumber of samples in candidate signal.
half_searchHalf-size of the search domain.
deltaOutput sinfo_correlation offset.
Returns
Maximum cross-correlation value as a double. @doc

Two signals are expected in input of this function: a reference signal (line_i) and a candidate signal (line_t) . They are expected to be roughly the same signal up to an offset (delta)

A cross-correlation is computed on 2*half_search+1 values. The maximum of likelihood is the maximum cross-correlation value between signals. The offset 'delta' corresponding to this position is returned.

Returns -100.0 in case of error. Normally, the cross-sinfo_correlation coefficient is normalized so it should stay between -1 and +1.

double * xsh_function1d_xcorrelate (double *line_i, int width_i, double *line_t, int width_t, int half_search, int normalise, double *xcorr_max, double *delta)
 
int raw_mjd_frame_compare (const cpl_frame *f1, const cpl_frame *f2)
 
cpl_error_code get_average_qc_from_raws (cpl_frameset *fset, xsh_instrument *instrument, cpl_propertylist *qclist)
 
cpl_error_code get_chromatic_eff (cpl_frame *eff, cpl_propertylist *qclist)
 
cpl_error_code calc_curve_qc (cpl_image *im, xsh_instrument *instrument, cpl_propertylist *qclist)
 
static int qc_linfunc (const double x[], const double p[], double *f)
 
static int qc_dlinfunc (const double x[], const double p[], double f[])
 
cpl_error_code calc_flat_slit_qc (cpl_image *im, int xa1, int xa2, cpl_propertylist *qclist)
 
cpl_error_code calc_resp_qc (cpl_table *mtab, cpl_table *rtab, xsh_instrument *instrument, int lower, int upper, const char *label, cpl_propertylist *qclist)
 

xsh_histogram

@memo computes histogram

Parameters
datainput data table
nbinsinput size of histogram bin
mininput min data to be considered in histogram
maxinput max data to be considered in histogram
histoutput histogram: table with results:

H: histogram

X: array of data values corresponding to the center of each bin

Xmean: 1D array corresponding to the mean of the data values entering

each histogram bin Returns in case of succes -1 else. @doc

 Compute the histogram with the IDL intrinsic function HISTOGRAM, using
 the input options specified by the parameters Dmin, Dmax, Bin. All
 the computations are performed in floating-point arithmetics.
 Then compute arrays of values corresponding to each histogram bin,
 useful for plots, fitting, etc.
cpl_table * xsh_histogram (const cpl_table *data, const char *cname, const int nbins, const double min, const double max)
 
static int xsh_wavecal_find_nearest (const cpl_table *line_refer, const char *col_ref, double lambda, int lo, int hi)
 Find best matching catalogue wavelength.
 
static cpl_error_code xsh_wavecal_qclog_compute (cpl_table *temp, cpl_propertylist **header_check, const char *element, const double exptime)
 computes intmon QC log
 
static cpl_table * xsh_table_select_matching_waves (cpl_table *table_intmon, const char *col_wave_intmon, cpl_table *table_check, const char *col_wave_intcheck, const double exptime)
 Match reference and actual table via wavelength column.
 
static cpl_error_code xsh_wavecal_qclog_element (cpl_table *table_intmon, cpl_table *table_check, const double exptime, const char *atom_name, cpl_propertylist **header_check)
 computes intmon QC log
 
cpl_error_code xsh_wavecal_qclog_intmon (cpl_frame *line_check, const cpl_frame *line_intmon, const double exptime, xsh_instrument *inst)
 computes intmon QC log
 
cpl_error_code xsh_get_table_value (const cpl_table *table, const char *colname, cpl_type coltype, int i, void *result)
 Read a table value from a fits table.
 
cpl_error_code xsh_sort_table_1 (cpl_table *t, const char *column, cpl_boolean reverse)
 Sort a table by one column.
 
cpl_error_code xsh_sort_table_2 (cpl_table *t, const char *column1, const char *column2, cpl_boolean reverse1, cpl_boolean reverse2)
 Sort a table by two columns.
 
cpl_error_code xsh_sort_table_3 (cpl_table *t, const char *column1, const char *column2, const char *column3, cpl_boolean reverse1, cpl_boolean reverse2, cpl_boolean reverse3)
 Sort a table by two columns.
 
double xsh_data_interpolate (double wav, int nrow, double *pw, double *pe)
 Interpolate data points.
 
double xsh_table_interpolate (cpl_table *tbl, double wav, const char *colx, const char *coly)
 Interpolate table columns.
 
static cpl_error_code xsh_table_monitor_flux_qc (cpl_table *table, const double ws, const double we, const char *prefix, const int index, cpl_propertylist **header)
 Computes statistics on spectrum for QC.
 
static cpl_propertylist * xsh_frame_table_monitor_flux_qc_ext (cpl_table *table, const char *colw, const char *colf, const char *prefix, xsh_instrument *instrument)
 Computes statistics on spectrum for QC.
 
cpl_error_code xsh_frame_table_monitor_flux_qc (cpl_frame *frm, const char *colw, const char *colf, const char *prefix, xsh_instrument *instrument)
 Computes statistics on spectrum for QC.
 
cpl_error_code xsh_table_merge_clean_and_resid_tabs (cpl_frame *frm_resid, cpl_frame *frm_clean)
 
cpl_table * xsh_table_shift_rv (cpl_table *orig, const char *col_wave, const double offset)
 

Detailed Description

This module is for the stuff that don't fit anywhere else. It should be kept as small as possible.

Macro Definition Documentation

◆ CPL_IMAGE_GET_DATA

#define CPL_IMAGE_GET_DATA   cpl_image_get_data_float

Definition at line 101 of file xsh_utils.c.

◆ CPL_IMAGE_GET_DATA_CONST

#define CPL_IMAGE_GET_DATA_CONST   cpl_image_get_data_float_const

Definition at line 102 of file xsh_utils.c.

◆ CPL_IMAGE_GET_MEDIAN

#define CPL_IMAGE_GET_MEDIAN   cpl_tools_get_median_float

Definition at line 103 of file xsh_utils.c.

◆ CPL_TYPE

#define CPL_TYPE   float

Definition at line 99 of file xsh_utils.c.

◆ CPL_TYPE_T

#define CPL_TYPE_T   CPL_TYPE_FLOAT

Definition at line 100 of file xsh_utils.c.

◆ XSH_DOUBLE_SWAP

#define XSH_DOUBLE_SWAP (   a,
 
)    { register double t=(a);(a)=(b);(b)=t; }

Definition at line 2403 of file xsh_utils.c.

◆ XSH_FLOAT_SWAP

#define XSH_FLOAT_SWAP (   a,
 
)    { register float t=(a);(a)=(b);(b)=t; }

Definition at line 2404 of file xsh_utils.c.

◆ XSH_INT_SWAP

#define XSH_INT_SWAP (   a,
 
)    { register int t=(a);(a)=(b);(b)=t; }

Definition at line 2405 of file xsh_utils.c.

◆ XSH_PIX_STACK_SIZE

#define XSH_PIX_STACK_SIZE   50

Definition at line 2407 of file xsh_utils.c.

Function Documentation

◆ calc_curve_qc()

cpl_error_code calc_curve_qc ( cpl_image *  im,
xsh_instrument instrument,
cpl_propertylist *  qclist 
)

◆ calc_flat_slit_qc()

cpl_error_code calc_flat_slit_qc ( cpl_image *  im,
int  xa1,
int  xa2,
cpl_propertylist *  qclist 
)

Definition at line 7429 of file xsh_utils.c.

References qc_dlinfunc(), and qc_linfunc().

Referenced by xsh_qc_write_to_flat().

◆ calc_resp_qc()

cpl_error_code calc_resp_qc ( cpl_table *  mtab,
cpl_table *  rtab,
xsh_instrument instrument,
int  lower,
int  upper,
const char *  label,
cpl_propertylist *  qclist 
)

◆ compare_frame_date()

static int compare_frame_date ( const void *  one,
const void *  two 
)
static

Definition at line 3284 of file xsh_utils.c.

References first.

Referenced by xsh_order_frameset_by_date().

◆ convert_bin_to_data()

double convert_bin_to_data ( double  bin_data,
int  binning 
)

Definition at line 3228 of file xsh_utils.c.

Referenced by xsh_dispersol_list_eval(), and xsh_order_list_eval().

◆ convert_data_to_bin()

double convert_data_to_bin ( double  data,
int  binning 
)

◆ date_to_double()

static double date_to_double ( const char *  the_date)
static

Definition at line 3255 of file xsh_utils.c.

References mm, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_order_frameset_by_date().

◆ expb_df()

static int expb_df ( const gsl_vector *  x,
void *  data,
gsl_matrix *  J 
)
static

Definition at line 6788 of file xsh_utils.c.

References data::deg, M_PI, n, sigma, data::t, and x.

Referenced by expb_fdf(), and xsh_gsl_fit_gaussian().

◆ expb_f()

static int expb_f ( const gsl_vector *  x,
void *  data,
gsl_vector *  f 
)
static

Definition at line 6757 of file xsh_utils.c.

References M_PI, n, sigma, data::t, x, and y.

Referenced by expb_fdf(), and xsh_gsl_fit_gaussian().

◆ expb_fdf()

static int expb_fdf ( const gsl_vector *  x,
void *  data,
gsl_vector *  f,
gsl_matrix *  J 
)
static

Definition at line 6850 of file xsh_utils.c.

References expb_df(), expb_f(), and x.

Referenced by xsh_gsl_fit_gaussian().

◆ get_average_qc_from_raws()

cpl_error_code get_average_qc_from_raws ( cpl_frameset *  fset,
xsh_instrument instrument,
cpl_propertylist *  qclist 
)

◆ get_chromatic_eff()

cpl_error_code get_chromatic_eff ( cpl_frame *  eff,
cpl_propertylist *  qclist 
)

◆ qc_dlinfunc()

static int qc_dlinfunc ( const double  x[],
const double  p[],
double  f[] 
)
static

Definition at line 7417 of file xsh_utils.c.

References x.

Referenced by calc_flat_slit_qc(), and calc_resp_qc().

◆ qc_linfunc()

static int qc_linfunc ( const double  x[],
const double  p[],
double *  f 
)
static

Definition at line 7408 of file xsh_utils.c.

References x.

Referenced by calc_flat_slit_qc(), and calc_resp_qc().

◆ raw_mjd_frame_compare()

int raw_mjd_frame_compare ( const cpl_frame *  f1,
const cpl_frame *  f2 
)

Definition at line 7196 of file xsh_utils.c.

Referenced by get_average_qc_from_raws().

◆ xsh_add_product_file()

void xsh_add_product_file ( const char *  name)

◆ xsh_add_temporary_file()

void xsh_add_temporary_file ( const char *  name)

Add temporary file to temprary files list.

Parameters
[in]nameThe name of the file

Definition at line 1432 of file xsh_utils.c.

References NbTemp, and TempFiles.

Referenced by xsh_2dmap(), xsh_add_product_image(), xsh_add_product_imagelist(), xsh_add_product_orders_spectrum(), xsh_afcthetab_create(), xsh_badpixelmap_coadd(), xsh_badpixelmap_crea_master_from_bpmap(), xsh_badpixelmap_extract(), xsh_build_ifu_cube(), xsh_build_ifu_map(), xsh_check_load_master_bpmap(), xsh_check_remove_crh_single(), xsh_check_subtract_dark(), xsh_check_subtract_sky_single(), xsh_combine_nod(), xsh_compute_absorp(), xsh_compute_noise_map(), xsh_compute_resampling_accuracy(), xsh_compute_response(), xsh_compute_response2(), xsh_compute_response_ord(), xsh_compute_shift_ifu_slitlet(), xsh_compute_wavelength_resampling_accuracy(), xsh_create_dispersol_physmod(), xsh_detect_arclines(), xsh_detect_arclines_dan(), xsh_extract(), xsh_extract_clean(), xsh_flux_calibrate1D(), xsh_flux_calibrate2D(), xsh_follow_arclines(), xsh_frame_abs(), xsh_frame_build_sky_map(), xsh_frame_image_div_by_fct(), xsh_frame_image_mult_by_fct(), xsh_frame_nir_tab_chop_Kband(), xsh_frameset_crh_single(), xsh_frameset_mflat_divide(), xsh_get_crh_frame(), xsh_get_master_dark_nir_via_noise(), xsh_linear(), xsh_linetilt_list_save(), xsh_localize_ifu_slitlet(), xsh_localize_obj(), xsh_model_maps_create(), xsh_model_temperature_update_frame(), xsh_nod_group_by_reloff(), xsh_nod_group_by_reloff2(), xsh_nod_median_correct_list_per_wavelength(), xsh_nod_rectify_and_shift_with_key(), xsh_opt_extract_orders(), xsh_order_split_qth_d2(), xsh_pre_frame_subtract(), xsh_pre_save(), xsh_predict(), xsh_preoverscan_corr(), xsh_rec_list_qc(), xsh_rec_list_save_table(), xsh_rectify_orders(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_response_calculate(), xsh_scired_ifu_stare(), xsh_scired_slit_nod_accurate(), xsh_scired_slit_nod_fast(), xsh_scired_slit_offset(), xsh_scired_slit_stare(), xsh_shift(), xsh_shift_tab_save(), xsh_slit_stare_correct_crh_and_sky(), xsh_spectrum_correct(), xsh_spectrum_interpolate(), xsh_spectrum_interpolate_linear(), xsh_spectrum_resample(), xsh_subtract_background(), xsh_subtract_nir_on_off(), xsh_subtract_sky_nod(), xsh_subtract_sky_single(), xsh_telluric_model_eval(), and xsh_util_frameset_collapse_mean().

◆ xsh_array_clip_mean()

void xsh_array_clip_mean ( cpl_array *  array,
double  kappa,
int  niter,
double  frac_min,
double *  mean,
double *  stdev 
)

mean clip of an array

Parameters
arrayarray of values to be clipped
kappakappa value of kappa sigma clip
niternumber of iterations
frac_minminimum accepable fraction of good pixels
[out]meanmean of values after clipping
[out]stdevsigma of values after clipping

Definition at line 6415 of file xsh_utils.c.

References check, kappa, niter, sigma, size, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_msg, and xsh_msg_dbg_medium.

◆ xsh_array_clip_median()

void xsh_array_clip_median ( cpl_array *  array,
double  kappa,
int  niter,
double  frac_min,
double *  median,
double *  stdev 
)

median clip of an array

Parameters
arrayarray of values to be clipped
kappakappa value of kappa sigma clip
niternumber of iterations
frac_minminimum accepable fraction of good pixels
[out]medianmedian of values after clipping
[out]stdevsigma of values after clipping

Definition at line 6493 of file xsh_utils.c.

References check, kappa, niter, sigma, size, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, and xsh_msg.

Referenced by compute_specres().

◆ xsh_array_clip_poly1d()

void xsh_array_clip_poly1d ( cpl_vector *  pos_vect,
cpl_vector *  val_vect,
double  kappa,
int  niter,
double  frac_min,
int  deg,
cpl_polynomial **  polyp,
double *  chisq,
int **  flagsp 
)

clip outliers from a 1D poly fit

Parameters
pos_vectvector with positions
val_vectvector with values
kappakappa value of kappa sigma clip
niternumber of iterations
frac_minminimum accepable fraction of good pixels
degdegree of polynomial
polyppolynomial
chisqchi square
flagspflag parameter

Definition at line 6568 of file xsh_utils.c.

References check, kappa, niter, sigma, size, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_free_polynomial(), xsh_msg, xsh_msg_dbg_medium, xsh_polynomial_fit_1d_create(), and xsh_unwrap_vector().

Referenced by find_tilt(), and xsh_image_create_model_image().

◆ xsh_begin()

cpl_error_code xsh_begin ( cpl_frameset *  frames,
const cpl_parameterlist *  parameters,
xsh_instrument **  instrument,
cpl_frameset **  raws,
cpl_frameset **  calib,
const char *  tag_list[],
int  tag_list_size,
const char *  recipe_id,
unsigned int  binary_version,
const char *  short_descr 
)

Recipe initialization.

Parameters
framesThe input frame set
parametersThe input parameter list
instrumentPointer to the instrument structure pointer
rawsPointer to RAW Frameset
calibPointer to CALIB Frameset
tag_listList of valid tags for the recipe
tag_list_sizesize of List of valid tags for the recipe
recipe_idName of the recipe, e.g. xsh_mbias
binary_versionRecipe version (possibly different from pipeline version)
short_descrA short description of what the recipe does
Returns
CPL_ERROR_NONE iff OK

This function should be called at the beginning of every recipe. It takes care of the mandatory tasks that are common for all recipes before the beginning of the data reduction.

  • makes sure that the CPL library are up to date, and prints a warning message if not,
  • defines the group of all input frames (see xsh_dfs_set_groups()), and
  • prints the input frame set.

See also xsh_end().

Definition at line 1244 of file xsh_utils.c.

References assure, check, instrument, MAXIMUM, XSH_ARM_NIR, XSH_ASSURE_NOT_ILLEGAL_MSG, XSH_ASSURE_NOT_NULL, xsh_calib_nir_corr_if_JH(), xsh_debug_level_tostring(), xsh_dfs_files_dont_exist(), xsh_dfs_filter(), xsh_dfs_set_groups(), xsh_dfs_split_in_group(), xsh_instrument_get_arm(), xsh_instrument_nir_corr_if_JH(), xsh_instrument_nir_corr_if_spectral_format_is_JH(), xsh_instrument_set_decode_bp(), xsh_instrument_set_recipe_id(), xsh_msg, XSH_NEW_FRAMESET, xsh_parameters_debug_level_get(), xsh_parameters_find(), xsh_parameters_get_temporary(), xsh_print_cpl_frameset(), and xsh_stringcat_4().

Referenced by xsh_2dmap(), xsh_absorp(), xsh_cfg_recover_driver(), xsh_flexcomp(), xsh_geom_ifu(), xsh_linear(), xsh_lingain(), xsh_mbias(), xsh_mdark(), xsh_mflat(), xsh_orderpos(), xsh_predict(), xsh_respon_slit_nod(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_scired_slit_nod(), xsh_scired_slit_offset(), xsh_scired_slit_stare(), xsh_util_afc(), xsh_util_apply_response(), xsh_util_bpmap_coadd(), xsh_util_bpmap_nl_raw2pre(), xsh_util_compute_response(), xsh_util_crh_single(), xsh_util_efficiency1d(), xsh_util_efficiency2d(), xsh_util_guess_xy(), xsh_util_ifu_build_cube(), xsh_util_ima_arith(), xsh_util_integrate(), xsh_util_physmod(), and xsh_wavecal().

◆ xsh_check_input_is_unbinned()

cpl_error_code xsh_check_input_is_unbinned ( cpl_frame *  in)

Check if an input frame is not binned.

Parameters
ininput frame
Returns
cpl error code

Definition at line 375 of file xsh_utils.c.

References binx, biny, xsh_free_propertylist(), xsh_msg_error, xsh_pfits_get_binx(), and xsh_pfits_get_biny().

Referenced by xsh_2dmap(), xsh_orderpos(), and xsh_predict().

◆ xsh_data_interpolate()

double xsh_data_interpolate ( double  wav,
int  nrow,
double *  pw,
double *  pe 
)

Interpolate data points.

Parameters
wavvalue at which is desired an interpolated value
nrownumber of data points
pwpointer to wave array
pepointer to efficiency array
Returns
Interpolated data points

Definition at line 649 of file xsh_utils_table.c.

References y.

Referenced by fill_rectified(), xsh_compute_shift_ifu_slitlet(), xsh_interpolate_atm_ext(), xsh_localize_ifu_slitlet(), and xsh_table_interpolate().

◆ xsh_debug_level_get()

int xsh_debug_level_get ( void  )

◆ xsh_debug_level_set()

int xsh_debug_level_set ( int  level)

set debug level

Parameters
levelerror level
Returns
debug level

Definition at line 3125 of file xsh_utils.c.

References XshDebugLevel.

Referenced by HandleOptions(), main(), xsh_model_reduce(), and xsh_parameters_debug_level_get().

◆ xsh_debug_level_tostring()

const char * xsh_debug_level_tostring ( void  )

set debug level

Returns
string equivalent to debug level

Definition at line 3155 of file xsh_utils.c.

References XSH_DEBUG_LEVEL_HIGH, XSH_DEBUG_LEVEL_LOW, XSH_DEBUG_LEVEL_MEDIUM, XSH_DEBUG_LEVEL_NONE, and XshDebugLevel.

Referenced by xsh_begin().

◆ xsh_end()

cpl_error_code xsh_end ( const char *  recipe_id,
cpl_frameset *  frames,
cpl_parameterlist *  parameters 
)

Recipe termination.

Parameters
recipe_idName of calling recipe
framesThe output frame set
parametersThe input parameter list
Returns
CPL_ERROR_NONE iff OK

This function is called at the end of every recipe. The output frame set is printed, and the number of warnings produced by the recipe is summarized.

See also xsh_begin().

Definition at line 1519 of file xsh_utils.c.

References NbTemp, TempFiles, xsh_free_product_files(), xsh_free_temporary_files(), xsh_msg, xsh_msg_get_warnings(), xsh_msg_warning, xsh_parameters_get_temporary(), and xsh_print_cpl_frame().

Referenced by xsh_2dmap(), xsh_absorp(), xsh_cfg_recover_last_step(), xsh_flexcomp(), xsh_geom_ifu(), xsh_linear(), xsh_mbias(), xsh_mdark(), xsh_mflat(), xsh_orderpos(), xsh_predict(), xsh_respon_slit_nod(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_scired_slit_nod(), xsh_scired_slit_offset(), xsh_scired_slit_stare(), xsh_util_ifu_build_cube(), and xsh_wavecal().

◆ xsh_erase_table_rows()

int xsh_erase_table_rows ( cpl_table *  t,
const char *  column,
cpl_table_select_operator  operator,
double  value 
)

Erase table rows.

Parameters
tTable
columnColumn name
operatorLogical operator
valueValue used for comparison
Returns
Number of erased rows

A table row is erased if and only if the value in column is in the relation operator to the specified value. The specified column must have type CPL_TYPE_DOUBLE or CPL_TYPE_INT. If integer, the integer nearest to value is used for the comparison.

The table selection flags are reset.

Also see cpl_table_and_selected_<type>().

Definition at line 3849 of file xsh_utils.c.

References assure, check_msg, and xsh_select_table_rows().

Referenced by xsh_polynomial_regression_2d().

◆ xsh_fileutils_copy()

int xsh_fileutils_copy ( const char *  srcpath,
const char *  dstpath 
)

Definition at line 429 of file xsh_utils.c.

References DEV_BLOCKSIZE.

Referenced by xsh_fileutils_move().

◆ xsh_fileutils_move()

int xsh_fileutils_move ( const char *  srcpath,
const char *  dstpath 
)

Definition at line 534 of file xsh_utils.c.

References xsh_fileutils_copy().

Referenced by xsh_add_product_table().

◆ xsh_frame_abs()

cpl_frame * xsh_frame_abs ( cpl_frame *  in,
xsh_instrument instr,
cpl_frame **  sign 
)

Computes absolute value of a frame.

Parameters
ininput frame
instrinstrument setting
signinput frame
Returns
||in||

Definition at line 3911 of file xsh_utils.c.

References check, xsh_add_temporary_file(), XSH_ASSURE_NOT_NULL, xsh_free_frame(), xsh_free_image(), xsh_pre_abs(), xsh_pre_free(), xsh_pre_load(), and xsh_pre_save().

Referenced by xsh_abs_remove_crh_single().

◆ xsh_frame_image_save()

void xsh_frame_image_save ( cpl_frame *  frm,
const char *  name_o 
)

save an image frame

Parameters
frmframe
name_ooutput filename
Returns
void

Definition at line 3983 of file xsh_utils.c.

References xsh_free_image(), and xsh_free_propertylist().

Referenced by xsh_slit_stare_correct_crh_and_sky().

◆ xsh_frame_inv()

cpl_frame * xsh_frame_inv ( cpl_frame *  in,
const char *  filename,
xsh_instrument instr 
)

Inverse the flux of a PRE frame.

Parameters
inThe pre frame to inverse
filenamefilename
instrinstrument setting
Returns
The new inverse flux frame

Definition at line 3878 of file xsh_utils.c.

References check, XSH_ASSURE_NOT_NULL, xsh_free_frame(), xsh_pre_free(), xsh_pre_load(), xsh_pre_multiply_scalar(), and xsh_pre_save().

◆ xsh_frame_mult()

cpl_frame * xsh_frame_mult ( cpl_frame *  in,
xsh_instrument instr,
cpl_frame *  sign 
)

Computes product of two input frames.

Parameters
ininput frame
instrinstrument structure
signinput frame
Returns
in*sign

Definition at line 4061 of file xsh_utils.c.

References check, XSH_ASSURE_NOT_NULL, xsh_free_frame(), xsh_free_image(), xsh_pre_free(), xsh_pre_load(), xsh_pre_multiply_image(), and xsh_pre_save().

Referenced by xsh_abs_remove_crh_single().

◆ xsh_frame_spectrum_save()

void xsh_frame_spectrum_save ( cpl_frame *  frm,
const char *  name_o 
)

save an spectrum frame

Parameters
frmframe
name_ooutput filename
Returns
void

Definition at line 3959 of file xsh_utils.c.

References s, xsh_free_frame(), xsh_spectrum_free(), xsh_spectrum_load(), and xsh_spectrum_save().

Referenced by xsh_compute_response2().

◆ xsh_frame_table_monitor_flux_qc()

cpl_error_code xsh_frame_table_monitor_flux_qc ( cpl_frame *  frm,
const char *  colw,
const char *  colf,
const char *  prefix,
xsh_instrument instrument 
)

Computes statistics on spectrum for QC.

Parameters
[in]frmspectrum frame
[in]colwwavelength column name
[in]colfflux column name
[in]prefixprefix of QC parameter
[in]instrumentinstrument arm setting
Returns
CPL error code

Definition at line 856 of file xsh_utils_table.c.

References check, instrument, XSH_ASSURE_NOT_NULL_MSG, xsh_frame_table_monitor_flux_qc_ext(), xsh_free_propertylist(), and xsh_free_table().

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

◆ xsh_frame_table_monitor_flux_qc_ext()

static cpl_propertylist * xsh_frame_table_monitor_flux_qc_ext ( cpl_table *  table,
const char *  colw,
const char *  colf,
const char *  prefix,
xsh_instrument instrument 
)
static

Computes statistics on spectrum for QC.

Parameters
[in]tableinput table describing spectrum
[in]colwwavelength column name
[in]colfflux column name
[in]prefixprefix of QC parameter
[in]instrumentinstrument arm setting
Returns
CPL error code

Definition at line 799 of file xsh_utils_table.c.

References check, instrument, XSH_ARM_NIR, XSH_ARM_UVB, XSH_ARM_VIS, XSH_ASSURE_NOT_NULL_MSG, xsh_instrument_get_arm(), and xsh_table_monitor_flux_qc().

Referenced by xsh_frame_table_monitor_flux_qc().

◆ xsh_frame_table_save()

void xsh_frame_table_save ( cpl_frame *  frame,
const char *  name_o 
)

Save a table frame.

Parameters
frameinput table frame
name_ofile name
Returns
void

Definition at line 4017 of file xsh_utils.c.

References check, xsh_free_propertylist(), and xsh_free_table().

◆ xsh_frameset_add()

cpl_frame * xsh_frameset_add ( cpl_frameset *  set,
xsh_instrument instr,
const int  decode_bp 
)

coadd frames in a frameset

Parameters
setinput frameset
instrinstrument arm setting
Returns
coadded frame (with error and qualifier propagation)

Definition at line 921 of file xsh_utils.c.

References check, xsh_pre::nx, nx, xsh_pre::ny, ny, QFLAG_GOOD_PIXEL, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_free_frame(), xsh_pre_duplicate(), xsh_pre_free(), xsh_pre_get_data(), xsh_pre_get_errs(), xsh_pre_get_qual(), xsh_pre_load(), and xsh_pre_save().

◆ xsh_frameset_average()

cpl_frame * xsh_frameset_average ( cpl_frameset *  set,
const char *  tag 
)

Dump propertylist.

Parameters
setthe input frameset
tagthe output frame tag
Returns
the frame product

Definition at line 875 of file xsh_utils.c.

References check, size, xsh_frame_product(), xsh_free_image(), xsh_free_imagelist(), and xsh_free_propertylist().

◆ xsh_frameset_dump()

cpl_error_code xsh_frameset_dump ( cpl_frameset *  set)

Dump frameset.

Parameters
setthe input frameset
Returns
cpl_error_code

Definition at line 1054 of file xsh_utils.c.

References n, and xsh_msg.

◆ xsh_frameset_dump_nod_info()

cpl_error_code xsh_frameset_dump_nod_info ( cpl_frameset *  set)

Dump frameset nod info.

Parameters
setthe input frameset
Returns
cpl_error_code

Definition at line 1088 of file xsh_utils.c.

References n, xsh_free_propertylist(), xsh_msg, xsh_msg_warning, XSH_NOD_CUMULATIVE_OFFSETY, XSH_NOD_JITTER_BOX, XSH_NOD_THROW, xsh_pfits_get_cumoffsety(), xsh_pfits_get_nod_jitterwidth(), and xsh_pfits_get_nodthrow().

◆ xsh_free()

void xsh_free ( const void *  mem)

◆ xsh_free_array()

void xsh_free_array ( cpl_array **  m)

Deallocate an array and set the pointer to NULL.

Parameters
mArray to deallocate

Definition at line 2299 of file xsh_utils.c.

References m.

Referenced by compute_specres(), xsh_cfg_recover_pattern_match(), xsh_image_mflat_detect_blemishes(), xsh_rec_list1D_save_as_tab(), xsh_rec_list_save(), xsh_rec_list_save2(), and xsh_rec_list_save_table().

◆ xsh_free_frame()

void xsh_free_frame ( cpl_frame **  f)

Deallocate a frame and set the pointer to NULL.

Parameters
fFrame to deallocate

Definition at line 2269 of file xsh_utils.c.

Referenced by analyse_localization(), calculate_qc_parameters(), create_resid_tab(), create_zero_rectify(), main(), save_pre_frame(), shift_with_kw(), test_xsh_create_list_from_image(), xsh_2dmap(), xsh_abs_remove_crh_single(), xsh_absorp(), xsh_add_product_orders_spectrum(), xsh_add_product_pre(), xsh_add_product_pre_3d(), xsh_add_product_spectrum(), xsh_add_product_vector(), xsh_afcthetab_create(), xsh_badpixelmap_extract(), xsh_blaze_image(), xsh_build_ifu_cube(), xsh_cfg_recover_last_step(), xsh_cfg_recover_measure_line_xy(), xsh_check_load_master_bpmap(), xsh_check_subtract_sky_single(), xsh_combine_nod(), xsh_compute_absorp(), xsh_compute_resampling_accuracy(), xsh_compute_response(), xsh_compute_response2(), xsh_compute_response_ord(), xsh_compute_slice_dist(), xsh_compute_wavelength_resampling_accuracy(), xsh_create_dispersol_physmod(), xsh_create_master_bias2(), xsh_create_master_dark(), xsh_create_master_dark_bpmap(), xsh_cube(), xsh_dfs_split_nir(), xsh_dfs_split_offset(), xsh_dfs_split_qth_d2(), xsh_dispersol_list_to_slitmap(), xsh_dispersol_list_to_wavemap(), xsh_divide_by_blaze(), xsh_divide_flat(), xsh_flexcomp(), xsh_flexcor(), xsh_flux_calibrate1D(), xsh_flux_calibrate2D(), xsh_frame_abs(), xsh_frame_inv(), xsh_frame_mult(), xsh_frame_product(), xsh_frame_qual_update(), xsh_frame_spectrum_save(), xsh_frameset_add(), xsh_frameset_average_pre(), xsh_gain(), xsh_geom_ifu(), xsh_get_master_dark_opt(), xsh_image_mflat_detect_blemishes(), xsh_linear(), xsh_lingain(), xsh_localize_obj(), xsh_mark_tell(), xsh_mbias(), xsh_mdark(), xsh_mflat(), xsh_model_first_anneal_save(), xsh_model_pipe_anneal(), xsh_model_reduce(), xsh_model_spectralformat_create(), xsh_model_THE_create(), xsh_monitor_spectrum1D_extra_qc(), xsh_monitor_spectrum1D_flux(), xsh_multiply_flat(), xsh_nod_rectify_and_shift_with_key(), xsh_opt_extract_orders(), xsh_orderpos(), xsh_phys_spectrum_save(), xsh_pre_3d_save(), xsh_pre_save(), xsh_pre_save_product(), xsh_predict(), xsh_preframe_extract(), xsh_prepare(), xsh_rec_list_add(), xsh_rec_list_qc(), xsh_rectify_and_shift(), xsh_remove_cosmics(), xsh_resid_order_save(), xsh_resid_tab_save(), xsh_respon_slit_nod(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_response_calculate(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_scired_slit_nod(), xsh_scired_slit_nod_accurate(), xsh_scired_slit_nod_fast(), xsh_scired_slit_offset(), xsh_scired_slit_stare(), xsh_scired_util_spectra_flux_calibrate(), xsh_shift(), xsh_shift_tab_save(), xsh_slit_stare_correct_crh_and_sky(), xsh_spectrum1D_save(), xsh_spectrum_correct(), xsh_spectrum_cut_dichroic_uvb(), xsh_spectrum_orders_cut_dichroic_uvb(), xsh_spectrum_save(), xsh_spectrum_save_order(), xsh_star_flux_list_to_frame(), xsh_subtract_background(), xsh_subtract_bias(), xsh_subtract_dark(), xsh_subtract_nir_on_off(), xsh_subtract_sky_single(), xsh_util_afc(), xsh_util_apply_response(), xsh_util_compute_response(), xsh_util_crh_single(), xsh_util_efficiency1d(), xsh_util_ifu_build_cube(), xsh_util_integrate(), xsh_util_model_SPF_create(), xsh_util_physmod(), xsh_util_physmod_model_THE_create(), xsh_wavecal(), xsh_wavemap_list_object_image_save(), xsh_wavemap_list_save4debug(), xsh_wavemap_list_save_poly(), and xsh_wavemap_list_sky_image_save().

◆ xsh_free_frameset()

void xsh_free_frameset ( cpl_frameset **  f)

Deallocate a frame set and set the pointer to NULL.

Parameters
fFrame set to deallocate

Definition at line 2254 of file xsh_utils.c.

Referenced by main(), sof_to_frameset(), xsh_2dmap(), xsh_absorp(), xsh_cfg_recover_driver(), xsh_cfg_recover_last_step(), xsh_check_load_master_bpmap(), xsh_compute_shift_ifu(), xsh_correct_calib(), xsh_dfs_fix_key_start_end(), xsh_dfs_split_nir(), xsh_dfs_split_qth_d2(), xsh_ensure_raws_input_offset_recipe_is_proper(), xsh_extract_nod_pairs(), xsh_extract_obj_and_sky_pairs(), xsh_find_offset_tab_ifu(), xsh_flexcomp(), xsh_follow_arclines_ifu(), xsh_gain(), xsh_geom_ifu(), xsh_ifu_wavetab_create(), xsh_linear(), xsh_lingain(), xsh_localize_ifu(), xsh_localize_obj_ifu(), xsh_mbias(), xsh_mdark(), xsh_merge_ord_ifu(), xsh_mflat(), xsh_mflat_combine_flats(), xsh_model_first_anneal_save(), xsh_nod_group_by_reloff(), xsh_nod_group_by_reloff2(), xsh_order_frameset_by_date(), xsh_orderpos(), xsh_predict(), xsh_respon_slit_nod(), xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_scired_slit_nod(), xsh_scired_slit_nod_accurate(), xsh_scired_slit_offset(), xsh_scired_slit_stare(), xsh_shift_offsettab(), xsh_subtract_nir_on_off(), xsh_subtract_on_off(), xsh_subtract_sky_nod(), xsh_subtract_sky_offset(), xsh_util_afc(), xsh_util_apply_response(), xsh_util_bpmap_coadd(), xsh_util_bpmap_nl_raw2pre(), xsh_util_compute_response(), xsh_util_efficiency1d(), xsh_util_efficiency2d(), xsh_util_guess_xy(), xsh_util_ifu_build_cube(), xsh_util_ima_arith(), xsh_util_ima_shift(), xsh_util_integrate(), xsh_util_physmod(), and xsh_wavecal().

◆ xsh_free_image()

void xsh_free_image ( cpl_image **  i)

Deallocate an image and set the pointer to NULL.

Parameters
iImage to deallocate

Definition at line 2116 of file xsh_utils.c.

Referenced by compute_specres(), create_frame(), createFakeFrames(), fill_rectified(), get_masterbias_qc_structure_col_region(), get_masterbias_qc_structure_row_region(), main(), make_data_cube(), set_masterbias_qc_xsh_structure_region(), xsh_add_afc_info(), xsh_add_product(), xsh_add_product_bpmap(), xsh_add_product_image(), xsh_add_sky_model(), xsh_badpixelmap_coadd(), xsh_badpixelmap_crea_master_from_bpmap(), xsh_badpixelmap_extract(), xsh_badpixelmap_fill_bp_pattern_holes(), xsh_blaze_image(), xsh_build_ifu_cube(), xsh_build_ifu_map(), xsh_cfg_recover_linear_ext(), xsh_cfg_recover_measure_line_xy(), xsh_cfg_recover_measure_line_xy_fit(), xsh_check_load_master_bpmap(), xsh_combine_flats(), xsh_compute_flat_edges(), xsh_compute_linearity(), xsh_compute_noise_map(), xsh_compute_resampling_accuracy(), xsh_compute_ron(), xsh_compute_wavelength_resampling_accuracy(), xsh_crea_grid_from_mask(), xsh_create_blaze(), xsh_create_dispersol_physmod(), xsh_create_master_bias2(), xsh_create_master_dark2(), xsh_create_master_flat_with_mask(), xsh_dispersol_list_to_slitmap(), xsh_dispersol_list_to_wavemap(), xsh_divide_by_blaze(), xsh_efficiency_compute(), xsh_extract_local_clean(), xsh_fixed_pattern_noise(), xsh_fixed_pattern_noise_bias(), xsh_flat_merge_qth_d2(), xsh_flat_merge_qth_d2_smooth(), xsh_frame_abs(), xsh_frame_build_sky_area(), xsh_frame_build_sky_map(), xsh_frame_force_pro_catg(), xsh_frame_image_add_double(), xsh_frame_image_div_by_fct(), xsh_frame_image_ext_qc_trace_window(), xsh_frame_image_get_step(), xsh_frame_image_mult_by_fct(), xsh_frame_image_qc_trace_window(), xsh_frame_image_save(), xsh_frame_image_save2ext(), xsh_frame_mult(), xsh_frame_qual_update(), xsh_frameset_average(), xsh_frameset_average_pre(), xsh_frameset_crh_single(), xsh_gain(), xsh_get_master_dark_nir_via_noise(), xsh_gfit_tests(), xsh_hdrl_remove_crh_single(), xsh_ifu_trace_object_calibrate(), xsh_image_clean_badpixel(), xsh_image_compute_geom_corr(), xsh_image_create_gaussian_image(), xsh_image_create_model_image(), xsh_image_cut_dichroic_uvb(), xsh_image_divide_1D(), xsh_image_flag_bptype_with_crox(), xsh_image_get_hot_cold_pixs(), xsh_image_get_stdev_clean(), xsh_image_get_stdev_robust(), xsh_image_mflat_detect_blemishes(), xsh_image_smooth_fft(), xsh_image_smooth_mean_y(), xsh_iml_merge_wgt(), xsh_linear(), xsh_lingain(), xsh_mdark(), xsh_mdark_get_median_stdev(), xsh_model_maps_create(), xsh_monitor_flux(), xsh_monitor_spectrum1D_flux_qc(), xsh_monitor_spectrum3D_flux_qc(), xsh_normalize_spectrum_image(), xsh_normalize_spectrum_image_slice(), xsh_object_localize(), xsh_opt_extract_orders(), xsh_optextract_produce_model(), xsh_pre_create(), xsh_pre_extract(), xsh_pre_free(), xsh_pre_multiply_image(), xsh_preoverscan_corr(), xsh_rec_list_load_eso(), xsh_rec_list_save2(), xsh_remove_cosmics(), xsh_remove_crh_single(), xsh_spectrum1D_free(), xsh_spectrum_free(), xsh_subtract_background(), xsh_test_create_frame(), xsh_update_pheader_in_image_multi(), xsh_util_afc(), xsh_util_bpmap2rp(), xsh_util_bpmap_coadd(), xsh_util_efficiency(), xsh_util_efficiency2d(), xsh_util_frameset_collapse_mean(), xsh_util_ifu_build_cube(), xsh_util_ima_arith(), xsh_util_ima_getextno(), xsh_util_ima_oversample(), xsh_util_ima_rebin(), xsh_util_ima_shift(), xsh_util_ima_subsample(), xsh_util_multiply_by_response(), xsh_util_multiply_by_response_ord(), xsh_vector_to_image(), xsh_wavemap_lambda_range(), xsh_wavemap_list_full_sky_save(), xsh_wavemap_list_new(), xsh_wavemap_list_object_image_save(), xsh_wavemap_list_rms_sky_image_save(), xsh_wavemap_list_save(), xsh_wavemap_list_save2(), xsh_wavemap_list_save4debug(), xsh_wavemap_list_sky_image_save(), and xsh_wavemap_qc().

◆ xsh_free_imagelist()

void xsh_free_imagelist ( cpl_imagelist **  i)

◆ xsh_free_mask()

void xsh_free_mask ( cpl_mask **  m)

Deallocate an image mask and set the pointer to NULL.

Parameters
mMask to deallocate

Definition at line 2149 of file xsh_utils.c.

References m.

Referenced by reject_lo_hi(), xsh_frameset_crh_single(), xsh_get_master_dark_nir_via_noise(), xsh_image_flag_bp(), xsh_image_get_hot_cold_pixs(), xsh_image_get_stdev_clean(), xsh_image_get_stdev_robust(), xsh_rectify_orders(), and xsh_remove_cosmics().

◆ xsh_free_matrix()

void xsh_free_matrix ( cpl_matrix **  m)

Deallocate a matrix and set the pointer to NULL.

Parameters
mMatrix to deallocate

Definition at line 2209 of file xsh_utils.c.

References m.

Referenced by main(), xsh_atrous(), xsh_cfg_recover_pattern_match(), xsh_image_mflat_detect_blemishes(), xsh_localize_ifu_slitlet(), xsh_model_maps_create(), xsh_polynomial_fit_1d(), xsh_polynomial_fit_2d(), and xsh_remove_crh_single().

◆ xsh_free_parameter()

void xsh_free_parameter ( cpl_parameter **  p)

Deallocate a parameter and set the pointer to NULL.

Parameters
pParameter to deallocate

Definition at line 2239 of file xsh_utils.c.

◆ xsh_free_parameterlist()

void xsh_free_parameterlist ( cpl_parameterlist **  p)

◆ xsh_free_polynomial()

void xsh_free_polynomial ( cpl_polynomial **  p)

◆ xsh_free_product_files()

void xsh_free_product_files ( void  )

Free temprary files list.

Definition at line 1491 of file xsh_utils.c.

References NbProducts, and ProdFiles.

Referenced by main(), and xsh_end().

◆ xsh_free_propertylist()

void xsh_free_propertylist ( cpl_propertylist **  p)

Deallocate a property list and set the pointer to NULL.

Parameters
pProperty list to deallocate

Definition at line 2179 of file xsh_utils.c.

Referenced by create_frame(), create_instrument(), createFakeFrames(), main(), save_pre_frame(), shift_with_kw(), test_catalog(), test_create_ima_gauss(), test_create_ima_uniform(), verify_order_table(), xsh_2dmap(), xsh_abs_remove_crh_single(), xsh_absorp(), xsh_add_afc_info(), xsh_add_product(), xsh_add_product_bpmap(), xsh_add_product_image(), xsh_add_product_imagelist(), xsh_add_product_orders_spectrum(), xsh_add_product_pre(), xsh_add_product_table(), xsh_add_product_vector(), xsh_add_qc_tab(), xsh_arclist_free(), xsh_badpixelmap_coadd(), xsh_badpixelmap_crea_master_from_bpmap(), xsh_badpixelmap_extract(), xsh_badpixelmap_fill_bp_pattern_holes(), xsh_build_ifu_cube(), xsh_build_ifu_map(), xsh_cfg_recover_gen_xyg_frame(), xsh_cfg_recover_measure_tab_xy_peaks(), xsh_check_input_is_unbinned(), xsh_check_load_master_bpmap(), xsh_combine_flats(), xsh_compute_flat_edges(), xsh_compute_linearity(), xsh_compute_noise_map(), xsh_compute_resampling_accuracy(), xsh_compute_response(), xsh_compute_response2(), xsh_compute_response_ord(), xsh_compute_ron(), xsh_compute_shift_ifu_slitlet(), xsh_compute_wavelength_resampling_accuracy(), xsh_convert_seeing(), xsh_correct_calib(), xsh_correct_frameset_calib_bin(), xsh_correct_frameset_raws_bin(), xsh_crea_correct_coeff(), xsh_create_master_dark2(), xsh_cube_qc_trace_window(), xsh_detect_arclines(), xsh_detect_arclines_dan(), xsh_detect_continuum(), xsh_detect_order_edge(), xsh_dfs_check_binning(), xsh_dfs_check_mflat_is_proper(), xsh_dispersol_list_free(), xsh_dispersol_list_to_slitmap(), xsh_dispersol_list_to_wavemap(), xsh_efficiency_compute(), xsh_ensure_raws_number_is_even(), xsh_extract_clean_with_tag(), xsh_extract_local_clean(), xsh_extract_nod_pairs(), xsh_extract_obj_and_sky_pairs(), xsh_extract_with_tag(), xsh_flexcor(), xsh_frame_build_sky_area(), xsh_frame_build_sky_map(), xsh_frame_check_is_right_afcatt(), xsh_frame_check_model_cfg_is_afc_corrected(), xsh_frame_check_model_cfg_is_proper_for_sci(), xsh_frame_force_pro_catg(), xsh_frame_image_add_double(), xsh_frame_image_div_by_fct(), xsh_frame_image_ext_qc_trace_window(), xsh_frame_image_mult_by_fct(), xsh_frame_image_qc_trace_window(), xsh_frame_image_save(), xsh_frame_image_save2ext(), xsh_frame_nir_tab_chop_Kband(), xsh_frame_pre_subsample(), xsh_frame_sci_get_gain_airmass_exptime_naxis1_biny(), xsh_frame_sci_get_ra_dec_airmass(), xsh_frame_set_shift_ref(), xsh_frame_set_shiftifu_ref(), xsh_frame_table_monitor_flux_qc(), xsh_frame_table_resid_merge(), xsh_frame_table_save(), xsh_frameset_average(), xsh_frameset_average_pre(), xsh_frameset_check_uniform_exptime(), xsh_frameset_drl_frames(), xsh_frameset_dump_nod_info(), xsh_frameset_ext_image_frames(), xsh_frameset_ext_table_frames(), xsh_frameset_extract_offsety_matches(), xsh_frameset_extract_offsety_mismatches(), xsh_frameset_uniform_bin(), xsh_gain(), xsh_geom_ifu(), xsh_get_binning(), xsh_get_exptimes(), xsh_get_master_dark_nir_via_noise(), xsh_get_shift_ref(), xsh_get_slit_edges(), xsh_ifu_trace_object_calibrate(), xsh_image_clean_badpixel(), xsh_image_cut_dichroic_uvb(), xsh_image_get_hot_cold_pixs(), xsh_instrument_nir_is_JH(), xsh_linear_group_by_exptime(), xsh_linetilt_list_free(), xsh_lingain(), xsh_localization_free(), xsh_localization_load(), xsh_localize_ifu(), xsh_localize_ifu_slitlet(), xsh_mbias(), xsh_mdark(), xsh_merge_ord_slitlet(), xsh_merge_ord_with_tag(), xsh_mflat(), xsh_model_first_anneal_save(), xsh_model_maps_create(), xsh_model_order_edges_tab_create(), xsh_model_pipe_anneal(), xsh_model_spectralformat_create(), xsh_model_temperature_update_frame(), xsh_model_temperature_update_structure(), xsh_model_THE_create(), xsh_monitor_flux(), xsh_nod_group_by_reloff(), xsh_nod_group_by_reloff2(), xsh_normalize_spectrum(), xsh_normalize_spectrum_image_slice(), xsh_normalize_spectrum_ord(), xsh_obs_std_correct(), xsh_opt_extract_orders(), xsh_order_frameset_by_date(), xsh_order_list_free(), xsh_order_list_load(), xsh_order_split_qth_d2(), xsh_params_bin_scale(), xsh_pfits_combine_headers(), xsh_pfits_combine_two_frames_headers(), xsh_pre_3d_free(), xsh_pre_create(), xsh_pre_free(), xsh_predict(), xsh_preoverscan_corr(), xsh_rec_get_nod_kw(), xsh_rec_list1D_save_as_tab(), xsh_rec_list_duplicate(), xsh_rec_list_free(), xsh_rec_list_load(), xsh_rec_list_load_eso(), xsh_rec_list_load_eso_1d(), xsh_rec_list_save2(), xsh_rectify_and_shift(), xsh_resid_order_free(), xsh_resid_tab_erase_flagged(), xsh_resid_tab_free(), xsh_respon_slit_nod(), xsh_response_merge_obj_std_info(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_scired_slit_stare(), xsh_set_recipe_file_prefix(), xsh_shift_offsettab(), xsh_shift_tab_free(), xsh_slice_offset_free(), xsh_slice_offset_load(), xsh_sort_table_1(), xsh_sort_table_2(), xsh_sort_table_3(), xsh_spectralformat_list_free(), xsh_spectralformat_list_load(), xsh_spectrum1D_free(), xsh_spectrum_cut_dichroic_uvb(), xsh_spectrum_free(), xsh_spectrum_interpolate(), xsh_spectrum_interpolate_linear(), xsh_spectrum_orders_cut_dichroic_uvb(), xsh_spectrum_resample(), xsh_star_flux_list_free(), xsh_stare_params_bin_scale(), xsh_subtract_background(), xsh_table_merge_clean_and_resid_tabs(), xsh_telluric_model_eval(), xsh_test_create_bias_image(), xsh_test_create_frame(), xsh_the_map_free(), xsh_the_map_load(), xsh_update_pheader_in_image_multi(), xsh_util_afc(), xsh_util_bpmap2rp(), xsh_util_bpmap_coadd(), xsh_util_compute_response(), xsh_util_efficiency(), xsh_util_efficiency2d(), xsh_util_frameset_collapse_mean(), xsh_util_ifu_build_cube(), xsh_util_ima_arith(), xsh_util_ima_getextno(), xsh_util_ima_oversample(), xsh_util_ima_rebin(), xsh_util_ima_shift(), xsh_util_ima_subsample(), xsh_util_integrate(), xsh_util_multiply_by_response(), xsh_util_multiply_by_response_ord(), xsh_util_physmod_model_THE_create(), xsh_utils_compute_airm_eff(), xsh_utils_efficiency(), xsh_wavecal_qclog_intmon(), xsh_wavemap_list_free(), xsh_wavemap_list_save(), xsh_wavemap_list_save2(), xsh_wavemap_qc(), xsh_wavesol_free(), and xsh_wavetab_qc().

◆ xsh_free_stats()

void xsh_free_stats ( cpl_stats **  s)

Deallocate a stats object and set the pointer to NULL.

Parameters
sStats object to deallocate

Definition at line 2314 of file xsh_utils.c.

References s.

Referenced by xsh_pre_dump().

◆ xsh_free_table()

void xsh_free_table ( cpl_table **  t)

Deallocate a table and set the pointer to NULL.

Parameters
ttable to deallocate

Definition at line 2133 of file xsh_utils.c.

Referenced by main(), test_catalog(), test_spectrum_detect_lines(), xsh_2dmap(), xsh_add_product(), xsh_add_product_table(), xsh_add_qc_tab(), xsh_align_model_to_spectrum(), xsh_bspline_fit_interpol(), xsh_bspline_fit_smooth(), xsh_bspline_fit_smooth_data(), xsh_bspline_fit_smooth_data2(), xsh_bspline_smooth_non_uniform2(), xsh_bspline_smooth_uniform(), xsh_bspline_smooth_uniform_sl(), xsh_build_ifu_cube(), xsh_calib_nir_respon_corr_if_JH(), xsh_cfg_recover_extend_xy_pos_frm(), xsh_cfg_recover_gen_xyg_frame(), xsh_cfg_recover_guess_tab_corr_by_ordpos(), xsh_cfg_recover_guess_tab_corr_by_user(), xsh_cfg_recover_last_step(), xsh_cfg_recover_linear_ext(), xsh_cfg_recover_measure_line_xy(), xsh_cfg_recover_measure_line_xy_fit(), xsh_cfg_recover_measure_tab_xy_peaks(), xsh_cfg_recover_pattern_match(), xsh_cfg_recover_prepare_pm_set(), xsh_cfg_recover_remove_blends(), xsh_cfg_recover_select_peaks(), xsh_combine_flats(), xsh_compute_flat_edges(), xsh_compute_resampling_accuracy(), xsh_compute_response(), xsh_compute_response2(), xsh_compute_response_ord(), xsh_compute_wavelength_resampling_accuracy(), xsh_crea_correct_coeff(), xsh_create_order_table(), xsh_cube_qc_trace_window(), xsh_detect_arclines(), xsh_detect_arclines_dan(), xsh_detect_order_edge(), xsh_detect_outliers_thres_new(), xsh_detect_raw_data_outliers_1d(), xsh_detect_raw_data_outliers_1d_slice(), xsh_dispersol_list_load(), xsh_dispersol_list_save(), xsh_efficiency_compute(), xsh_evaluate_tell_model(), xsh_extract_local_clean(), xsh_extract_points_to_fit(), xsh_extract_ranges_to_fit(), xsh_fill_high_abs_regions(), xsh_fill_tell_compute_resid_regions(), xsh_fill_tell_fit_regions(), xsh_fit_spline1(), xsh_fit_spline2(), xsh_flexcor(), xsh_frame_force_pro_catg(), xsh_frame_image_ext_qc_trace_window(), xsh_frame_image_qc_trace_window(), xsh_frame_nir_tab_chop_Kband(), xsh_frame_table_monitor_flux_qc(), xsh_frame_table_resid_merge(), xsh_frame_table_save(), xsh_gain(), xsh_get_central_xy(), xsh_get_xcorrel_peak(), xsh_histogram(), xsh_ifu_wavetab_create(), xsh_line_fill_xbin_ybin_ysig(), xsh_line_group_stat(), xsh_lines_set_breakpoints(), xsh_linetilt_list_save(), xsh_localize_ifu_slitlet(), xsh_localize_obj_auto(), xsh_mflat(), xsh_model_compute_residuals(), xsh_model_first_anneal(), xsh_model_maps_create(), xsh_model_pipe_anneal(), xsh_model_readfits(), xsh_model_spectralformat_create(), xsh_model_temperature_update_frame(), xsh_model_THE_create(), xsh_monitor_flux(), xsh_normalize_spectrum(), xsh_normalize_spectrum_ord(), xsh_obs_std_correct(), xsh_order_list_save(), xsh_order_split_qth_d2(), xsh_pre_median_mean_stdev_window(), xsh_predict(), xsh_rec_list1D_save_as_tab(), xsh_rec_list_add(), xsh_resid_tab_erase_flagged(), xsh_response_calculate(), xsh_response_merge_obj_std_info(), xsh_skycor_def_nbkpts_ord(), xsh_skycorr_sampl_lines_from_static_tab(), xsh_skycorr_wave_sampling_create(), xsh_spectrum_correct(), xsh_spectrum_interpolate(), xsh_spectrum_interpolate_linear(), xsh_spectrum_resample(), xsh_subtract_background(), xsh_table_merge_clean_and_resid_tabs(), xsh_table_monitor_flux_qc(), xsh_telluric_model_eval(), xsh_util_afc(), xsh_util_compute_qc_residuals(), xsh_util_efficiency(), xsh_util_efficiency2d(), xsh_util_ifu_build_cube(), xsh_util_multiply_by_response(), xsh_util_multiply_by_response_ord(), xsh_util_physmod_model_THE_create(), xsh_utils_efficiency(), xsh_utils_efficiency_internal(), xsh_verify_2dmap_poly_input(), xsh_wavecal_qclog_element(), xsh_wavecal_qclog_intmon(), xsh_wavemap_list_new(), xsh_wavemap_qc(), and xsh_wavetab_qc().

◆ xsh_free_temporary_files()

void xsh_free_temporary_files ( void  )

Free temprary files list.

Definition at line 1451 of file xsh_utils.c.

References NbTemp, and TempFiles.

Referenced by main(), and xsh_end().

◆ xsh_free_vector()

void xsh_free_vector ( cpl_vector **  v)

Deallocate a vector and set the pointer to NULL.

Parameters
vVector to deallocate

Definition at line 2284 of file xsh_utils.c.

Referenced by clean_arclist_data(), compute_specres(), create_gaussian_profile(), data_wavesol_fit_with_sigma(), detect_centroid(), fill_rectified(), find_tilt(), lambda_fit(), main(), test_tech_eval_perf(), theo_tab_model(), xsh_add_product_orders_spectrum(), xsh_add_product_vector(), xsh_afcthetab_create(), xsh_align_model_to_spectrum(), xsh_atrous(), xsh_build_ifu_cube(), xsh_center_cube(), xsh_cfg_recover_measure_line_xy(), xsh_cfg_recover_measure_tab_xy_peaks(), xsh_compute_absorp(), xsh_compute_shift_ifu_slitlet(), xsh_compute_wavelength_resampling_accuracy(), xsh_correl_spectra(), xsh_detect_continuum(), xsh_dispersol_list_to_slitmap(), xsh_dispersol_list_to_wavemap(), xsh_efficiency_compute(), xsh_extract_clean_slice(), xsh_fit_gaussian(), xsh_flexcor(), xsh_image_extract_optimal(), xsh_image_extract_standard(), xsh_image_fit_gaussian_max_pos_x_window(), xsh_image_fit_gaussian_max_pos_y_window(), xsh_image_gaussian_fit_y(), xsh_imagelist_cut_dichroic_uvb(), xsh_interpolate_spectrum(), xsh_localize_ifu_slitlet(), xsh_localize_obj_auto(), xsh_mark_tell(), xsh_model_maps_create(), xsh_normalize_spectrum_image_slice(), xsh_opt_extract_orders(), xsh_phys_spectrum_save(), xsh_polynomial_fit_1d(), xsh_pre_median_mean_stdev(), xsh_pre_median_mean_stdev_window(), xsh_preoverscan_corr(), xsh_rec_list_load_eso_1d(), xsh_rec_list_save2(), xsh_remove_crh_single(), xsh_spectralformat_list_get_orders(), xsh_spectrum_load(), xsh_spectrum_load_order(), xsh_spectrum_save(), xsh_spectrum_save_order(), xsh_star_flux_list_filter_lowpass(), xsh_star_flux_list_filter_median(), xsh_std_star_spectra_correlate(), xsh_telluric_model_eval(), xsh_tools_get_statistics(), xsh_tools_tchebitchev_poly_eval(), xsh_util_efficiency(), xsh_util_efficiency2d(), xsh_util_ifu_build_cube(), xsh_util_multiply_by_response(), xsh_util_multiply_by_response_ord(), xsh_vector_fit_slope(), xsh_vector_integrate(), xsh_wavemap_list_eval_lambda(), xsh_wavemap_list_new(), xsh_wavesol_eval_polx(), xsh_wavesol_eval_poly(), xsh_wavesol_free(), and xsh_wavetab_qc().

◆ xsh_function1d_xcorrelate()

double * xsh_function1d_xcorrelate ( double *  line_i,
int  width_i,
double *  line_t,
int  width_t,
int  half_search,
int  normalise,
double *  xcorr_max,
double *  delta 
)

Definition at line 7101 of file xsh_utils.c.

References step.

Referenced by xsh_correl_spectra().

◆ xsh_get_basename()

char * xsh_get_basename ( const char *  filename)

Return base filename.

Parameters
filenameinput filename
Returns
basename (See unix basename)

Definition at line 1175 of file xsh_utils.c.

Referenced by xsh_compute_response2(), xsh_frame_image_div_by_fct(), xsh_frame_image_mult_by_fct(), xsh_frame_nir_tab_chop_Kband(), xsh_frame_pre_subsample(), xsh_preoverscan_corr(), and xsh_util_ima_rebin().

◆ xsh_get_license()

const char * xsh_get_license ( void  )

Get the pipeline copyright and license.

Returns
The copyright and license string

The function returns a pointer to the statically allocated license string. This string should not be modified using the returned pointer.

Definition at line 1193 of file xsh_utils.c.

Referenced by cpl_plugin_get_info().

◆ xsh_get_property_value()

cpl_error_code xsh_get_property_value ( const cpl_propertylist *  plist,
const char *  keyword,
cpl_type  keywordtype,
void *  result 
)

Read a property value from a property list.

Parameters
plistPropertylist to read
keywordName of property to read
keywordtypeType of keyword
resultThe value read
Returns
CPL_ERROR_NONE iff OK

This function wraps cpl_propertylist_get_int(), cpl_propertylist_get_bool(), cpl_propertylist_get_double() and cpl_propertylist_get_string(). It checks existence and type of the requested keyword before reading and describes what went wrong if the property could not be read.

Note
The result is written to the variable pointed to by the parameter result. Because this is a void pointer, it is the responsibility of the caller to make sure that the type of this pointer variable corresponds to the requested keywordtype. E.g. if keywordtype is CPL_TYPE_BOOL, then result must be an bool pointer (bool *). If keywordtype isCPL_TYPE_STRING, then result must be a char **, and so on.

Definition at line 1600 of file xsh_utils.c.

References assure, check_msg, and xsh_tostring_cpl_type().

Referenced by verify_order_table(), xsh_key_bin_div_by_fct(), xsh_key_bin_mult_by_fct(), xsh_key_scan_div_by_fct(), xsh_key_scan_mult_by_fct(), xsh_pfits_get_airm_end(), xsh_pfits_get_airm_start(), xsh_pfits_get_arcfile(), xsh_pfits_get_b_dec_cumoffset(), xsh_pfits_get_b_dec_reloffset(), xsh_pfits_get_b_ra_cumoffset(), xsh_pfits_get_b_ra_reloffset(), xsh_pfits_get_bias_down_median(), xsh_pfits_get_bias_down_stdev(), xsh_pfits_get_bias_left_median(), xsh_pfits_get_bias_left_stdev(), xsh_pfits_get_bias_right_median(), xsh_pfits_get_bias_right_stdev(), xsh_pfits_get_bias_up_median(), xsh_pfits_get_bias_up_stdev(), xsh_pfits_get_bunit(), xsh_pfits_get_cd11(), xsh_pfits_get_cd12(), xsh_pfits_get_cd13(), xsh_pfits_get_cd21(), xsh_pfits_get_cd22(), xsh_pfits_get_cd23(), xsh_pfits_get_cd31(), xsh_pfits_get_cd32(), xsh_pfits_get_cd33(), xsh_pfits_get_cdelt1(), xsh_pfits_get_cdelt2(), xsh_pfits_get_cdelt3(), xsh_pfits_get_crpix1(), xsh_pfits_get_crpix2(), xsh_pfits_get_crpix3(), xsh_pfits_get_crval1(), xsh_pfits_get_crval2(), xsh_pfits_get_crval3(), xsh_pfits_get_cumoffsetx(), xsh_pfits_get_cumoffsety(), xsh_pfits_get_cunit1(), xsh_pfits_get_cunit2(), xsh_pfits_get_cunit3(), xsh_pfits_get_date(), xsh_pfits_get_date_obs(), xsh_pfits_get_dec(), xsh_pfits_get_dec_cumoffset(), xsh_pfits_get_dec_reloffset(), xsh_pfits_get_det_gain(), xsh_pfits_get_det_pxspace(), xsh_pfits_get_det_win1_uit1(), xsh_pfits_get_dit(), xsh_pfits_get_dpr_catg(), xsh_pfits_get_dpr_tech(), xsh_pfits_get_dpr_type(), xsh_pfits_get_exptime(), xsh_pfits_get_extname(), xsh_pfits_get_extract_slit_max(), xsh_pfits_get_extract_slit_min(), xsh_pfits_get_FOCU1ENC(), xsh_pfits_get_lamp_on_off(), xsh_pfits_get_mjdobs(), xsh_pfits_get_ndit(), xsh_pfits_get_nod_cumoffset(), xsh_pfits_get_nod_jitterwidth(), xsh_pfits_get_nod_reloffset(), xsh_pfits_get_nodthrow(), xsh_pfits_get_obs_id(), xsh_pfits_get_obs_targ_name(), xsh_pfits_get_pcatg(), xsh_pfits_get_posang(), xsh_pfits_get_pszx(), xsh_pfits_get_pszy(), xsh_pfits_get_qc_mbiasavg(), xsh_pfits_get_qc_mbiasmed(), xsh_pfits_get_qc_mbiasrms(), xsh_pfits_get_qc_mbiasslope(), xsh_pfits_get_qc_mdarkmed(), xsh_pfits_get_qc_ncrh(), xsh_pfits_get_qc_ncrh_mean(), xsh_pfits_get_qc_nhpix(), xsh_pfits_get_qc_ron(), xsh_pfits_get_qc_structx(), xsh_pfits_get_qc_structy(), xsh_pfits_get_ra(), xsh_pfits_get_ra_cumoffset(), xsh_pfits_get_ra_reloffset(), xsh_pfits_get_raw1catg(), xsh_pfits_get_raw1name(), xsh_pfits_get_rectify_bin_lambda(), xsh_pfits_get_rectify_bin_space(), xsh_pfits_get_rectify_lambda_max(), xsh_pfits_get_rectify_lambda_min(), xsh_pfits_get_rectify_space_max(), xsh_pfits_get_rectify_space_min(), xsh_pfits_get_shiftifu_lambdaref(), xsh_pfits_get_shiftifu_slitref(), xsh_pfits_get_slitmap_median_cen(), xsh_pfits_get_slitmap_median_edglo(), xsh_pfits_get_slitmap_median_edgup(), xsh_pfits_get_slitmap_median_sliclo(), xsh_pfits_get_slitmap_median_slicup(), xsh_pfits_get_tel_targ_alpha(), xsh_pfits_get_tel_targ_delta(), xsh_pfits_get_telescop(), xsh_pfits_get_temp2(), xsh_pfits_get_temp5(), xsh_pfits_get_temp82(), xsh_pfits_get_wavesol_lambda_max(), xsh_pfits_get_wavesol_lambda_min(), xsh_pfits_get_wavesol_order_max(), xsh_pfits_get_wavesol_order_min(), xsh_pfits_get_wavesol_slit_max(), xsh_pfits_get_wavesol_slit_min(), xsh_pfits_get_wavesol_x_max(), xsh_pfits_get_wavesol_x_min(), xsh_pfits_get_wavesol_y_max(), xsh_pfits_get_wavesol_y_min(), xsh_pfits_get_wavesoltype(), and xsh_pfits_get_win1_dit1().

◆ xsh_get_random_double_window()

double xsh_get_random_double_window ( const double  v1,
const double  v2 
)

generates random integer values in range [v1,v2]

Parameters
v1min value
v2max value
Returns
random integer value

Definition at line 150 of file xsh_utils.c.

◆ xsh_get_random_int_window()

int xsh_get_random_int_window ( const int  v1,
const int  v2 
)

generates random integer values in range [v1,v2]

Parameters
v1min value
v2max value
Returns
random integer value

Definition at line 128 of file xsh_utils.c.

◆ xsh_get_table_value()

cpl_error_code xsh_get_table_value ( const cpl_table *  table,
const char *  colname,
cpl_type  coltype,
int  i,
void *  result 
)

Read a table value from a fits table.

Parameters
tabletable to read
colnameName of column to read
coltypeType of column
irow to read
resultThe value read
Returns
CPL_ERROR_NONE iff OK
Note
derived from UVES pipeline

Definition at line 472 of file xsh_utils_table.c.

References assure, check_msg, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_arclist_load(), xsh_atmos_ext_list_load(), xsh_dispersol_list_load(), xsh_localization_load(), xsh_order_list_load(), xsh_order_split_qth_d2(), xsh_rec_list_load(), xsh_resid_order_load(), xsh_resid_tab_load(), xsh_shift_tab_load(), xsh_slice_offset_load(), xsh_spectralformat_list_load(), xsh_star_flux_list_load(), xsh_the_map_load(), and xsh_wavesol_load().

◆ xsh_gsl_fit_gaussian()

void xsh_gsl_fit_gaussian ( cpl_vector *  xpos_vect,
cpl_vector *  ypos_vect,
int  deg,
double *  params,
double *  errs,
int *  status 
)

◆ xsh_gsl_init_gaussian_fit()

void xsh_gsl_init_gaussian_fit ( cpl_vector *  xpos_vect,
cpl_vector *  ypos_vect,
double *  init_par 
)

Definition at line 6862 of file xsh_utils.c.

References M_PI, size, XSH_ASSURE_NOT_NULL, and xsh_msg_dbg_high.

Referenced by main(), and xsh_localize_ifu_slitlet().

◆ xsh_histogram()

cpl_table * xsh_histogram ( const cpl_table *  data,
const char *  cname,
const int  nbins,
const double  min,
const double  max 
)

Definition at line 88 of file xsh_utils_table.c.

References max, and xsh_free_table().

Referenced by xsh_detect_outliers_thres_new(), and xsh_lines_set_breakpoints().

◆ xsh_hms2deg()

double xsh_hms2deg ( const double  hms)

Convert a double from hours minute seconds to deg:

Parameters
hmsangle in hours minute second units
Returns
0 if suggess, else -1;

Definition at line 312 of file xsh_utils.c.

Referenced by xsh_build_ifu_map(), and xsh_cube_set_wcs().

◆ xsh_image_fit_spline()

void xsh_image_fit_spline ( cpl_image *  img,
xsh_grid grid 
)

perform spline fit

Parameters
imginput image
gridinput grid specifying evaluation points
Returns
updated image with result of spline fit to grid points

Definition at line 2980 of file xsh_utils.c.

References check, nx, ny, size, xsh_grid_point::v, xsh_grid_point::x, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, XSH_FREE, xsh_grid_get_index(), xsh_grid_point_get(), XSH_MALLOC, xsh_msg, and xsh_grid_point::y.

◆ xsh_image_to_vector()

cpl_vector * xsh_image_to_vector ( cpl_image *  spectrum)

◆ xsh_imagelist_collapse_sigclip_iter_create()

cpl_image * xsh_imagelist_collapse_sigclip_iter_create ( const cpl_imagelist *  imlist,
double  sigma_low,
double  sigma_upp,
const int  niter 
)

Average with sigma-clipping rejection an imagelist to a single image.

Parameters
imlistthe input images list
sigma_lowthe sigma value to clip low signal pixels
sigma_uppthe sigma value to clip high signal pixels
niterthe number of clipping iterations
Returns
the average image or NULL on error case.

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

The bad pixel maps of the input frames are not taken into account, and the one of the created image is empty.

For each pixel position the pixels whose value is higher than mean+sigma_upp*stdev or lower than mean-sigma_low*stdev are discarded for the average computation. If all pixels are discarde, the reslting pixel is 0. Where mean is the average of the pixels at that position, and stdev is the standard deviation of the pixels at that position.

The input image list can be of type CPL_TYPE_INT, CPL_TYPE_FLOAT and CPL_TYPE_DOUBLE.

Possible #_cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT if (one of) the input pointer(s) is NULL
  • CPL_ERROR_ILLEGAL_INPUT if the input image list is not valid or if sigma is negative
  • CPL_ERROR_TYPE_MISMATCH if the passed image list type is not supported

Definition at line 193 of file xsh_utils.c.

References check, CPL_IMAGE_GET_DATA, CPL_IMAGE_GET_DATA_CONST, CPL_TYPE, CPL_TYPE_T, n, niter, nx, and ny.

◆ xsh_init()

void xsh_init ( void  )

Reset library state.

This function must be called from the recipe initializer function to make sure that the recipe is re-entrant (i.e. behaves identical on successive invocations)

Successive plugin invocations share their memory, so it is important that all static memory is reset to a well defined state.

Definition at line 1160 of file xsh_utils.c.

References xsh_error_reset, and xsh_msg_init().

Referenced by create(), xsh_2dmap_create(), xsh_absorp_create(), xsh_cfg_recover_create(), xsh_flexcomp_create(), xsh_geom_ifu_create(), xsh_lingain_create(), xsh_mbias_create(), xsh_mdark_create(), xsh_mflat_create(), xsh_model_anneal_create(), xsh_model_create(), xsh_model_first_anneal_create(), xsh_molecfit_calctrans_create(), xsh_molecfit_correct_create(), xsh_molecfit_model_create(), xsh_molecfit_telluric_create(), xsh_orderpos_create(), xsh_predict_create(), xsh_respon_slit_nod_create(), xsh_respon_slit_offset_create(), xsh_respon_slit_stare_create(), xsh_scired_ifu_offset_create(), xsh_scired_ifu_stare_create(), xsh_scired_slit_nod_create(), xsh_scired_slit_offset_create(), xsh_scired_slit_stare_create(), xsh_util_afc_create(), xsh_util_apply_response_create(), xsh_util_bpmap2rp_create(), xsh_util_bpmap_coadd_create(), xsh_util_bpmap_nl_raw2pre_create(), xsh_util_compute_response_create(), xsh_util_crh_single_create(), xsh_util_efficiency1d_create(), xsh_util_efficiency2d_create(), xsh_util_efficiency_create(), xsh_util_guess_xy_create(), xsh_util_ifu_build_cube_create(), xsh_util_ima_arith_create(), xsh_util_ima_getextno_create(), xsh_util_ima_oversample_create(), xsh_util_ima_rebin_create(), xsh_util_ima_shift_create(), xsh_util_ima_subsample_create(), xsh_util_integrate_create(), xsh_util_physmod_create(), xsh_util_ronbias_create(), and xsh_wavecal_create().

◆ xsh_iterpol_linear()

static double xsh_iterpol_linear ( double *  data_x,
double *  data_y,
int  ndata,
double  x,
int *  i_inf,
int *  i_sup 
)
static

Definition at line 6170 of file xsh_utils.c.

References x, and y.

Referenced by xsh_spectrum_interpolate_linear().

◆ xsh_max_double()

double xsh_max_double ( double  x,
double  y 
)

Maximum of two numbers.

Parameters
xFirst number
ySecond number
Returns
Maximum of x and y

See also xsh_round_double() .

Definition at line 4449 of file xsh_utils.c.

References x, and y.

◆ xsh_max_int()

int xsh_max_int ( int  x,
int  y 
)

Maximum of two numbers.

Parameters
xFirst number
ySecond number
Returns
Maximum of x and y

See also xsh_round_double() .

Definition at line 4415 of file xsh_utils.c.

References x, and y.

Referenced by xsh_polynomial_add_2d().

◆ xsh_mem_dump()

void xsh_mem_dump ( const char *  prompt)

Debugging utility. A call to this function dumps the memory usage to stderr.

Parameters
promptA string output to stderr before memory dump

Definition at line 3208 of file xsh_utils.c.

◆ xsh_min_double()

double xsh_min_double ( double  x,
double  y 
)

Minimum of two numbers.

Parameters
xFirst number
ySecond number
Returns
Minimum of x and y

See also xsh_round_double() .

Definition at line 4432 of file xsh_utils.c.

References x, and y.

◆ xsh_min_int()

int xsh_min_int ( int  x,
int  y 
)

Minimum of two numbers.

Parameters
xFirst number
ySecond number
Returns
Minimum of x and y

See also xsh_round_double() .

Definition at line 4399 of file xsh_utils.c.

References x, and y.

◆ xsh_monitor_flux()

cpl_error_code xsh_monitor_flux ( cpl_frame *  frm_ima,
const cpl_frame *  frm_tab,
xsh_instrument instrument,
const char *  qc_key_prefix 
)


Monitor Flux level along the orders traces given by an input table

Parameters
frm_imaThe input frame image whose flux is to be monitored
frm_tabinput frame table with order traces
instrumentinstrument (arm setting)
Returns
The input frame image FITS header is updated with flux level QC parameters

Definition at line 4107 of file xsh_utils.c.

References binx, biny, check, xsh_instrument::decode_bp, instrument, XSH_ARM_NIR, xsh_free_image(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_get_arm(), xsh_msg, xsh_pfits_get_binx(), xsh_pfits_get_biny(), XSH_QC_FLUX_MAX_C, XSH_QC_FLUX_MIN_C, and xsh_update_pheader_in_image_multi().

Referenced by xsh_combine_flats_and_detect_edges(), xsh_mflat_combine_flats(), and xsh_orderpos().

◆ xsh_normalize_spectrum()

cpl_frame * xsh_normalize_spectrum ( const cpl_frame *  obj_frame,
const cpl_frame *  atm_ext_frame,
cpl_boolean  correct_binning,
xsh_instrument instrument,
const char *  tag_o 
)

Normalize a spectrum.

Parameters
obj_frameThe 1d (merged) or 2d (non-merged or 2d extracted+merged) spectrum to be normalized
atm_ext_frameThe frame of atmospheric extinction spectrum
correct_binningFlag to divide or not by the x-binning factor
instrumentInstrument setting (XSH ARM..)
tag_opro catg of output frame
Returns
The normalized spectrum

The spectrum is divided by exposure time, gain and (optionally) binning. Also corrected for atmospheric extinction using the provided table of extinction coefficients.

Bad pixels are propagated.xsh_utils.h

Definition at line 5807 of file xsh_utils.c.

References binx, check, exptime, instrument, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL_MSG, XSH_ATMOS_EXT_LIST_COLNAME_K, xsh_frame_product(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_get_arm(), xsh_msg_dbg_medium, xsh_normalize_spectrum_image_slice(), xsh_pfits_get_airm_mean(), xsh_pfits_get_exptime(), and xsh_pfits_get_gain().

Referenced by xsh_scired_util_spectra_flux_calibrate().

◆ xsh_normalize_spectrum_image()

cpl_image * xsh_normalize_spectrum_image ( const cpl_image *  spectrum,
const cpl_image *  spectrum_error,
const cpl_propertylist *  spectrum_header,
const int  bin_size,
const double  gain,
const double  exptime,
const double  airmass,
const int  n_traces,
const cpl_table *  atm_extinction,
cpl_image **  scaled_error 
)

Normalize a spectrum.

Parameters
spectrumThe 1d (merged) or 2d (non-merged or 2d extracted+merged) spectrum to be normalized
spectrum_errorError (1 sigma) of spectrum, or NULL.
spectrum_headerHeader describing the geometry of the input spectrum
binxx bin
gaindetector's gain
exptimeobserved object's exposure time
airmassobserved object's airmass
n_tracesNumber of spatial bins (1 unless 2d extracted)
atm_extinctionThe table of extinction coefficients
scaled_error(output) If non-NULL, error of output spectrum
Returns
The normalized spectrum

The spectrum is divided by exposure time, gain and (optionally) binning. Also corrected for atmospheric extinction using the provided table of extinction coefficients.

Bad pixels are propagated.xsh_utils.h

Definition at line 5996 of file xsh_utils.c.

References assure, check_msg, exptime, nx, ny, order, x, XSH_ASSURE_NOT_NULL_MSG, xsh_free_image(), xsh_msg_dbg_medium, xsh_pfits_get_cdelt1(), xsh_pfits_get_crval1(), and xsh_spline_hermite_table().

Referenced by xsh_normalize_spectrum_image_slice().

◆ xsh_normalize_spectrum_image_slice()

cpl_error_code xsh_normalize_spectrum_image_slice ( const char *  name_s,
const char *  tag_o,
const int  ext,
const int  bin_size,
const double  gain,
const double  exptime,
const double  airmass,
const cpl_table *  tbl_atm_ext 
)

Normalize spectrum slice.

Parameters
name_sspectrum filename
tag_ooutput frame pro catg
extextension value
binxX bin size
gaindetector's gain
exptimeexposure time
airmassairmass
tbl_atm_extatmospheric extinction table
Returns
CPL error code

The spectrum is divided by exposure time, gain and (optionally) binning. Also corrected for atmospheric extinction using the provided table of extinction coefficients.

Bad pixels are propagated.xsh_utils.h

Definition at line 5650 of file xsh_utils.c.

References check, exptime, xsh_free_image(), xsh_free_propertylist(), xsh_free_vector(), xsh_image_to_vector(), xsh_normalize_spectrum_image(), xsh_pfits_get_naxis(), xsh_pfits_set_pcatg(), XSH_PRE_DATA_BPP, XSH_PRE_DATA_TYPE, XSH_PRE_ERRS_BPP, XSH_PRE_ERRS_TYPE, XSH_PRE_QUAL_BPP, XSH_PRE_QUAL_TYPE, XSH_SPECTRUM_DATA_BPP, XSH_SPECTRUM_ERRS_BPP, and xsh_vector_to_image().

Referenced by xsh_normalize_spectrum(), and xsh_normalize_spectrum_ord().

◆ xsh_normalize_spectrum_ord()

cpl_frame * xsh_normalize_spectrum_ord ( const cpl_frame *  obj_frame,
const cpl_frame *  atm_ext_frame,
cpl_boolean  correct_binning,
xsh_instrument instrument,
const char *  tag_o 
)

Normalize a spectrum.

Parameters
obj_frameThe 1d (merged) or 2d (non-merged or 2d extracted+merged) spectrum to be normalized
atm_ext_frameThe frame with atmospheric extinction spectrum
correct_binningFlag indicating whether or not to divide by the x-binning factor
instrumentinstrument arm
tag_ooutput product tag
Returns
The normalized spectrum

The spectrum is divided by exposure time, gain and (optionally) binning. Also corrected for atmospheric extinction using the provided table of extinction coefficients.

Bad pixels are propagated.xsh_utils.h

Definition at line 5893 of file xsh_utils.c.

References binx, biny, check, exptime, instrument, XSH_ARM_NIR, XSH_ASSURE_NOT_NULL_MSG, XSH_ATMOS_EXT_LIST_COLNAME_K, XSH_ATMOS_EXT_LIST_COLNAME_OLD, xsh_frame_product(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_get_arm(), xsh_msg_dbg_medium, xsh_msg_warning, xsh_normalize_spectrum_image_slice(), xsh_pfits_get_airm_mean(), xsh_pfits_get_binx(), xsh_pfits_get_biny(), xsh_pfits_get_exptime(), and xsh_pfits_get_gain().

Referenced by xsh_flux_calibrate1D(), xsh_flux_calibrate2D(), and xsh_util_apply_response().

◆ xsh_order_frameset_by_date()

cpl_frameset * xsh_order_frameset_by_date ( cpl_frameset *  frameset)

◆ xsh_parameterlist_duplicate()

cpl_parameterlist * xsh_parameterlist_duplicate ( const cpl_parameterlist *  pin)

Extract frames with given tag from frameset.

Parameters
pininput parameterlist
Returns
newly allocated parametrlist or NULL on error

Definition at line 771 of file xsh_utils.c.

Referenced by xsh_lingain().

◆ xsh_plist_dump()

void xsh_plist_dump ( cpl_propertylist *  plist)

Dump propertylist.

Parameters
plistthe input propertylist
Returns
void

Definition at line 1026 of file xsh_utils.c.

References xsh_property_dump().

◆ xsh_polynomial_regression_2d()

polynomial * xsh_polynomial_regression_2d ( cpl_table *  t,
const char *  X1,
const char *  X2,
const char *  Y,
const char *  sigmaY,
int  degree1,
int  degree2,
const char *  polynomial_fit,
const char *  residual_square,
const char *  variance_fit,
double *  mse,
double *  red_chisq,
polynomial **  variance,
double  kappa,
double  min_reject 
)

Fit a 2d polynomial to three table columns.

Parameters
tThe table
X1Name of table column containing 1st independent variable
X2Name of table column containing 2nd independent variable
YName of table column containing dependent variable
sigmaYUncertainty of dependent variable. If NULL, constant uncertainties are assumed.
degree1Degree of polynomial fit (1st variable)
degree2Degree of polynomial fit (2nd variable)
polynomial_fitIf non-NULL, name of column to add. The fitted value.
residual_squareIf non-NULL, name of column to add. The squared residual of the fit.
variance_fitIf non-NULL, name of column to add. Variance of the fitted value.
[out]mseMean squared error of the residuals. May be NULL.
[out]red_chisqReduced chi square of the fit. May be NULL.
[out]varianceVariance of the fit-polynomial (which is in itself a polynomial; see also xsh_polynomial_fit_2d() ). May be NULL.
kappaIf positive, the value of kappa used in a kappa sigma-clipping. Ignored if negative.
min_rejectMinimum number of outliers worth rejecting. Stop iterating (for efficiency) if less than this relative number of outliers (e.g. 0.001) are detected. Negative to disable
Returns
Fitted polynomial

This function fits column Y (must be of type CPL_TYPE_DOUBLE) as function of X1 (CPL_TYPE_DOUBLE or CPL_TYPE_INT) and X2 (CPL_TYPE_DOUBLE or CPL_TYPE_INT). The column sigmaY contains the Y-uncertainties. If NULL, constant uncertainty equal to 1 is assumed.

If non-NULL the columns specified by the parameters polynomial_fit, residual_square and variance_fit are added to the table (containing the fitted value, the squared residual and the variance of the fitted value, for each point).

If non-NULL, the mean_squared_error and red_chisq (reduced chi square) are calculated.

If non-NULL the parameter variance will contain the polynomial that defines the variance of the fit (i.e. as function of x1 and x2 ).

To calculate variances or reduced chi square, the parameter sigmaY must be non-NULL.

If kappa is positive, a kappa-sigma clipping is performed (iteratively, until there are no points with residuals worse than kappa*sigma). The rejected points (rows) are physically removed from the table.

Also see xsh_polynomial_regression_1d() .

Definition at line 3423 of file xsh_utils.c.

References assure, check_msg, kappa, N, xsh_erase_table_rows(), xsh_msg_debug, xsh_polynomial_delete(), xsh_polynomial_evaluate_2d(), xsh_polynomial_fit_2d(), xsh_tostring_cpl_type(), xsh_unwrap_bivector_vectors(), xsh_unwrap_vector(), and y.

Referenced by xsh_background_poly().

◆ xsh_pow_int()

double xsh_pow_int ( double  x,
int  y 
)

Computes x^y.

Parameters
xbase
yorder
Returns
x^y

Definition at line 4463 of file xsh_utils.c.

References x, and y.

Referenced by xsh_polynomial_fit_1d().

◆ xsh_property_dump()

static void xsh_property_dump ( cpl_property *  property)
static

Dump property.

Parameters
propertyproperty to be dumped
Returns
void

Definition at line 797 of file xsh_utils.c.

References size.

Referenced by xsh_plist_dump().

◆ xsh_random_init()

void xsh_random_init ( void  )

Definition at line 109 of file xsh_utils.c.

◆ xsh_rectify_params_set_defaults()

cpl_error_code xsh_rectify_params_set_defaults ( cpl_parameterlist *  pars,
const char *  rec_id,
xsh_instrument inst,
xsh_rectify_param rectify_par 
)

◆ xsh_reindex()

void xsh_reindex ( double *  data,
int *  idx,
int  size 
)

TO BE DESCRIBED.

Parameters
data
idx
size

Definition at line 2008 of file xsh_utils.c.

References size, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_create_order_table().

◆ xsh_reindex_float()

void xsh_reindex_float ( float *  data,
int *  idx,
int  size 
)

TO BE DESCRIBED.

Parameters
data
idx
size

Definition at line 2038 of file xsh_utils.c.

References size, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

◆ xsh_reindex_int()

void xsh_reindex_int ( int *  data,
int *  idx,
int  size 
)

TO BE DESCRIBED.

Parameters
data
idx
size

Definition at line 2070 of file xsh_utils.c.

References size, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

◆ xsh_remove_crh_single_params_set_defaults()

cpl_error_code xsh_remove_crh_single_params_set_defaults ( cpl_parameterlist *  pars,
const char *  rec_id,
xsh_instrument inst,
xsh_remove_crh_single_param crh_single_par 
)

◆ xsh_round_double()

long xsh_round_double ( double  x)

◆ xsh_sdate_utc()

char * xsh_sdate_utc ( time_t *  now)

From the time in seconds, create a string in the format: YYYYMMDD-HHMMSS The date is UTC. The function uses cpl_malloc to allocate memory for the string. The space allocated must be freed with cpl_free

Parameters
nowDate in Unix/Linux format (seconds since 1970)
Returns
Pointer to the date string

Definition at line 1691 of file xsh_utils.c.

References XSH_CALLOC.

Referenced by xsh_add_product_orders_spectrum(), xsh_add_product_pre(), xsh_add_product_pre_3d(), xsh_add_product_spectrum(), xsh_create_final_name(), and xsh_pre_save_product().

◆ xsh_select_table_rows()

int xsh_select_table_rows ( cpl_table *  t,
const char *  column,
cpl_table_select_operator  operator,
double  value 
)

Select table rows.

Parameters
tTable
columnColumn name
operatorLogical operator
valueValue used for comparison
Returns
Number of selected rows

A row is selected if and only if the value in column is in the relation operator to the specified value. The specified column must have type CPL_TYPE_DOUBLE, CPL_TYPE_FLOAT or CPL_TYPE_INT. If integer, the integer nearest to value is used for the comparison.

Also see cpl_table_and_selected_<type>().

Definition at line 3784 of file xsh_utils.c.

References assure, check_msg, passure, xsh_round_double(), and xsh_tostring_cpl_type().

Referenced by xsh_background_poly(), and xsh_erase_table_rows().

◆ xsh_sess2deg()

double xsh_sess2deg ( const double  sess)

Convert a double from ssessagesimal to deg: 203049.197= 20:30:49.197 = 20.5136658333.

Parameters
sessangle in seesagesimal units (see above)
Returns
0 if suggess, else -1;

Definition at line 345 of file xsh_utils.c.

Referenced by xsh_build_ifu_map(), and xsh_cube_set_wcs().

◆ xsh_set_cd_matrix()

cpl_error_code xsh_set_cd_matrix ( cpl_propertylist *  plist)

Set CD matrix.

Parameters
plistinput propertylist
Returns
updated propertylist

Definition at line 676 of file xsh_utils.c.

References xsh_msg_error, xsh_pfits_get_naxis(), xsh_set_cd_matrix1d(), xsh_set_cd_matrix2d(), and xsh_set_cd_matrix3d().

◆ xsh_set_cd_matrix1d()

cpl_error_code xsh_set_cd_matrix1d ( cpl_propertylist *  plist)

Set CD matrix.

Parameters
plistinput propertylist
Returns
updated propertylist

Definition at line 701 of file xsh_utils.c.

References xsh_pfits_get_cdelt1(), and xsh_pfits_set_cd1().

Referenced by xsh_set_cd_matrix().

◆ xsh_set_cd_matrix2d()

cpl_error_code xsh_set_cd_matrix2d ( cpl_propertylist *  plist)

Set CD matrix.

Parameters
plistinput propertylist
Returns
updated propertylist

Definition at line 718 of file xsh_utils.c.

References check, xsh_pfits_get_cdelt1(), xsh_pfits_get_cdelt2(), xsh_pfits_set_cd11(), xsh_pfits_set_cd12(), xsh_pfits_set_cd21(), and xsh_pfits_set_cd22().

Referenced by xsh_set_cd_matrix(), and xsh_spectrum_2D_create().

◆ xsh_set_cd_matrix3d()

cpl_error_code xsh_set_cd_matrix3d ( cpl_propertylist *  plist)

Set CD matrix.

Parameters
plistinput propertylist
Returns
updated propertylist

Definition at line 744 of file xsh_utils.c.

References check, xsh_pfits_get_cdelt3(), xsh_pfits_set_cd13(), xsh_pfits_set_cd23(), xsh_pfits_set_cd31(), xsh_pfits_set_cd32(), and xsh_pfits_set_cd33().

Referenced by xsh_cube(), xsh_format(), and xsh_set_cd_matrix().

◆ xsh_set_recipe_file_prefix()

char * xsh_set_recipe_file_prefix ( cpl_frameset *  raw,
const char *  recipe 
)

◆ xsh_set_recipe_sky_file_prefix()

const char * xsh_set_recipe_sky_file_prefix ( char *  rec_prefix)

Set recipe sky frames prefix.

Parameters
rec_prefixinput recipe name
Returns
recipe products prefix

Definition at line 576 of file xsh_utils.c.

Referenced by xsh_respon_slit_offset(), xsh_respon_slit_stare(), xsh_scired_ifu_offset(), xsh_scired_slit_offset(), and xsh_scired_slit_stare().

◆ xsh_show_time()

void xsh_show_time ( const char *  comment)

show time

Parameters
commentcomment to print

Definition at line 2389 of file xsh_utils.c.

References xsh_msg.

◆ xsh_sort()

int * xsh_sort ( void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

Sort an array and give is index table.

Parameters
base
nmemb
size
compar

Definition at line 1966 of file xsh_utils.c.

References xsh_sort_data::data, xsh_sort_data::idx, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, XSH_FREE, and XSH_MALLOC.

Referenced by xsh_create_order_table().

◆ xsh_sort_table_1()

cpl_error_code xsh_sort_table_1 ( cpl_table *  t,
const char *  column,
cpl_boolean  reverse 
)

Sort a table by one column.

Parameters
tTable
columnColumn name
reverseFlag indicating if column values are sorted descending (CPL_TRUE) or ascending (CPL_FALSE)
Returns
CPL_ERROR_NONE iff OK
Note
derived from UVES pipeline

This is a wrapper of cpl_table_sort().

Definition at line 530 of file xsh_utils_table.c.

References assure, check_msg, and xsh_free_propertylist().

Referenced by create_sky_mask(), test_spectrum_detect_lines(), xsh_bspline_smooth_uniform_sl(), xsh_cfg_recover_prepare_pm_set(), xsh_compute_absorp(), xsh_fit_spline1(), xsh_fit_spline2(), xsh_localize_ifu_slitlet(), xsh_localize_obj_auto(), xsh_table_unique_column(), and xsh_wavemap_list_new().

◆ xsh_sort_table_2()

cpl_error_code xsh_sort_table_2 ( cpl_table *  t,
const char *  column1,
const char *  column2,
cpl_boolean  reverse1,
cpl_boolean  reverse2 
)

Sort a table by two columns.

Parameters
tTable
column11st column name
column22nd column name
reverse1Flag indicating if 1st column values are sorted descending (true) or ascending (CPL_FALSE)
reverse2Flag indicating if 2nd column values are sorted descending (true) or ascending (CPL_TRUE)
Returns
CPL_ERROR_NONE iff OK
Note
derived from UVES pipeline

This is a wrapper of cpl_table_sort(). column1 is the more significant column (i.e. values in column2 are compared, only if the values in column1 are equal).

Definition at line 568 of file xsh_utils_table.c.

References assure, check_msg, and xsh_free_propertylist().

◆ xsh_sort_table_3()

cpl_error_code xsh_sort_table_3 ( cpl_table *  t,
const char *  column1,
const char *  column2,
const char *  column3,
cpl_boolean  reverse1,
cpl_boolean  reverse2,
cpl_boolean  reverse3 
)

Sort a table by two columns.

Parameters
tTable
column11st column name
column22nd column name
column33rd column name
reverse1Flag indicating if 1st column values are sorted descending (CPL_TRUE) or ascending (CPL_FALSE)
reverse2Flag indicating if 2nd column values are sorted descending (CPL_TRUE) or ascending (CPL_FALSE)
reverse3Flag indicating if 3rd column values are sorted descending (CPL_TRUE) or ascending (CPL_FALSE)
Returns
CPL_ERROR_NONE iff OK
Note
derived from UVES pipeline

This is a wrapper of cpl_table_sort(). column1 is the more significant column (i.e. values in column2 are compared, only if the values in column1 are equal).

Definition at line 612 of file xsh_utils_table.c.

References assure, check_msg, and xsh_free_propertylist().

Referenced by xsh_create_sampl_table(), xsh_create_sampl_uniform_continuum(), and xsh_skycorr_wave_sampling_create().

◆ xsh_spectrum_integrate()

static double xsh_spectrum_integrate ( double *  pif,
double *  piw,
int  i1_inf,
int  i1_sup,
int  i2_inf,
int  i2_sup,
double  wave,
double  wstep 
)
static

Definition at line 5276 of file xsh_utils.c.

Referenced by xsh_spectrum_resample().

◆ xsh_spectrum_interpolate()

cpl_frame * xsh_spectrum_interpolate ( cpl_frame *  table_frame,
const double  wstep,
const double  wmin,
const double  wmax 
)

spectra interpolation

Parameters
table_frametable frame containing the spectrum
wstepwave step
wminwave min
wmaxwave max

Definition at line 6306 of file xsh_utils.c.

References check, check_msg, xsh_add_temporary_file(), XSH_ASSURE_NOT_ILLEGAL_MSG, XSH_ASSURE_NOT_NULL_MSG, xsh_frame_product(), xsh_free_propertylist(), xsh_free_table(), xsh_msg_dbg_medium, xsh_pfits_set_pcatg(), and xsh_spline_hermite_table().

Referenced by xsh_compute_response(), and xsh_compute_response_ord().

◆ xsh_spectrum_interpolate_linear()

cpl_frame * xsh_spectrum_interpolate_linear ( cpl_frame *  table_frame,
const double  wstep,
const double  wmin,
const double  wmax 
)

spectra interpolation

Parameters
table_frametable frame containing the spectrum
wstepwave step
wminwave min
wmaxwave max

Definition at line 6213 of file xsh_utils.c.

References check, xsh_add_temporary_file(), XSH_ASSURE_NOT_ILLEGAL_MSG, XSH_ASSURE_NOT_NULL_MSG, xsh_frame_product(), xsh_free_propertylist(), xsh_free_table(), xsh_iterpol_linear(), and xsh_pfits_set_pcatg().

Referenced by xsh_compute_response2().

◆ xsh_spectrum_resample()

cpl_frame * xsh_spectrum_resample ( cpl_frame *  frame_inp,
const double  wstep,
const double  wmin,
const double  wmax,
xsh_instrument instr 
)

resample a spectrum

Parameters
[in]frame_inpinput spectrum
[in]wstepoutput spectrum wavelength step
[in]wminmin wave on the given arm
[in]wmaxmax wave on the given arm
[in]instrinstrument setting
Returns
1D resampled spectrum frame

Definition at line 5336 of file xsh_utils.c.

References check, xsh_add_temporary_file(), XSH_ARM_UVB, XSH_ATM_EXT_UVB_WAV_MIN, xsh_frame_product(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_arm_tostring(), xsh_instrument_get_arm(), xsh_msg, xsh_spectrum_integrate(), and xsh_util_get_infsup().

Referenced by xsh_compute_response().

◆ xsh_spline_hermite()

double xsh_spline_hermite ( double  xp,
const double *  x,
const double *  y,
int  n,
int *  istart 
)

Spline interpolation based on Hermite polynomials.

Parameters
xpx-value to interpolate
xx-values
yy-values
narray length
istart(input/output) initial row (set to 0 to search all row)
Returns
The interpolated value.

The x column must be sorted (ascending or descending) and all x column values must be different.

Adopted from: Cristian Levin - ESO La Silla, 1-Apr-1991

Definition at line 4577 of file xsh_utils.c.

References n, x, and y.

Referenced by xsh_spline_hermite_table().

◆ xsh_spline_hermite_table()

double xsh_spline_hermite_table ( double  xp,
const cpl_table *  t,
const char *  column_x,
const char *  column_y,
int *  istart 
)

Spline interpolation based on Hermite polynomials.

Parameters
xpx-value to interpolate
tTable containing the columns to interpolate
column_xColumn of x-values
column_yColumn of y-values
istart(input/output) initial row (set to 0 to search all row)
Returns
The interpolated value.

Definition at line 4648 of file xsh_utils.c.

References check_msg, n, x, xsh_spline_hermite(), and y.

Referenced by xsh_normalize_spectrum_image(), xsh_spectrum_interpolate(), xsh_util_multiply_by_response(), and xsh_util_multiply_by_response_ord().

◆ xsh_string_tolower()

const char * xsh_string_tolower ( char *  s)

Convert all uppercase characters in a string into lowercase characters.

Parameters
sThe string to convert.
Returns
Returns a pointer to the converted string.

Walks through the given string and turns uppercase characters into lowercase characters using tolower().

See also
xsh_string_tolower()

Definition at line 4508 of file xsh_utils.c.

References s.

◆ xsh_string_toupper()

const char * xsh_string_toupper ( char *  s)

Convert all lowercase characters in a string into uppercase characters.

Parameters
sThe string to convert.
Returns
Returns a pointer to the converted string.

Walks through the given string and turns lowercase characters into uppercase characters using toupper().

See also
xsh_string_tolower()

Definition at line 4542 of file xsh_utils.c.

References s.

Referenced by xsh_molecfit_model_qc(), and xsh_parameters_subtract_sky_single_get().

◆ xsh_stringcat()

char * xsh_stringcat ( const char *  s1,
const char *  s2 
)

String concatenation.

Parameters
s1First string
s2Second string
Returns
s1 concatenated with s2, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1719 of file xsh_utils.c.

References assure.

◆ xsh_stringcat_3()

char * xsh_stringcat_3 ( const char *  s1,
const char *  s2,
const char *  s3 
)

String concatenation.

Parameters
s1First string
s2Second string
s3Third string
Returns
s1 concatenated with s2 concatenated with s3, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1753 of file xsh_utils.c.

References assure.

Referenced by xsh_find_frame().

◆ xsh_stringcat_4()

char * xsh_stringcat_4 ( const char *  s1,
const char *  s2,
const char *  s3,
const char *  s4 
)

String concatenation.

Parameters
s1First string
s2Second string
s3Third string
s4Fourth string
Returns
s1 concatenated with s2 concatenated with s3 concatenated with s4, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1791 of file xsh_utils.c.

References assure.

Referenced by xsh_begin(), and xsh_unique_filename().

◆ xsh_stringcat_5()

char * xsh_stringcat_5 ( const char *  s1,
const char *  s2,
const char *  s3,
const char *  s4,
const char *  s5 
)

String concatenation.

Parameters
s1First string
s2Second string
s3Third string
s4Fourth string
s5Fifth string
Returns
s1 concatenated with s2 concatenated with s3 concatenated with s4 concatenated with s5, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1831 of file xsh_utils.c.

References assure.

◆ xsh_stringcat_6()

char * xsh_stringcat_6 ( const char *  s1,
const char *  s2,
const char *  s3,
const char *  s4,
const char *  s5,
const char *  s6 
)

String concatenation.

Parameters
s1First string
s2Second string
s3Third string
s4Fourth string
s5Fifth string
s6Sixth string
Returns
s1 concatenated with s2 concatenated with s3 concatenated with s4 concatenated with s5 concatenated with s6, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1875 of file xsh_utils.c.

References assure.

Referenced by xsh_unique_filename().

◆ xsh_stringcat_any()

char * xsh_stringcat_any ( const char *  s,
  ... 
)

Concatenate an arbitrary number of strings.

Parameters
sFirst string
...Other strings (at least 1 more)
Returns
Pointer to concatenated string or NULL if error
Note
The resulting string must be deallocated using cpl_free()
THE LAST STRING MUST BE a NULL ptr or AN EMPTY STRING (""). However, one should not just use the plain NULL macro in the parameter list, since this can lead to undefined behaviour. On some platforms the NULL macro might not expant to a pointer type, i.e. sizeof(NULL) might not equal sizeof(void*). Instead one should use code like the following:
y = xsh_stringcat_any(x, (void*)NULL)
int * y
int * x
char * xsh_stringcat_any(const char *s,...)
Concatenate an arbitrary number of strings.
Definition: xsh_utils.c:1925

Definition at line 1925 of file xsh_utils.c.

References assure, s, and size.

Referenced by irplib_paf_init(), main(), save_centers(), xsh_2dmap(), xsh_add_product_orders_spectrum(), xsh_add_product_pre(), xsh_add_product_pre_3d(), xsh_add_product_spectrum(), xsh_add_product_table(), xsh_cfg_recover_last_step(), xsh_combine_nod(), xsh_create_final_name(), xsh_create_final_tag(), xsh_extract_clean_with_tag(), xsh_extract_with_tag(), xsh_find_calpro_model_config(), xsh_find_calpro_model_meas_coord(), xsh_find_model_config_open(), xsh_find_model_testpar(), xsh_find_model_wavelist(), xsh_find_raw_arc_slit_nir_off(), xsh_find_raw_arc_slit_nir_on(), xsh_find_raw_arc_slit_uvb_vis(), xsh_find_raw_orderdef_nir(), xsh_find_raw_orderdef_nir_off(), xsh_find_raw_orderdef_vis_uvb(), xsh_find_spectral_format(), xsh_hdrl_remove_crh_single(), xsh_linear(), xsh_merge_ord_with_tag(), xsh_model_first_anneal(), xsh_parameters_new_string(), xsh_parameters_stack_create(), xsh_predict(), xsh_remove_crh_single(), xsh_scired_ifu_offset(), xsh_scired_ifu_stare(), xsh_set_recipe_file_prefix(), xsh_shift(), xsh_wavemap_list_save(), xsh_wavemap_list_save2(), and xsh_wavemap_list_save4debug().

◆ xsh_stringdup()

char * xsh_stringdup ( const char *  s)

String duplication.

Parameters
sString to duplicate
Returns
A copy of s, or NULL on error.
Note
The resulting string must be deallocated using cpl_free()

Definition at line 1658 of file xsh_utils.c.

References assure, and s.

Referenced by xsh_arclist_load(), and xsh_find_frame().

◆ xsh_table_interpolate()

double xsh_table_interpolate ( cpl_table *  tbl,
double  wav,
const char *  colx,
const char *  coly 
)

Interpolate table columns.

Parameters
tblTable
wavvalue at which is desired to get an interpolated value
colx1st column name
coly2nd column name
Returns
interpolated value if ok

Definition at line 715 of file xsh_utils_table.c.

References check, xsh_data_interpolate(), and y.

Referenced by xsh_utils_efficiency_internal().

◆ xsh_table_merge_clean_and_resid_tabs()

cpl_error_code xsh_table_merge_clean_and_resid_tabs ( cpl_frame *  frm_resid,
cpl_frame *  frm_clean 
)

◆ xsh_table_monitor_flux_qc()

static cpl_error_code xsh_table_monitor_flux_qc ( cpl_table *  table,
const double  ws,
const double  we,
const char *  prefix,
const int  index,
cpl_propertylist **  header 
)
static

Computes statistics on spectrum for QC.

Parameters
[in]tableinput table
[in]wswavelength start value
[in]wewavelength end value
[in]prefixprefix of QC parameter
[in]indexindex to specify QC parameter name
[out]headerheader containing computed QC key
Returns
CPL error code

Definition at line 747 of file xsh_utils_table.c.

References check, and xsh_free_table().

Referenced by xsh_frame_table_monitor_flux_qc_ext().

◆ xsh_table_select_matching_waves()

static cpl_table * xsh_table_select_matching_waves ( cpl_table *  table_intmon,
const char *  col_wave_intmon,
cpl_table *  table_check,
const char *  col_wave_intcheck,
const double  exptime 
)
static

Match reference and actual table via wavelength column.

Parameters
table_intmontable on which QC log is computed
col_wave_intmonintmon table wavelength column
table_checktable on which QC log is computed
col_wave_checkcheck table wavelength column

Definition at line 277 of file xsh_utils_table.c.

References check, exptime, tolerance, and xsh_wavecal_find_nearest().

Referenced by xsh_wavecal_qclog_element().

◆ xsh_table_shift_rv()

cpl_table * xsh_table_shift_rv ( cpl_table *  orig,
const char *  col_wave,
const double  offset 
)

Definition at line 977 of file xsh_utils_table.c.

References XSH_ASSURE_NOT_NULL_MSG.

Referenced by xsh_compute_response2().

◆ xsh_time_stamp_get()

int xsh_time_stamp_get ( void  )

◆ xsh_time_stamp_set()

int xsh_time_stamp_set ( int  ts)

set timestamp

Parameters
tstime stamp index
Returns
timestamp

Definition at line 3179 of file xsh_utils.c.

References XshTimeStamp.

Referenced by xsh_parameters_time_stamp_get().

◆ xsh_tools_get_median_double()

double xsh_tools_get_median_double ( double *  array,
int  size 
)

Calculates the median value of an array of double.

Parameters
arrayThe input array
sizeThe size of the array
Returns
The median value

The first step is to sort in ascending ordre. Then the median is calculated: if size is an odd number, the median is the value of the size/2+1-th element. If size is an even number, the median is the average of the 2 elements size/2 and size/2+1. The input array is MODIFIED.

Definition at line 2721 of file xsh_utils.c.

References max, size, and xsh_tools_sort_double().

Referenced by flag_noisy_pixels(), and xsh_tools_running_median_1d_get_max().

◆ xsh_tools_get_statistics()

void xsh_tools_get_statistics ( double *  tab,
int  size,
double *  median,
double *  mean,
double *  stdev 
)

Compute median, stdev and mean for the tab.

Parameters
[in]tabthe input array
[in]sizethe size of input array
[out]medianthe median of array
[out]meanthe mean of array
[out]stdevthe stdev of array
Returns
void

Definition at line 2421 of file xsh_utils.c.

References check, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_NULL, and xsh_free_vector().

◆ xsh_tools_min_max()

void xsh_tools_min_max ( int  size,
double *  tab,
double *  min,
double *  max 
)

computes min & max in ab array

Parameters
sizesize of array
tabarray
minminimum
maxmaximum
Returns
void

Definition at line 2799 of file xsh_utils.c.

References max, size, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

Referenced by lambda_fit(), and xsh_wavesol_compute().

◆ xsh_tools_running_median_1d_get_max()

int xsh_tools_running_median_1d_get_max ( double *  tab,
int  size,
int  wsize 
)

get max of a list of doubles after running median

Parameters
tablist of values
sizenumber of values
wsizewindow size for running median

Definition at line 2748 of file xsh_utils.c.

References max, size, XSH_ASSURE_NOT_NULL, XSH_FREE, XSH_MALLOC, and xsh_tools_get_median_double().

Referenced by xsh_fit_gaussian().

◆ xsh_tools_sort_double()

cpl_error_code xsh_tools_sort_double ( double *  pix_arr,
int  n 
)

Sort a double array.

Parameters
pix_arrthe array to sort
nthe array size
Returns
the #_cpl_error_code_ or CPL_ERROR_NONE

From the cpl_tools_sort_double. Possible #_cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

Definition at line 2461 of file xsh_utils.c.

References n, XSH_DOUBLE_SWAP, and XSH_PIX_STACK_SIZE.

Referenced by xsh_tools_get_median_double().

◆ xsh_tools_sort_float()

cpl_error_code xsh_tools_sort_float ( float *  pix_arr,
int  n 
)

Sort a float array.

Parameters
pix_arrthe array to sort
nthe array size
Returns
the #_cpl_error_code_ or CPL_ERROR_NONE

From the cpl_tools_sort_double. Possible #_cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

Definition at line 2548 of file xsh_utils.c.

References n, XSH_FLOAT_SWAP, and XSH_PIX_STACK_SIZE.

◆ xsh_tools_sort_int()

cpl_error_code xsh_tools_sort_int ( int *  pix_arr,
int  n 
)

Sort an integer array.

Parameters
pix_arrthe array to sort
nthe array size
Returns
the #_cpl_error_code_ or CPL_ERROR_NONE

Possible #_cpl_error_code_ set in this function:

  • CPL_ERROR_NULL_INPUT
  • CPL_ERROR_ILLEGAL_INPUT

Definition at line 2633 of file xsh_utils.c.

References n, XSH_INT_SWAP, and XSH_PIX_STACK_SIZE.

◆ xsh_tools_tchebitchev_poly_eval()

cpl_vector * xsh_tools_tchebitchev_poly_eval ( int  n,
double  X 
)

Compute tchebitchev Tn(X) first coefficient for tchebitchev polynomial.

Parameters
nindex of the last term to be computed (0 to n)
Xvalue of X in evaluation of the polynomial
Returns
the result of evaluation of the n first terms of tchebitchev polynomial

Definition at line 2836 of file xsh_utils.c.

References check, n, XSH_ASSURE_NOT_ILLEGAL, and xsh_free_vector().

Referenced by lambda_fit(), test_tech_eval_perf(), xsh_wavemap_list_eval_lambda(), xsh_wavesol_eval_polx(), and xsh_wavesol_eval_poly().

◆ xsh_tools_tchebitchev_reverse_transform()

double xsh_tools_tchebitchev_reverse_transform ( double  pos,
double  min,
double  max 
)

computes reverse Tchebitchev transformation

Parameters
posposition
minminimum
maxmaximum
Returns
inverse Tchebischev transformation

Definition at line 2954 of file xsh_utils.c.

References max, and XSH_ASSURE_NOT_ILLEGAL.

Referenced by xsh_wavemap_list_eval_lambda(), xsh_wavesol_eval_polx(), and xsh_wavesol_eval_poly().

◆ xsh_tools_tchebitchev_transform()

double xsh_tools_tchebitchev_transform ( double  pos,
double  min,
double  max 
)

computes Tchebitchev transformation

Parameters
posposition
minminimum
maxmaximum
Returns
Tchebischev transformation

Definition at line 2917 of file xsh_utils.c.

References max, XSH_ASSURE_NOT_ILLEGAL, and xsh_msg_dbg_medium.

Referenced by xsh_wavemap_list_eval_lambda(), xsh_wavesol_eval_polx(), and xsh_wavesol_eval_poly().

◆ xsh_tools_tchebitchev_transform_tab()

void xsh_tools_tchebitchev_transform_tab ( int  size,
double *  pos,
double  min,
double  max,
double *  tcheb_pos 
)

computes Tchebitchev transformation

Parameters
sizesaze of array
posposition array
minminimum
maxmaximum
tcheb_postransformed position array
Returns
Tchebischev transformation applied on input array

Definition at line 2881 of file xsh_utils.c.

References max, size, XSH_ASSURE_NOT_ILLEGAL, and XSH_ASSURE_NOT_NULL.

Referenced by lambda_fit(), xsh_wavesol_compute(), and xsh_wavesol_residual().

◆ xsh_unwrap_array()

void xsh_unwrap_array ( cpl_array **  a)

Unwrap an array and set the pointer to NULL.

Parameters
aArray to unwrap

Definition at line 2361 of file xsh_utils.c.

Referenced by set_qc_parameters(), and xsh_detect_arclines_dan().

◆ xsh_unwrap_bivector_vectors()

void xsh_unwrap_bivector_vectors ( cpl_bivector **  b)

Unwrap a bi-vector and set the pointer to NULL.

Parameters
bBi-vector to deallocate

Definition at line 2376 of file xsh_utils.c.

Referenced by xsh_polynomial_regression_2d().

◆ xsh_unwrap_image()

void xsh_unwrap_image ( cpl_image **  i)

Unwrap an image and set the pointer to NULL.

Parameters
iImage to unwrap

Definition at line 2330 of file xsh_utils.c.

Referenced by xsh_opt_extract_orders().

◆ xsh_unwrap_vector()

void xsh_unwrap_vector ( cpl_vector **  v)

◆ xsh_update_pheader_in_image_multi()

cpl_error_code xsh_update_pheader_in_image_multi ( cpl_frame *  frame,
const cpl_propertylist *  pheader 
)

Update FITS header.

Parameters
frameThe frame whose frame need to be updated
pheaderThe primary header to copy to the frame
Returns
The error code

Definition at line 4258 of file xsh_utils.c.

References check, XSH_ASSURE_NOT_NULL, xsh_free_image(), xsh_free_propertylist(), and xsh_msg_dbg_medium.

Referenced by xsh_monitor_flux(), and xsh_wavemap_qc().

◆ xsh_util_frameset_collapse_mean()

cpl_frame * xsh_util_frameset_collapse_mean ( cpl_frameset *  set,
xsh_instrument instrument 
)

Compute mean frame from a list of (IMAGE) framesets.

Parameters
setThe input frameset
instrumentThe instrument structure
Returns
The mean frameset

Definition at line 5538 of file xsh_utils.c.

References check, instrument, size, xsh_add_temporary_file(), xsh_frame_product(), xsh_free_image(), xsh_free_propertylist(), xsh_instrument_arm_tostring(), XSH_PRE_DATA_BPP, XSH_PRE_DATA_TYPE, XSH_PRE_ERRS_BPP, XSH_PRE_ERRS_TYPE, XSH_PRE_QUAL_BPP, and XSH_PRE_QUAL_TYPE.

Referenced by xsh_scired_ifu_offset().

◆ xsh_util_get_infsup()

static cpl_error_code xsh_util_get_infsup ( double *  piw,
double  w,
int  i_start,
int  i_end,
int *  i_inf,
int *  i_sup 
)
static

Definition at line 5255 of file xsh_utils.c.

Referenced by xsh_spectrum_resample().

◆ xsh_util_multiply_by_response()

cpl_frame * xsh_util_multiply_by_response ( cpl_frame *  merged_sci,
cpl_frame *  response,
const char *  tag_o 
)

◆ xsh_util_multiply_by_response_ord()

cpl_frame * xsh_util_multiply_by_response_ord ( cpl_frame *  extracted_sci,
cpl_frame *  response,
const char *  tag_o 
)

◆ xsh_vector_fit_gaussian()

void xsh_vector_fit_gaussian ( cpl_vector *  x,
cpl_vector *  y,
XSH_GAUSSIAN_FIT result 
)

set debug level

Parameters
xvector with independent variable
yvector with dependent variable
resultstructure containing results (peakpos,sigma,area,offset,mse)
Returns
results of Gaussian fit
Note
wrapper to cpl_vector_fit_gaussian (assumes no errors on X,Y);

Definition at line 3101 of file xsh_utils.c.

References XSH_GAUSSIAN_FIT::area, XSH_GAUSSIAN_FIT::mse, XSH_GAUSSIAN_FIT::offset, XSH_GAUSSIAN_FIT::peakpos, XSH_GAUSSIAN_FIT::sigma, x, XSH_ASSURE_NOT_NULL, and y.

Referenced by detect_centroid(), xsh_image_fit_gaussian_max_pos_x_window(), and xsh_image_fit_gaussian_max_pos_y_window().

◆ xsh_vector_get_err_mean()

double xsh_vector_get_err_mean ( cpl_vector *  vect)

Computes mean error on a data set.

Parameters
vectinput data
Returns
mean error

Definition at line 4354 of file xsh_utils.c.

References check, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_rec_list_add().

◆ xsh_vector_get_err_median()

double xsh_vector_get_err_median ( cpl_vector *  vect)

Computes median error on a data set.

Parameters
vectinput data
Returns
median error

Definition at line 4319 of file xsh_utils.c.

References check, M_PI, and XSH_ASSURE_NOT_NULL.

Referenced by xsh_rec_list_add().

◆ xsh_vector_to_image()

cpl_image * xsh_vector_to_image ( const cpl_vector *  vector,
cpl_type  type 
)

Convert a vector to a 1d image.

Parameters
vectorto convert
typeof image
Returns
a new allocated 1d image whose elements are the same as the vector The image need to be allocated .

Definition at line 4745 of file xsh_utils.c.

References assure, size, and xsh_free_image().

Referenced by xsh_normalize_spectrum_image_slice(), xsh_util_multiply_by_response(), and xsh_util_multiply_by_response_ord().

◆ xsh_wavecal_find_nearest()

static int xsh_wavecal_find_nearest ( const cpl_table *  line_refer,
const char *  col_ref,
double  lambda,
int  lo,
int  hi 
)
static

Find best matching catalogue wavelength.

Parameters
line_referTable to search
lambdaFind catalogue wavelength nearest to this wavelength
loFirst row (inclusive, counting from 0) of table to search
hiLast row (inclusive, counting from 0) of table to search
Returns
The index of the row containing the wavelength closest to lambda

This function returns the index of the nearest wavelength in the range {lo, ..., hi} The input table must be sorted according to the column "Wave" which is the column that is searched.

Note
The function implements a binary search (using recursion) which is why the input table must be sorted.

Definition at line 178 of file xsh_utils_table.c.

References check, and xsh_wavecal_find_nearest().

Referenced by xsh_table_select_matching_waves(), and xsh_wavecal_find_nearest().

◆ xsh_wavecal_qclog_compute()

static cpl_error_code xsh_wavecal_qclog_compute ( cpl_table *  temp,
cpl_propertylist **  header_check,
const char *  element,
const double  exptime 
)
static

computes intmon QC log

Parameters
tabletable on which QC log is computed
headerframe header of bright lines
elementatomic element the line refers to
exptimeframe exposure time

Definition at line 225 of file xsh_utils_table.c.

References check, exptime, QC_WAVECAL_INTAVG, QC_WAVECAL_INTAVG_C, QC_WAVECAL_NLININT, QC_WAVECAL_NLININT_C, and xsh_msg_warning.

Referenced by xsh_wavecal_qclog_element().

◆ xsh_wavecal_qclog_element()

static cpl_error_code xsh_wavecal_qclog_element ( cpl_table *  table_intmon,
cpl_table *  table_check,
const double  exptime,
const char *  atom_name,
cpl_propertylist **  header_check 
)
static

computes intmon QC log

Parameters
table_intmontable of bright lines
table_checkline detection table on which QC log is computed
exptimeframe exposure time
atom_nameatom name
header_checkframe header where to loh QC

Definition at line 370 of file xsh_utils_table.c.

References exptime, xsh_free_table(), xsh_table_select_matching_waves(), and xsh_wavecal_qclog_compute().

Referenced by xsh_wavecal_qclog_intmon().

◆ xsh_wavecal_qclog_intmon()

cpl_error_code xsh_wavecal_qclog_intmon ( cpl_frame *  line_check,
const cpl_frame *  line_intmon,
const double  exptime,
xsh_instrument inst 
)

computes intmon QC log

Parameters
table_checkframe line detection table on which QC log is computed
line_intmonframe table of bright lines
exptimeframe exposure time
instX-shooter instrument arm/lamp setting

Definition at line 409 of file xsh_utils_table.c.

References check, exptime, XSH_ARM_NIR, xsh_free_propertylist(), xsh_free_table(), xsh_instrument_get_arm(), and xsh_wavecal_qclog_element().

Referenced by xsh_2dmap(), and xsh_predict().

Variable Documentation

◆ deg

int data::deg

Definition at line 6753 of file xsh_utils.c.

Referenced by expb_df(), and xsh_gsl_fit_gaussian().

◆ frame

cpl_frame* FRAME_DATE_IDX::frame

Definition at line 3279 of file xsh_utils.c.

Referenced by xsh_order_frameset_by_date().

◆ frame_date

double FRAME_DATE_IDX::frame_date

Definition at line 3277 of file xsh_utils.c.

Referenced by xsh_order_frameset_by_date().

◆ frame_idx

int FRAME_DATE_IDX::frame_idx

Definition at line 3278 of file xsh_utils.c.

Referenced by xsh_order_frameset_by_date().

◆ frame_name

const char* FRAME_DATE_IDX::frame_name

Definition at line 3280 of file xsh_utils.c.

Referenced by xsh_order_frameset_by_date().

◆ n

size_t data::n

Definition at line 11 of file xsh_ngaussfdf.h.

Referenced by xsh_gsl_fit_gaussian().

◆ NbProducts

int NbProducts = 0
static

Definition at line 1422 of file xsh_utils.c.

Referenced by xsh_add_product_file(), and xsh_free_product_files().

◆ NbTemp

int NbTemp = 0
static

Definition at line 1420 of file xsh_utils.c.

Referenced by xsh_add_temporary_file(), xsh_end(), and xsh_free_temporary_files().

◆ ProdFiles

char** ProdFiles = NULL
static

Definition at line 1421 of file xsh_utils.c.

Referenced by xsh_add_product_file(), and xsh_free_product_files().

◆ TempFiles

char** TempFiles = NULL
static

Definition at line 1419 of file xsh_utils.c.

Referenced by xsh_add_temporary_file(), xsh_end(), and xsh_free_temporary_files().

◆ x

double* data::x

Definition at line 6752 of file xsh_utils.c.

Referenced by xsh_gsl_fit_gaussian().

◆ y

double * data::y

Definition at line 14 of file xsh_ngaussfdf.h.

Referenced by xsh_gsl_fit_gaussian().