Functions for the wl model computation

Defines

#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)
 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.

Define Documentation

#define ERROR   1

Definition at line 1932 of file xsh_model_kernel.c.

#define ERROR   1

Definition at line 1932 of file xsh_model_kernel.c.

Referenced by xsh_free3Darray().

#define OK   0

Definition at line 1933 of file xsh_model_kernel.c.

#define OK   0

Definition at line 1933 of file xsh_model_kernel.c.

Referenced by xsh_free3Darray().


Function Documentation

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

Definition at line 5755 of file xsh_model_kernel.c.

References first, and CENTER_ORDER::order.

Referenced by xsh_model_order_edges_tab_create().

static void fit_order_edge_list ( xsh_order_list list,
int  npos,
CENTER_ORDER pcent,
int  degree,
int  edge 
) [static]
static void save_centers ( CENTER_ORDER pcent,
int  fpos,
int  npos,
const char *  arm 
) [static]
void xsh_3_detpix ( struct xs_3 p_xs_3  ) 
void xsh_3_eval ( DOUBLE  lambda,
int  morder,
DOUBLE **  ref_ind,
struct xs_3 p_xs_3 
)
void xsh_3_init ( struct xs_3 p_xs_3  ) 
void xsh_addvectors ( vec  a,
vec  b 
)

add 2 vectors a+=b

Parameters:
a vector1
b vector2
Returns:
void

Definition at line 1583 of file xsh_model_kernel.c.

References vectordim.

void xsh_addvectors3D ( vec  a,
vec  b 
)

add 2 vectors a+=b

Parameters:
a vector1
b vector2
Returns:
void

Definition at line 1595 of file xsh_model_kernel.c.

References vectordim.

DOUBLE* xsh_alloc1Darray ( int  asize  ) 

allocates memory for an array of doubles

Parameters:
asize size of array
Returns:
allocated array (remember to de-allocate)

Definition at line 1247 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().

int* xsh_alloc1Darray_INT ( int  asize  ) 

allocates memory for an array of integers

Parameters:
asize size of array
Returns:
allocated array (remember to de-allocate)

Definition at line 1231 of file xsh_model_kernel.c.

Referenced by xsh_model_locus(), and xsh_model_reduce().

double** xsh_alloc2Darray ( int  asize,
int  bsize 
)

allocates memory for a 2D array of doubles

Parameters:
asize size1 of array
bsize size2 of array
Returns:
allocated array (remember to de-allocate)

Definition at line 1265 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().

float** xsh_alloc2Darray_f ( int  asize,
int  bsize 
)

allocates memory for a 2D array of floats

Parameters:
asize size1 of array
bsize size2 of array
Returns:
allocated array (remember to de-allocate)

Definition at line 1293 of file xsh_model_kernel.c.

int** xsh_alloc2Darray_i ( int  asize,
int  bsize 
)

allocates memory for a 2D array of integers

Parameters:
asize size1 of array
bsize size2 of array
Returns:
allocated array (remember to de-allocate)

Definition at line 1322 of file xsh_model_kernel.c.

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

allocate 3D array

Parameters:
asize size1
bsize size2
csize size3
Returns:
3D array of doubles (remember to deallocate memory)

Definition at line 1514 of file xsh_model_kernel.c.

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

allocate 3D array

Parameters:
asize size1
bsize size2
csize size3
Returns:
3D array of doubles (remember to deallocate memory)

Definition at line 1491 of file xsh_model_kernel.c.

References xsh_alloc2Darray().

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

copy 1D to 2D array

Parameters:
oneDccdtemp 1D array
asize size1
bsize size2
Returns:
2D array of doubles (remember to deallocate memory)

Definition at line 1465 of file xsh_model_kernel.c.

References xsh_alloc2Darray().

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

copy 2D to 1D array

Parameters:
ccdtemp 2D array
asize size1
bsize size2
Returns:
1D array of doubles (remember to deallocate memory)

Definition at line 1435 of file xsh_model_kernel.c.

Referenced by xsh_model_maps_create(), and xsh_model_reduce().

static void xsh_copyvector ( vec  a,
vec  b 
) [static]

Definition at line 130 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_eval(), and xsh_matrixforvector().

int xsh_free2Darray ( double **  ccdtemp,
int  asize 
)

free memory for a 2D array of doubles

Parameters:
ccdtemp array
asize size of array
Returns:
0 if no error or 1 if error

Definition at line 1351 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().

int xsh_free2Darray_f ( float **  ccdtemp,
int  asize 
)

free memory for a 2D array of floats

Parameters:
ccdtemp array
asize size of array
Returns:
0 if no error or 1 if error

Definition at line 1408 of file xsh_model_kernel.c.

int xsh_free2Darray_i ( int **  ccdtemp,
int  asize 
)

free memory for a 2D array of integers

Parameters:
ccdtemp array
asize size of array
Returns:
0 if no error or 1 if error

Definition at line 1380 of file xsh_model_kernel.c.

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

free 3D array

Parameters:
ccdtemp free 3D array
asize size1
bsize size2
Returns:
0 if no error 1 if error

Definition at line 1556 of file xsh_model_kernel.c.

References ERROR, OK, and xsh_free2Darray().

static const char* xsh_get_tag_opt_mod_cfg ( xsh_xs_3 p_xs_3,
int  rec_id 
) [static]
void xsh_initializematrix ( mat  A  ) 

initialize matrix A

Parameters:
A matrix to be initialized

Definition at line 1754 of file xsh_model_kernel.c.

References vectordim.

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

Realize a*B*c.

Parameters:
a vector
B matrix
c vector
Returns:
void

Definition at line 1772 of file xsh_model_kernel.c.

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

Referenced by xsh_3_eval(), and xsh_physmod_grating().

void xsh_model_binxy ( xsh_xs_3 p_xs_3,
int  bin_X,
int  bin_Y 
)
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]
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]
int xsh_model_first_anneal ( cpl_parameterlist *  parlist,
cpl_frameset *  frameset 
)
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_table the table
instr instrument arm setting
parlist the input list of parameters
set the input frame set
Returns:
0 if everything is ok, -1 otherwise

Definition at line 5662 of file xsh_model_kernel.c.

References check, xsh_add_product_table_multi(), 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().

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_3 Model configuration structure
instr The identifier of the XSH arm
lambda_nm The wavelength in nm (double)
morder The spectral order (int)
ent_slit_pos Position on the slit in arcsec (double)
x Takes the calculated x value (double)
y Takes 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 2736 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, 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(), 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().

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_3 Model configuration data structure
instr The XSH arm
ent_slit_pos Position 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 2565 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().

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:
xifu dispersion axis co-ordinate in arcsec on IFU slitlet
yifu X-dispersion axis co-ordinate in arcsec on IFU slitlet
p_xs_3 Model 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 2506 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().

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 
)
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_shift The shift of the slit centre in dispersion pixels (new position - old position)
slit_pix_shift The shift of the slit centre in slit pixels (new position - old position)
p_xs_3 The 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 5738 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().

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 4949 of file xsh_model_kernel.c.

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_3 Model configuration data structure
tab_filename Name 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 5950 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().

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_frame Model configuration frame (contains config file name)
resid_frame Frame containing resid table - absolute x,y positions can be calculated from thpre_x,y and diff_x,y
maxit The numer of iterations of the annealing algorithm to be performed (int)
ann_fac Multiplier applied to the automatic parameter ranges (i.e. when scenario!=0). For routine operations should be 1.0
scenario selects 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_id recipe 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 3547 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_basename(), 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().

double xsh_model_ref_ind_air ( double  temper,
double  lam_sqr 
)

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

Parameters:
temper the temperature (deg K)
lam_sqr wavelength in micron, squared
Returns:
refractive index of air All constants from Schott document TIE-19, Jul 2008 pp3

Definition at line 5041 of file xsh_model_kernel.c.

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

Detect the brightest features in a spectrum.

Parameters:
in the spectrum (cpl_vector)
fwhm the FWHM used for the lines convolution in pixels (int)
sigma No. of standard deviation for detection (double)
display the flag to display (int)
Returns:
The bright lines positions or NULL in error case

Definition at line 5060 of file xsh_model_kernel.c.

References check, and xsh_print_rec_status().

Referenced by xsh_cfg_recover_measure_line_xy(), and xsh_model_reduce().

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:
arm ram selector
temper Temperature of Infrasil prism in K (double)
lam_sqr Square of wavelength in um (double)
Returns:
sqrt(ref_ind) Refractive index (double)

Definition at line 4982 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

cpl_frame* xsh_model_spectralformat_create ( xsh_xs_3 p_xs_3,
const char *  tab_filename 
)
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_3 Model configuration data structure
instr The XSH arm
line_list Calibration source line list file name
num_ph Number of pinholes in mask (int)
sep_ph Separation of pinholes (arcsec) or <0 to use values from the config file (double)
THE_filename THE 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 3326 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 xsh_cfg_recover_model_THE_create(), xsh_model_reduce(), and xsh_util_physmod_model_THE_create().

void xsh_multiply ( vec  a,
DOUBLE  k 
)

applies scalar product to vector

Parameters:
a vector
k scalar

Definition at line 1633 of file xsh_model_kernel.c.

References vectordim.

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

multiply three matrixes A=B*C

Parameters:
A matrix result
B matrix factor
C matrix factor

Definition at line 1710 of file xsh_model_kernel.c.

References vectordim, and xsh_nullmatrix().

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

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

multiply three matrixes A=B*C*D

Parameters:
A matrix result
B matrix factor
C matrix factor
D matrix factor

Definition at line 1729 of file xsh_model_kernel.c.

References xsh_multiplymatrix(), and xsh_nullmatrix().

void xsh_normall ( vec  a  ) 

normalize vector

Parameters:
a vector
Note:
normalize by 1/sqrt(x^2 + y^2 + z^2)

Definition at line 1695 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

void xsh_normz ( vec  a  ) 

normalize vector

Parameters:
a vector
Note:
normalize by z^2 = 1- (x^2 + y^2)

Definition at line 1656 of file xsh_model_kernel.c.

Referenced by xsh_3_eval(), and xsh_physmod_grating().

static void xsh_nullmatrix ( mat  A  )  [static]

Definition at line 94 of file xsh_model_kernel.c.

References vectordim.

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

static void xsh_nullvector ( vec  a  )  [static]

Definition at line 121 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_matrixforvector().

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] list structure containing order trace locations
[in] size size of list
[out] order order values
[out] posx x edge position values
[out] posy y edge position values
deg_poly degree of polynomial to be fit to edges
edge parameter indicating edge to fit (up: -1, cen: 0, low=1)

Definition at line 5827 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, xsh_order_list::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().

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:
in incident vector
m spectral order
sg grating constant
in_rot matrix describing the rotation in to the entrance surface
exit_rot matrix describing the rotation out of the exit surface
out output vector return alpha useful parameter for calculating blaze later...

Definition at line 1881 of file xsh_model_kernel.c.

References xsh_matrixforvector(), and xsh_normz().

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:
arm Instrument arm
ref_ind_T Refractive index coefficients
temper Temperature in K

Definition at line 1175 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().

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_file Filename for file conatining refractive index data
ref_ind Refractive index coefficients
temper Temperature in K

Definition at line 1124 of file xsh_model_kernel.c.

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:
b exit vector
rind refractive index
a incident vector
Returns:
void

Definition at line 1915 of file xsh_model_kernel.c.

Referenced by xsh_3_eval().

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

matrix rotation

Parameters:
A matrix to be rotated
axis axis around which rotation occurs
angle rotation angle

Definition at line 1807 of file xsh_model_kernel.c.

References xsh_nullmatrix().

Referenced by xsh_rotin().

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

matrix rotation

Parameters:
A matrix to be rotated
x_angle rotation angle around X axis
y_angle rotation angle around Y axis
z_angle rotation angle around Z axis

Definition at line 1856 of file xsh_model_kernel.c.

References xsh_multiplymatrix(), and xsh_rotationmatrix().

Referenced by xsh_3_eval(), and xsh_3_init().

DOUBLE xsh_scalarproduct ( vec  a,
vec  b 
)

implements scalar product

Parameters:
a vector1
b vector2
Returns:
a*b

Definition at line 1620 of file xsh_model_kernel.c.

References vectordim.

void xsh_showmatrix ( mat  A  ) 

Show matrix.

Parameters:
A matrix to be shown

Definition at line 1741 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_model_anneal_reduce(), and xsh_model_first_anneal().

void xsh_showvector ( vec  a  ) 

show vector content

Parameters:
a vector

Definition at line 1643 of file xsh_model_kernel.c.

References vectordim.

void xsh_subtractvectors ( vec  a,
vec  b 
)

subtract 2 vectors a-=b

Parameters:
a vector1
b vector2
Returns:
void

Definition at line 1608 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_eval().

void xsh_transpose ( mat  A,
mat  B 
)

matrix transposal

Parameters:
A transposed matrix
B matrix to be transposed

Definition at line 1790 of file xsh_model_kernel.c.

References vectordim.

Referenced by xsh_3_init().


Generated on 9 Mar 2011 for X-shooter Pipeline Reference Manual by  doxygen 1.6.1