X-shooter Pipeline Reference Manual 3.8.15
Macros | Functions
Functions for the wl model computation

Macros

#define ERROR   1
 
#define ERROR   1
 
#define OK   0
 
#define OK   0
 

Functions

static void xsh_nullmatrix (mat A)
 
static void xsh_nullvector (vec a)
 
static void xsh_copyvector (vec a, vec b)
 
static const char * xsh_get_tag_opt_mod_cfg (xsh_xs_3 *p_xs_3, int rec_id)
 
static cpl_error_code xsh_model_compute_residuals (xsh_xs_3 *p_xs_3, coord *msp_coord, DOUBLE *p_wlarray, DOUBLE **ref_ind, const int size, const int annealed, cpl_propertylist *resid_header, cpl_frame *resid_frame, cpl_propertylist **result)
 
void xsh_3_init (struct xs_3 *p_xs_3)
 Pre-compute a number of non-wavelength dependent secondary parameters required by the model.
 
void xsh_3_eval (DOUBLE lambda, int morder, DOUBLE **ref_ind, struct xs_3 *p_xs_3)
 Compute the physical x,y position at the detector array for a given wavelength, order and parameter configuration.
 
void xsh_3_detpix (struct xs_3 *p_xs_3)
 Takes the physical x,y position at the detector array and converts this to a pixel position.
 
void xsh_ref_ind_read_old (const char *ref_ind_file, DOUBLE **ref_ind, DOUBLE temper)
 Load the refractive index array for a given arm and temperature. This old routine is only retained to allow easy testing of new refractive index data.
 
void xsh_ref_ind_read (int arm, DOUBLE **ref_ind_T, DOUBLE temper)
 Load the refractive index coeffs for a given arm and temperature.
 
int * xsh_alloc1Darray_INT (int asize)
 allocates memory for an array of integers
 
DOUBLExsh_alloc1Darray (int asize)
 allocates memory for an array of doubles
 
double ** xsh_alloc2Darray (int asize, int bsize)
 allocates memory for a 2D array of doubles
 
float ** xsh_alloc2Darray_f (int asize, int bsize)
 allocates memory for a 2D array of floats
 
int ** xsh_alloc2Darray_i (int asize, int bsize)
 allocates memory for a 2D array of integers
 
int xsh_free2Darray (double **ccdtemp, int asize)
 free memory for a 2D array of doubles
 
int xsh_free2Darray_i (int **ccdtemp, int asize)
 free memory for a 2D array of integers
 
int xsh_free2Darray_f (float **ccdtemp, int asize)
 free memory for a 2D array of floats
 
double * xsh_copy2D_to_1D (double **ccdtemp, int asize, int bsize)
 copy 2D to 1D array
 
double ** xsh_copy1D_to_2D (double *oneDccdtemp, int asize, int bsize)
 copy 1D to 2D array
 
double *** xsh_alloc3Darray2 (int asize, int bsize, int csize)
 allocate 3D array
 
double *** xsh_alloc3Darray (int asize, int bsize, int csize)
 allocate 3D array
 
int xsh_free3Darray (double ***ccdtemp, int asize, int bsize)
 free 3D array
 
void xsh_addvectors (vec a, vec b)
 add 2 vectors a+=b
 
void xsh_addvectors3D (vec a, vec b)
 add 2 vectors a+=b
 
void xsh_subtractvectors (vec a, vec b)
 subtract 2 vectors a-=b
 
DOUBLE xsh_scalarproduct (vec a, vec b)
 implements scalar product
 
void xsh_multiply (vec a, DOUBLE k)
 applies scalar product to vector
 
void xsh_showvector (vec a)
 show vector content
 
void xsh_normz (vec a)
 normalize vector
 
void xsh_normall (vec a)
 normalize vector
 
void xsh_multiplymatrix (mat A, mat B, mat C)
 multiply three matrixes A=B*C
 
void xsh_multiplythreematrix (mat A, mat B, mat C, mat D)
 multiply three matrixes A=B*C*D
 
void xsh_showmatrix (mat A)
 Show matrix.
 
void xsh_initializematrix (mat A)
 initialize matrix A
 
void xsh_matrixforvector (vec a, mat B, vec c)
 Realize a*B*c.
 
void xsh_transpose (mat A, mat B)
 matrix transposal
 
void xsh_rotationmatrix (mat A, const char axis, const DOUBLE angle)
 matrix rotation
 
void xsh_rotin (mat A, const DOUBLE x_angle, const DOUBLE y_angle, const DOUBLE z_angle)
 matrix rotation
 
double xsh_physmod_grating (vec in, int m, double sg, mat in_rot, mat exit_rot, vec out)
 Calculate the new vector after a given incident vector is reflected in a prism (i.e. exits from the same surface than it entered through)
 
void xsh_refract (vec b, DOUBLE rind, vec a)
 Calculate the new vector after a given incident vector passes a boundary between two materials.
 
static cpl_error_code xsh_model_compute_slitmap_kw (const double slit_min, const double slit_max, xsh_xs_3 *p_xs_3, xsh_instrument *instr, cpl_propertylist **plist)
 
cpl_error_code xsh_model_maps_create (xsh_xs_3 *p_xs_3, xsh_instrument *instr, const char *wtag, const char *stag, cpl_frame **wmap_frame, cpl_frame **smap_frame, const int save_tmp)
 Compute the wavelength and slit maps.
 
int xsh_model_map_ifu (double xifu, double yifu, xsh_xs_3 *p_xs_3)
 Map the IFU position to spectrograph slit position using transformation provided by Ana for IFU2.
 
cpl_vector ** xsh_model_locus (struct xs_3 *p_xs_3, xsh_instrument *instr, double ent_slit_pos)
 Compute the locus of the spectrum.
 
void xsh_model_get_xy (xsh_xs_3 *p_xs_3, xsh_instrument *instr, double lambda_nm, int morder, double ent_slit_pos, double *x, double *y)
 Compute the detector location (floating point pixels) of a given wavelength/entrance slit position.
 
void xsh_model_binxy (xsh_xs_3 *p_xs_3, int bin_X, int bin_Y)
 corrects model for detector's binning
 
cpl_frame * xsh_model_spectralformat_create (xsh_xs_3 *p_xs_3, const char *tab_filename)
 creates the model spectral format table
 
cpl_frame * xsh_model_THE_create (xsh_xs_3 *p_xs_3, xsh_instrument *instr, const char *line_list, int num_ph, double sep_ph, const char *THE_filename)
 Compute the THE table (centroid for each feature in lamp spectrum)
 
cpl_frame * xsh_model_pipe_anneal (cpl_frame *cfg_frame, cpl_frame *resid_frame, int maxit, double ann_fac, int scenario, int rec_id)
 Run the annealing (optimisation) algoritm to improve the fit of the model parameter set to a given wavecal exposure.
 
int xsh_model_open_param (char *listname, char *findname, int *ref, int setref, double *best, double setbest, double *min, double *max, double gfac, double fac, int counter)
 Open a parameter in the model config structure for annealing and set the limits.
 
double xsh_model_sellmeier_ext (int arm, double temper, double lam_sqr)
 Get the refractive index for a given temperature and wavelength from the (hard coded) extended Sellmeier co-efficients for infrasil (NIR) and Silica (UVB)
 
double xsh_model_ref_ind_air (double temper, double lam_sqr)
 Return the refractive index of air at a given wavelength and temperature.
 
cpl_vector * xsh_model_refining_detect (const cpl_vector *in, int fwhm, double sigma, int display)
 Detect the brightest features in a spectrum.
 
int xsh_model_first_anneal (cpl_parameterlist *parlist, cpl_frameset *frameset)
 Interpret the command line options and execute the data processing.
 
int xsh_model_first_anneal_save (const cpl_table *out_table, xsh_instrument *instr, cpl_parameterlist *parlist, cpl_frameset *set)
 Save the product of the recipe.
 
int xsh_model_offset (DOUBLE slit_pix_shift, DOUBLE disp_pix_shift, struct xs_3 *p_xs_3)
 convert a pixel shift measured on the detector to a shift in detector centroid
 
static int comp_center2 (const void *one, const void *two)
 
static void save_centers (CENTER_ORDER *pcent, int fpos, int npos, const char *arm)
 
void xsh_order_edge_list_fit (xsh_order_list *list, int size, double *order, double *posx, double *posy, int deg_poly, int edge)
 Fit edge of an order.
 
static void fit_order_edge_list (xsh_order_list *list, int npos, CENTER_ORDER *pcent, int degree, int edge)
 
cpl_frame * xsh_model_order_edges_tab_create (xsh_xs_3 *p_xs_3, const char *tab_filename)
 Create an order edges table using the phys mod.
 

Detailed Description

Macro Definition Documentation

◆ ERROR [1/2]

#define ERROR   1

Definition at line 2001 of file xsh_model_kernel.c.

◆ ERROR [2/2]

#define ERROR   1

Definition at line 2001 of file xsh_model_kernel.c.

◆ OK [1/2]

#define OK   0

Definition at line 2002 of file xsh_model_kernel.c.

◆ OK [2/2]

#define OK   0

Definition at line 2002 of file xsh_model_kernel.c.

Function Documentation

◆ comp_center2()

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

Definition at line 5915 of file xsh_model_kernel.c.

References first, and CENTER_ORDER::order.

Referenced by xsh_model_order_edges_tab_create().

◆ fit_order_edge_list()

static void fit_order_edge_list ( xsh_order_list list,
int  npos,
CENTER_ORDER pcent,
int  degree,
int  edge 
)
static

◆ save_centers()

static void save_centers ( CENTER_ORDER pcent,
int  fpos,
int  npos,
const char *  arm 
)
static

◆ xsh_3_detpix()

void xsh_3_detpix ( struct xs_3 p_xs_3)

◆ xsh_3_eval()

void xsh_3_eval ( DOUBLE  lambda,
int  morder,
DOUBLE **  ref_ind,
struct xs_3 p_xs_3 
)

◆ xsh_3_init()

void xsh_3_init ( struct xs_3 p_xs_3)

◆ xsh_addvectors()

void xsh_addvectors ( vec  a,
vec  b 
)

add 2 vectors a+=b

Parameters
avector1
bvector2
Returns
void

Definition at line 1592 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_addvectors3D()

void xsh_addvectors3D ( vec  a,
vec  b 
)

add 2 vectors a+=b

Parameters
avector1
bvector2
Returns
void

Definition at line 1604 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_alloc1Darray()

DOUBLE * xsh_alloc1Darray ( int  asize)

allocates memory for an array of doubles

Parameters
asizesize of array
Returns
allocated array (remember to de-allocate)

Definition at line 1256 of file xsh_model_kernel.c.

Referenced by xsh_model_anneal_reduce(), xsh_model_first_anneal(), xsh_model_locus(), xsh_model_pipe_anneal(), and xsh_model_reduce().

◆ xsh_alloc1Darray_INT()

int * xsh_alloc1Darray_INT ( int  asize)

allocates memory for an array of integers

Parameters
asizesize of array
Returns
allocated array (remember to de-allocate)

Definition at line 1240 of file xsh_model_kernel.c.

Referenced by xsh_model_locus(), and xsh_model_reduce().

◆ xsh_alloc2Darray()

double ** xsh_alloc2Darray ( int  asize,
int  bsize 
)

allocates memory for a 2D array of doubles

Parameters
asizesize1 of array
bsizesize2 of array
Returns
allocated array (remember to de-allocate)

Definition at line 1274 of file xsh_model_kernel.c.

Referenced by xsh_alloc3Darray2(), xsh_copy1D_to_2D(), xsh_model_anneal_reduce(), xsh_model_first_anneal(), xsh_model_get_xy(), xsh_model_locus(), xsh_model_maps_create(), xsh_model_order_edges_tab_create(), xsh_model_pipe_anneal(), xsh_model_reduce(), xsh_model_spectralformat_create(), and xsh_model_THE_create().

◆ xsh_alloc2Darray_f()

float ** xsh_alloc2Darray_f ( int  asize,
int  bsize 
)

allocates memory for a 2D array of floats

Parameters
asizesize1 of array
bsizesize2 of array
Returns
allocated array (remember to de-allocate)

Definition at line 1302 of file xsh_model_kernel.c.

◆ xsh_alloc2Darray_i()

int ** xsh_alloc2Darray_i ( int  asize,
int  bsize 
)

allocates memory for a 2D array of integers

Parameters
asizesize1 of array
bsizesize2 of array
Returns
allocated array (remember to de-allocate)

Definition at line 1331 of file xsh_model_kernel.c.

◆ xsh_alloc3Darray()

double *** xsh_alloc3Darray ( int  asize,
int  bsize,
int  csize 
)

allocate 3D array

Parameters
asizesize1
bsizesize2
csizesize3
Returns
3D array of doubles (remember to deallocate memory)

Definition at line 1523 of file xsh_model_kernel.c.

◆ xsh_alloc3Darray2()

double *** xsh_alloc3Darray2 ( int  asize,
int  bsize,
int  csize 
)

allocate 3D array

Parameters
asizesize1
bsizesize2
csizesize3
Returns
3D array of doubles (remember to deallocate memory)

Definition at line 1500 of file xsh_model_kernel.c.

References xsh_alloc2Darray().

◆ xsh_copy1D_to_2D()

double ** xsh_copy1D_to_2D ( double *  oneDccdtemp,
int  asize,
int  bsize 
)

copy 1D to 2D array

Parameters
oneDccdtemp1D array
asizesize1
bsizesize2
Returns
2D array of doubles (remember to deallocate memory)

Definition at line 1474 of file xsh_model_kernel.c.

References xsh_alloc2Darray().

◆ xsh_copy2D_to_1D()

double * xsh_copy2D_to_1D ( double **  ccdtemp,
int  asize,
int  bsize 
)

copy 2D to 1D array

Parameters
ccdtemp2D array
asizesize1
bsizesize2
Returns
1D array of doubles (remember to deallocate memory)

Definition at line 1444 of file xsh_model_kernel.c.

Referenced by xsh_model_reduce().

◆ xsh_copyvector()

static void xsh_copyvector ( vec  a,
vec  b 
)
static

Definition at line 131 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_eval(), and xsh_matrixforvector().

◆ xsh_free2Darray()

int xsh_free2Darray ( double **  ccdtemp,
int  asize 
)

free memory for a 2D array of doubles

Parameters
ccdtemparray
asizesize of array
Returns
0 if no error or 1 if error

Definition at line 1360 of file xsh_model_kernel.c.

Referenced by xsh_free3Darray(), xsh_model_anneal_reduce(), xsh_model_first_anneal(), xsh_model_get_xy(), xsh_model_locus(), xsh_model_maps_create(), xsh_model_order_edges_tab_create(), xsh_model_pipe_anneal(), xsh_model_reduce(), xsh_model_spectralformat_create(), and xsh_model_THE_create().

◆ xsh_free2Darray_f()

int xsh_free2Darray_f ( float **  ccdtemp,
int  asize 
)

free memory for a 2D array of floats

Parameters
ccdtemparray
asizesize of array
Returns
0 if no error or 1 if error

Definition at line 1417 of file xsh_model_kernel.c.

◆ xsh_free2Darray_i()

int xsh_free2Darray_i ( int **  ccdtemp,
int  asize 
)

free memory for a 2D array of integers

Parameters
ccdtemparray
asizesize of array
Returns
0 if no error or 1 if error

Definition at line 1389 of file xsh_model_kernel.c.

◆ xsh_free3Darray()

int xsh_free3Darray ( double ***  ccdtemp,
int  asize,
int  bsize 
)

free 3D array

Parameters
ccdtempfree 3D array
asizesize1
bsizesize2
Returns
0 if no error 1 if error

Definition at line 1565 of file xsh_model_kernel.c.

References ERROR, OK, and xsh_free2Darray().

◆ xsh_get_tag_opt_mod_cfg()

static const char * xsh_get_tag_opt_mod_cfg ( xsh_xs_3 p_xs_3,
int  rec_id 
)
static

◆ xsh_initializematrix()

void xsh_initializematrix ( mat  A)

initialize matrix A

Parameters
Amatrix to be initialized

Definition at line 1766 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_matrixforvector()

void xsh_matrixforvector ( vec  a,
mat  B,
vec  c 
)

Realize a*B*c.

Parameters
avector
Bmatrix
cvector
Returns
void

Definition at line 1798 of file xsh_model_kernel.c.

References vectordim, xsh_copyvector(), and xsh_nullvector().

Referenced by xsh_3_eval(), and xsh_physmod_grating().

◆ xsh_model_binxy()

void xsh_model_binxy ( xsh_xs_3 p_xs_3,
int  bin_X,
int  bin_Y 
)

◆ xsh_model_compute_residuals()

static cpl_error_code xsh_model_compute_residuals ( xsh_xs_3 p_xs_3,
coord msp_coord,
DOUBLE p_wlarray,
DOUBLE **  ref_ind,
const int  size,
const int  annealed,
cpl_propertylist *  resid_header,
cpl_frame *  resid_frame,
cpl_propertylist **  result 
)
static

◆ xsh_model_compute_slitmap_kw()

static cpl_error_code xsh_model_compute_slitmap_kw ( const double  slit_min,
const double  slit_max,
xsh_xs_3 p_xs_3,
xsh_instrument instr,
cpl_propertylist **  plist 
)
static

◆ xsh_model_first_anneal()

int xsh_model_first_anneal ( cpl_parameterlist *  parlist,
cpl_frameset *  frameset 
)

◆ xsh_model_first_anneal_save()

int xsh_model_first_anneal_save ( const cpl_table *  out_table,
xsh_instrument instr,
cpl_parameterlist *  parlist,
cpl_frameset *  set 
)

Save the product of the recipe.

Parameters
out_tablethe table
instrinstrument arm setting
parlistthe input list of parameters
setthe input frame set
Returns
0 if everything is ok, -1 otherwise

Definition at line 5822 of file xsh_model_kernel.c.

References check, xsh_add_product_table(), xsh_dfs_extract_raw_frames(), xsh_frame_product(), xsh_free_frame(), xsh_free_frameset(), xsh_free_propertylist(), xsh_get_tag_from_arm(), and XSH_MOD_CFG_FAN.

Referenced by xsh_model_first_anneal().

◆ xsh_model_get_xy()

void xsh_model_get_xy ( xsh_xs_3 p_xs_3,
xsh_instrument instr,
double  lambda_nm,
int  morder,
double  ent_slit_pos,
double *  x,
double *  y 
)

Compute the detector location (floating point pixels) of a given wavelength/entrance slit position.

Parameters
p_xs_3Model configuration structure
instrThe identifier of the XSH arm
lambda_nmThe wavelength in nm (double)
morderThe spectral order (int)
ent_slit_posPosition on the slit in arcsec (double)
xTakes the calculated x value (double)
yTakes the calculated y value (double)
Returns
void Result is returned with the x and y params above

cpl_vector_delete(returned_ptr) ;

Definition at line 2849 of file xsh_model_kernel.c.

References xs_3::arm, check, xs_3::es_y, xs_3::es_y_tot, mm2nm, xs_3::slit_scale, xs_3::t_ir_p2, xs_3::temper, x, xs_3::xpospix, xsh_3_detpix(), xsh_3_eval(), xsh_3_init(), xsh_alloc2Darray(), XSH_ARM_UNDEFINED, XSH_ARM_UVB, XSH_ARM_VIS, XSH_ASSURE_NOT_NULL, xsh_free2Darray(), xsh_instrument_get_arm(), xsh_ref_ind_read(), y, and xs_3::ypospix.

Referenced by clean_arclist_data(), fill_rectified(), main(), theo_tab_model(), xsh_afcthetab_create(), xsh_build_ifu_cube(), xsh_cfg_recover_gen_xyg(), xsh_cfg_recover_measure_line_xy(), xsh_create_dispersol_physmod(), xsh_flexcor(), xsh_model_reduce(), xsh_opt_extract_orders(), xsh_spectralformat_check_wlimit(), xsh_util_guess_xy(), and xsh_util_ifu_build_cube().

◆ xsh_model_locus()

cpl_vector ** xsh_model_locus ( struct xs_3 p_xs_3,
xsh_instrument instr,
double  ent_slit_pos 
)

Compute the locus of the spectrum.

Parameters
p_xs_3Model configuration data structure
instrThe XSH arm
ent_slit_posPosition on the slit (double)
Returns
loci cpl_vectors for the x-dispersion positions

The returned pointer must be deallocated with for (i=0 ; i<n_orders ; i++) cpl_vector_delete(returned_ptr[i]) ; cpl_free(returned_ptr) ; here n_orders=16 for all 3 arms

Definition at line 2674 of file xsh_model_kernel.c.

References xs_3::arm, xs_3::ASIZE, xs_3::blaze_pad, xs_3::BSIZE, check, xs_3::chippix, xs_3::es_y, xs_3::es_y_tot, mm2nm, xs_3::morder_min, xs_3::nug, xs_3::sg, xs_3::SIZE, xs_3::slit_scale, xs_3::t_ir_p2, xs_3::temper, xs_3::xpospix, xsh_3_detpix(), xsh_3_eval(), xsh_3_init(), xsh_alloc1Darray(), xsh_alloc1Darray_INT(), xsh_alloc2Darray(), XSH_ARM_NIR, XSH_ARM_UNDEFINED, XSH_ARM_UVB, XSH_ARM_VIS, XSH_ASSURE_NOT_NULL, xsh_free2Darray(), xsh_instrument_get_arm(), xsh_ref_ind_read(), and xs_3::ypospix.

Referenced by xsh_cfg_recover_measure_line_xy(), and xsh_model_reduce().

◆ xsh_model_map_ifu()

int xsh_model_map_ifu ( double  xifu,
double  yifu,
xsh_xs_3 p_xs_3 
)

Map the IFU position to spectrograph slit position using transformation provided by Ana for IFU2.

Parameters
xifudispersion axis co-ordinate in arcsec on IFU slitlet
yifuX-dispersion axis co-ordinate in arcsec on IFU slitlet
p_xs_3Model configuration data structure
Returns
0 for success, -1 for error, 1 in the case that the incident ray does not pass through the IFU

(The es_x and es_y_tot parameters are updated inside p_xs_3)

Definition at line 2615 of file xsh_model_kernel.c.

References xs_3::es_x, xs_3::es_y, xs_3::es_y_tot, IFU_CEN_MIN, IFU_HI, IFU_LEFT_MIN, IFU_LOW, IFU_MAP_CEN_C0X, IFU_MAP_CEN_C0Y, IFU_MAP_CEN_C1X, IFU_MAP_CEN_C1Y, IFU_MAP_CEN_C2X, IFU_MAP_CEN_C2Y, IFU_MAP_LEFT_C0X, IFU_MAP_LEFT_C0Y, IFU_MAP_LEFT_C1X, IFU_MAP_LEFT_C1Y, IFU_MAP_LEFT_C2X, IFU_MAP_LEFT_C2Y, IFU_MAP_RIGHT_C0X, IFU_MAP_RIGHT_C0Y, IFU_MAP_RIGHT_C1X, IFU_MAP_RIGHT_C1Y, IFU_MAP_RIGHT_C2X, IFU_MAP_RIGHT_C2Y, IFU_RIGHT_MIN, IFU_SCALE, and xs_3::slit_scale.

Referenced by xsh_model_maps_create().

◆ xsh_model_maps_create()

cpl_error_code xsh_model_maps_create ( xsh_xs_3 p_xs_3,
xsh_instrument instr,
const char *  wtag,
const char *  stag,
cpl_frame **  wmap_frame,
cpl_frame **  smap_frame,
const int  save_tmp 
)

◆ xsh_model_offset()

int xsh_model_offset ( DOUBLE  slit_pix_shift,
DOUBLE  disp_pix_shift,
struct xs_3 p_xs_3 
)

convert a pixel shift measured on the detector to a shift in detector centroid

Parameters
disp_pix_shiftThe shift of the slit centre in dispersion pixels (new position - old position)
slit_pix_shiftThe shift of the slit centre in slit pixels (new position - old position)
p_xs_3The phys mod parameter structure
Returns
0 if everything is ok, -1 otherwise (result is in the updated p_xs_3->chipx value). Strictly this should use the location in the detector plane and the corresponding distortion, but this is an nth order effect...

Otherwise this reduces to simple independent chipx and chipy shifts since for XSH (but not for eg. CRIRES) there is no rotation of the detector chip within the detector plane.

Definition at line 5898 of file xsh_model_kernel.c.

References xs_3::arm, xs_3::chipx, xs_3::chipy, xs_3::pix_X, and xs_3::pix_Y.

Referenced by xsh_flexcor().

◆ xsh_model_open_param()

int xsh_model_open_param ( char *  listname,
char *  findname,
int *  ref,
int  setref,
double *  best,
double  setbest,
double *  min,
double *  max,
double  gfac,
double  fac,
int  counter 
)

Open a parameter in the model config structure for annealing and set the limits.

Parameters
listname(char)
findname(char)
ref(int*)
setref(int)
best(double*)
setbest(doublle
min(double*)
max(double*)
gfac(double)
fac(double)
counter(int)
Returns
counter (int)

Definition at line 5110 of file xsh_model_kernel.c.

References max, and ref.

◆ xsh_model_order_edges_tab_create()

cpl_frame * xsh_model_order_edges_tab_create ( xsh_xs_3 p_xs_3,
const char *  tab_filename 
)

Create an order edges table using the phys mod.

I have copied the method for fitting and creating the table from xsh_order_table_from_fmtchk.c, including variable names like res_list and centers that may have lost their context here.

Parameters
p_xs_3Model configuration data structure
tab_filenameName of the cpl_table to be created
Returns
the order edge table frame The returned pointer must be deallocated with xsh_free_frame()

Definition at line 6110 of file xsh_model_kernel.c.

References xsh_order::absorder, xs_3::arm, xs_3::ASIZE, xs_3::BSIZE, check, xs_3::chippix, comp_center2(), xsh_order::endy, xs_3::es_s, xs_3::es_x, xs_3::es_y, xs_3::es_y_tot, fit_order_edge_list(), CENTER_ORDER::flux, xsh_order_list::list, mm2nm, xs_3::morder_max, xs_3::morder_min, xs_3::nug, CENTER_ORDER::order, CENTER_ORDER::pos_x, CENTER_ORDER::pos_y, save_centers(), xs_3::sg, xsh_order::starty, xs_3::t_ir_p2, xs_3::temper, xs_3::xpospix, xsh_3_detpix(), xsh_3_eval(), xsh_3_init(), xsh_alloc2Darray(), XSH_ARM_NIR, XSH_ARM_UVB, XSH_ARM_VIS, XSH_ASSURE_NOT_NULL, XSH_CALLOC, XSH_FREE, xsh_free2Darray(), xsh_free_propertylist(), xsh_instrument_arm_tostring(), xsh_instrument_new(), xsh_instrument_set_arm(), xsh_order_list_create(), xsh_order_list_save(), xsh_pfits_set_pcatg(), xsh_ref_ind_read(), and xs_3::ypospix.

Referenced by xsh_model_reduce().

◆ xsh_model_pipe_anneal()

cpl_frame * xsh_model_pipe_anneal ( cpl_frame *  cfg_frame,
cpl_frame *  resid_frame,
int  maxit,
double  ann_fac,
int  scenario,
int  rec_id 
)

Run the annealing (optimisation) algoritm to improve the fit of the model parameter set to a given wavecal exposure.

Parameters
cfg_frameModel configuration frame (contains config file name)
resid_frameFrame containing resid table - absolute x,y positions can be calculated from thpre_x,y and diff_x,y
maxitThe numer of iterations of the annealing algorithm to be performed (int)
ann_facMultiplier applied to the automatic parameter ranges (i.e. when scenario!=0). For routine operations should be 1.0
scenarioselects preset flag and range combinations appropriate to common scenarios: -1- Only the position across the slit and camera focal length are open 0 - No scenario, input cfg flags and limits used. 1 - scenario appropriate for the startup recipe (large ranges for parameters affecting single ph exposures, dist coeff fixed) 2 - Like 1, but includes parameters affecting all ph positions 3 - Scenario for use in fine tuning cfg to match routine wavecal exposures. All parameters affecting 1ph exposures except dist coeffs are included and parameter ranges are small. (For use by predict in 1ph case). 4 - Like 3 but includes parameters affecting all ph positions (Standard for use by predict in 9ph case and 2dmap). 5 - Like 4 but includes also dist coeffs 6 - Just dist coeffs (and chipx, chipy) 7 - Just anneal the cross-slit position focal length of the camera for wavecal 8 - Optimised parameter set for QC
rec_idrecipe identifier
Returns
MODEL_CONF_OPT_frame The model configuration structure with modified parameters

The returned pointer must be deallocated with cpl_frame_delete(MODEL_CONF_OPT_frame);

Definition at line 3678 of file xsh_model_kernel.c.

References coord::arm, xs_3::arm, xs_3::ca_x0, xs_3::ca_x1, xs_3::ca_y0, xs_3::ca_y1, check, xs_3::chippix, xs_3::chipx, xs_3::chipy, coord::counter, xs_3::d2_x1, xs_3::d2_x2, xs_3::d2_x3, DEG2RAD, xs_3::es_x, xs_3::es_y, xs_3::es_y_tot, xs_3::fcol, xs_3::fdet, coord::flux, xsh_resid_tab::header, xs_3::mud, xs_3::mug, xs_3::mup1, xs_3::mup2, xs_3::mup3, xs_3::mup4, xs_3::mup5, xs_3::mup6, xs_3::nud, xs_3::nug, xs_3::nup1, xs_3::nup2, xs_3::nup3, xs_3::nup4, xs_3::nup5, xs_3::nup6, coord::order, xs_3::pc4_x_x2y2, xs_3::pc4_x_x3y, xs_3::pc4_x_x4, xs_3::pc4_x_xy3, xs_3::pc4_x_y4, xs_3::pc4_y_x2y2, xs_3::pc4_y_x4, xs_3::pc4_y_xy3, xs_3::pc4_y_y4, xs_3::pc_x_x1, xs_3::pc_x_x2y, xs_3::pc_x_x3, xs_3::pc_x_xx, xs_3::pc_x_xy, xs_3::pc_x_y1, xs_3::pc_x_y2x, xs_3::pc_x_y3, xs_3::pc_x_yy, xs_3::pc_y_x1, xs_3::pc_y_x2y, xs_3::pc_y_x3, xs_3::pc_y_xx, xs_3::pc_y_xy, xs_3::pc_y_y1, xs_3::pc_y_y2x, xs_3::pc_y_y3, xs_3::pc_y_yy, xs_3::sg, size, xs_3::slit, coord::slit_pos, xs_3::slit_scale, xs_3::t_ir_p2, xs_3::taud, xs_3::taues, xs_3::taug, xs_3::temper, coord::wave, coord::x, xs_3::xdet, xs_3::xpospix, xsh_3_detpix(), xsh_3_eval(), xsh_3_init(), xsh_alloc1Darray(), xsh_alloc2Darray(), XSH_ASSURE_NOT_NULL, XSH_CALLOC, xsh_frame_product(), XSH_FREE, xsh_free2Darray(), xsh_free_frame(), xsh_free_propertylist(), xsh_free_table(), xsh_get_tag_opt_mod_cfg(), xsh_model_anneal_comp(), xsh_model_compute_residuals(), xsh_model_readfits(), xsh_msg, xsh_msg_dbg_medium, xsh_pfits_set_pcatg(), xsh_ref_ind_read(), xsh_resid_tab_free(), xsh_resid_tab_get_lambda_data(), xsh_resid_tab_get_order_data(), xsh_resid_tab_get_size(), xsh_resid_tab_get_slit_index(), xsh_resid_tab_get_thpre_x_data(), xsh_resid_tab_get_thpre_y_data(), xsh_resid_tab_get_xgauss_data(), xsh_resid_tab_get_ygauss_data(), xsh_resid_tab_load(), coord::y, xs_3::ydet, and xs_3::ypospix.

Referenced by xsh_2dmap(), xsh_cfg_recover_last_step(), xsh_flexcor(), and xsh_predict().

◆ xsh_model_ref_ind_air()

double xsh_model_ref_ind_air ( double  temper,
double  lam_sqr 
)

Return the refractive index of air at a given wavelength and temperature.

Parameters
temperthe temperature (deg K)
lam_sqrwavelength in micron, squared
Returns
refractive index of air All constants from Schott document TIE-19, Jul 2008 pp3

Definition at line 5202 of file xsh_model_kernel.c.

◆ xsh_model_refining_detect()

cpl_vector * xsh_model_refining_detect ( const cpl_vector *  in,
int  fwhm,
double  sigma,
int  display 
)

Detect the brightest features in a spectrum.

Parameters
inthe spectrum (cpl_vector)
fwhmthe FWHM used for the lines convolution in pixels (int)
sigmaNo. of standard deviation for detection (double)
displaythe flag to display (int)
Returns
The bright lines positions or NULL in error case

Definition at line 5221 of file xsh_model_kernel.c.

References check, max, sigma, and xsh_print_rec_status().

Referenced by xsh_cfg_recover_measure_line_xy(), and xsh_model_reduce().

◆ xsh_model_sellmeier_ext()

double xsh_model_sellmeier_ext ( int  arm,
double  temper,
double  lam_sqr 
)

Get the refractive index for a given temperature and wavelength from the (hard coded) extended Sellmeier co-efficients for infrasil (NIR) and Silica (UVB)

Parameters
armram selector
temperTemperature of Infrasil prism in K (double)
lam_sqrSquare of wavelength in um (double)
Returns
sqrt(ref_ind) Refractive index (double)

Definition at line 5143 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

◆ xsh_model_spectralformat_create()

cpl_frame * xsh_model_spectralformat_create ( xsh_xs_3 p_xs_3,
const char *  tab_filename 
)

◆ xsh_model_THE_create()

cpl_frame * xsh_model_THE_create ( xsh_xs_3 p_xs_3,
xsh_instrument instr,
const char *  line_list,
int  num_ph,
double  sep_ph,
const char *  THE_filename 
)

Compute the THE table (centroid for each feature in lamp spectrum)

Parameters
p_xs_3Model configuration data structure
instrThe XSH arm
line_listCalibration source line list file name
num_phNumber of pinholes in mask (int)
sep_phSeparation of pinholes (arcsec) or <0 to use values from the config file (double)
THE_filenameTHE table filename
Returns
THE table frame If sep_ph>0.0 then pinholes are regularly spaced with central pinhole at es_y, If sep_ph<=0.0 then config slit[n] positions are used with es_y offset and scaling by slit_scale param from config If num_ph==1 then pinhole is always at es_y (either, for sep_ph<=0.0, spos=slit[4]=0.0 is used or, for sep_ph>0.0, spos=0.0)

The returned pointer must be deallocated with cpl_table_delete(returned_ptr);

Definition at line 3439 of file xsh_model_kernel.c.

References xs_3::arm, xs_3::blaze_pad, check, xs_3::chippix, xs_3::es_y, xs_3::es_y_tot, xs_3::morder_min, xs_3::nug, xs_3::sg, xs_3::slit, xs_3::slit_scale, xs_3::t_ir_p2, xs_3::temper, xs_3::xpospix, xsh_3_detpix(), xsh_3_eval(), xsh_3_init(), xsh_alloc2Darray(), XSH_ARCLIST_TABLE_COLNAME_FLUX, XSH_ARCLIST_TABLE_COLNAME_WAVELENGTH, XSH_ARM_NIR, XSH_ARM_UNDEFINED, XSH_ARM_UVB, XSH_ARM_VIS, XSH_ASSURE_NOT_NULL, xsh_frame_product(), xsh_free2Darray(), xsh_free_frame(), xsh_free_propertylist(), xsh_free_table(), xsh_instrument_get_arm(), xsh_msg, xsh_ref_ind_read(), XSH_THE_MAP_TABLE_COLNAME_DETECTORX, XSH_THE_MAP_TABLE_COLNAME_DETECTORY, XSH_THE_MAP_TABLE_COLNAME_ORDER, XSH_THE_MAP_TABLE_COLNAME_SLITINDEX, XSH_THE_MAP_TABLE_COLNAME_SLITPOSITION, XSH_THE_MAP_TABLE_COLNAME_WAVELENGTH, and xs_3::ypospix.

Referenced by main(), xsh_cfg_recover_model_THE_create(), xsh_model_reduce(), and xsh_util_physmod_model_THE_create().

◆ xsh_multiply()

void xsh_multiply ( vec  a,
DOUBLE  k 
)

applies scalar product to vector

Parameters
avector
kscalar

Definition at line 1642 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_multiplymatrix()

void xsh_multiplymatrix ( mat  A,
mat  B,
mat  C 
)

multiply three matrixes A=B*C

Parameters
Amatrix result
Bmatrix factor
Cmatrix factor

Definition at line 1722 of file xsh_model_kernel.c.

References C, vectordim, and xsh_nullmatrix().

Referenced by xsh_3_init(), xsh_multiplythreematrix(), and xsh_rotin().

◆ xsh_multiplythreematrix()

void xsh_multiplythreematrix ( mat  A,
mat  B,
mat  C,
mat  D 
)

multiply three matrixes A=B*C*D

Parameters
Amatrix result
Bmatrix factor
Cmatrix factor
Dmatrix factor

Definition at line 1741 of file xsh_model_kernel.c.

References C, xsh_multiplymatrix(), and xsh_nullmatrix().

◆ xsh_normall()

void xsh_normall ( vec  a)

normalize vector

Parameters
avector
Note
normalize by 1/sqrt(x^2 + y^2 + z^2)

Definition at line 1707 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

◆ xsh_normz()

void xsh_normz ( vec  a)

normalize vector

Parameters
avector
Note
normalize by z^2 = 1- (x^2 + y^2)

Definition at line 1667 of file xsh_model_kernel.c.

Referenced by xsh_3_eval(), and xsh_physmod_grating().

◆ xsh_nullmatrix()

static void xsh_nullmatrix ( mat  A)
static

Definition at line 95 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_multiplymatrix(), xsh_multiplythreematrix(), and xsh_rotationmatrix().

◆ xsh_nullvector()

static void xsh_nullvector ( vec  a)
static

Definition at line 122 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_matrixforvector().

◆ xsh_order_edge_list_fit()

void xsh_order_edge_list_fit ( xsh_order_list list,
int  size,
double *  order,
double *  posx,
double *  posy,
int  deg_poly,
int  edge 
)

Fit edge of an order.

Parameters
[in]liststructure containing order trace locations
[in]sizesize of list
[out]orderorder values
[out]posxx edge position values
[out]posyy edge position values
deg_polydegree of polynomial to be fit to edges
edgeparameter indicating edge to fit (up: -1, cen: 0, low=1)

Definition at line 5987 of file xsh_model_kernel.c.

References xsh_order::absorder, xsh_order_list::absorder_max, xsh_order_list::absorder_min, xsh_order::cenpoly, check, xsh_order::edglopoly, xsh_order::edguppoly, xsh_order_list::list, xsh_order::order, order, xsh_order_list::size, size, XSH_ASSURE_NOT_ILLEGAL, XSH_ASSURE_NOT_ILLEGAL_MSG, XSH_ASSURE_NOT_NULL, xsh_msg, xsh_msg_dbg_low, xsh_polynomial_fit_1d_create(), and xsh_unwrap_vector().

Referenced by fit_order_edge_list().

◆ xsh_physmod_grating()

double xsh_physmod_grating ( vec  in,
int  m,
double  sg,
mat  in_rot,
mat  exit_rot,
vec  out 
)

Calculate the new vector after a given incident vector is reflected in a prism (i.e. exits from the same surface than it entered through)

Parameters
inincident vector
mspectral order
sggrating constant
in_rotmatrix describing the rotation in to the entrance surface
exit_rotmatrix describing the rotation out of the exit surface
outoutput vector return alpha useful parameter for calculating blaze later...

Definition at line 1908 of file xsh_model_kernel.c.

References m, xsh_matrixforvector(), and xsh_normz().

◆ xsh_ref_ind_read()

void xsh_ref_ind_read ( int  arm,
DOUBLE **  ref_ind_T,
DOUBLE  temper 
)

Load the refractive index coeffs for a given arm and temperature.

Parameters
armInstrument arm
ref_ind_TRefractive index coefficients
temperTemperature in K

Definition at line 1184 of file xsh_model_kernel.c.

References schott_sf6_manu, silica_zemax, and znse.

Referenced by xsh_model_anneal_reduce(), xsh_model_first_anneal(), xsh_model_get_xy(), xsh_model_locus(), xsh_model_maps_create(), xsh_model_order_edges_tab_create(), xsh_model_pipe_anneal(), xsh_model_reduce(), xsh_model_spectralformat_create(), and xsh_model_THE_create().

◆ xsh_ref_ind_read_old()

void xsh_ref_ind_read_old ( const char *  ref_ind_file,
DOUBLE **  ref_ind,
DOUBLE  temper 
)

Load the refractive index array for a given arm and temperature. This old routine is only retained to allow easy testing of new refractive index data.

Parameters
ref_ind_fileFilename for file conatining refractive index data
ref_indRefractive index coefficients
temperTemperature in K

Definition at line 1127 of file xsh_model_kernel.c.

◆ xsh_refract()

void xsh_refract ( vec  b,
DOUBLE  rind,
vec  a 
)

Calculate the new vector after a given incident vector passes a boundary between two materials.

Parameters
bexit vector
rindrefractive index
aincident vector
Returns
void

Definition at line 1945 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

◆ xsh_rotationmatrix()

void xsh_rotationmatrix ( mat  A,
const char  axis,
const DOUBLE  angle 
)

matrix rotation

Parameters
Amatrix to be rotated
axisaxis around which rotation occurs
anglerotation angle

Definition at line 1834 of file xsh_model_kernel.c.

References xsh_nullmatrix().

Referenced by xsh_rotin().

◆ xsh_rotin()

void xsh_rotin ( mat  A,
const DOUBLE  x_angle,
const DOUBLE  y_angle,
const DOUBLE  z_angle 
)

matrix rotation

Parameters
Amatrix to be rotated
x_anglerotation angle around X axis
y_anglerotation angle around Y axis
z_anglerotation angle around Z axis

Definition at line 1883 of file xsh_model_kernel.c.

References xsh_multiplymatrix(), and xsh_rotationmatrix().

Referenced by xsh_3_eval(), and xsh_3_init().

◆ xsh_scalarproduct()

DOUBLE xsh_scalarproduct ( vec  a,
vec  b 
)

implements scalar product

Parameters
avector1
bvector2
Returns
a*b

Definition at line 1629 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_showmatrix()

void xsh_showmatrix ( mat  A)

Show matrix.

Parameters
Amatrix to be shown

Definition at line 1753 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_model_anneal_reduce(), and xsh_model_first_anneal().

◆ xsh_showvector()

void xsh_showvector ( vec  a)

show vector content

Parameters
avector

Definition at line 1652 of file xsh_model_kernel.c.

References vectordim.

◆ xsh_subtractvectors()

void xsh_subtractvectors ( vec  a,
vec  b 
)

subtract 2 vectors a-=b

Parameters
avector1
bvector2
Returns
void

Definition at line 1617 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_eval().

◆ xsh_transpose()

void xsh_transpose ( mat  A,
mat  B 
)

matrix transposal

Parameters
Atransposed matrix
Bmatrix to be transposed

Definition at line 1817 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_init().