28#ifndef XSH_MODEL_KERNEL_H
29#define XSH_MODEL_KERNEL_H
98 DOUBLE rind,
rind2,
rind3,
rind_a1,
rind_a2,
rind_a3,
rind_b1,
rind_b2,
rind_lm1,
rind_lm2,
rind_lm3,
rind_wta0,
rind_wta1,
rind_wta2,
rind_wtb0,
rind_wtb1,
rind_wtb2;
107 DOUBLE mud,
nud,
taud,
pix,
pix_X,
pix_Y,
offx,
offy,
flipx,
flipy,
xpospix,
ypospix,
fdet;
123 double d2_y3x3,
d2_y3x2,
d2_y3x1,
d2_y3x0,
d2_y2x3,
d2_y2x2,
d2_y2x1,
d2_y2x0,
d2_y1x3,
d2_y1x2,
d2_y1x1,
d2_y1x0;
129 mat mup_ir_cor,
mup_ir_cor_out,
toprism1,
toprism2,
toprism3,
toprism4,
toprism5,
toprism6,
prism_out,
ret_prism2,
ret_prism1,
ret_prism_out1,
ret_prism4,
ret_prism3,
ret_prism_out2,
ret_prism6,
ret_prism5,
ret_prism_out3,
todetector;
200 double ent_slit_pos);
202 const char* tab_filename);
204 const char* line_list,
210 const char* line_list,
213 const char* THE_filename);
216 cpl_frame* resid_frame,
219 int scenario,
int rec_id);
232 cpl_parameterlist* parlist,
233 cpl_frameset* frameset);
236 cpl_parameterlist *,cpl_frameset *) ;
244 struct xs_3* p_xs_3);
247 double* posx,
double* posy,
248 int deg_poly,
int edge);
251 const char* tab_filename);
257 cpl_frame** wmap_frame,
258 cpl_frame** smap_frame,
const int save_tmp);
void xsh_transpose(mat A, mat B)
matrix transposal
void xsh_refract(vec, DOUBLE, vec)
Calculate the new vector after a given incident vector passes a boundary between two materials.
double * xsh_copy2D_to_1D(double **ccdtemp, int asize, int bsize)
copy 2D to 1D array
int ** xsh_alloc2Darray_i(int asize, int bsize)
allocates memory for a 2D array of integers
int xsh_model_offset(DOUBLE disp_pix_shift, DOUBLE slit_pix_shift, struct xs_3 *p_xs_3)
convert a pixel shift measured on the detector to a shift in detector centroid
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 Sellme...
float ** xsh_alloc2Darray_f(int asize, int bsize)
allocates memory for a 2D array of floats
void xsh_ref_ind_read(int arm, DOUBLE **ref_ind, DOUBLE temper)
Load the refractive index coeffs for a given arm and temperature.
void xsh_matrixforvector(vec a, mat B, vec c)
Realize a*B*c.
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...
cpl_vector * xsh_model_refining_detect(const cpl_vector *in, int fwhm, double sigma, int display)
Detect the brightest features in a spectrum.
void xsh_addvectors3D(vec, vec)
add 2 vectors a+=b
void xsh_subtractvectors(vec, vec)
subtract 2 vectors a-=b
void xsh_model_get_xy(xsh_xs_3 *p_xs_3, xsh_instrument *instr, double lambda_nm, int morder, double slit, double *x, double *y)
Compute the detector location (floating point pixels) of a given wavelength/entrance slit position.
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.
int xsh_free2Darray_f(float **ccdtemp, int asize)
free memory for a 2D array of floats
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.
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.
void xsh_model_binxy(struct xs_3 *p_xs_3, int bin_X, int bin_Y)
corrects model for detector's binning
double *** xsh_alloc3Darray(int asize, int bsize, int csize)
allocate 3D array
int xsh_model_first_anneal_save(const cpl_table *, xsh_instrument *, cpl_parameterlist *, cpl_frameset *)
Save the product of the recipe.
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 c...
void xsh_normz(vec a)
normalize vector
double *** xsh_alloc3Darray2(int asize, int bsize, int csize)
allocate 3D array
DOUBLE xsh_scalarproduct(vec, vec)
implements scalar product
void xsh_initializematrix(mat A)
initialize matrix A
int xsh_free3Darray(double ***ccdtemp, int asize, int bsize)
free 3D array
double ** xsh_copy1D_to_2D(double *oneDccdtemp, int asize, int bsize)
copy 1D to 2D array
cpl_frame * xsh_model_spectralformat_create(struct xs_3 *p_xs_3, const char *tab_filename)
creates the model spectral format table
double xsh_model_ref_ind_air(double temper, double lam_sqr)
Return the refractive index of air at a given wavelength and temperature.
void xsh_multiplymatrix(mat A, mat B, mat C)
multiply three matrixes A=B*C
void xsh_showmatrix(mat A)
Show matrix.
int xsh_model_first_anneal(cpl_parameterlist *parlist, cpl_frameset *frameset)
Interpret the command line options and execute the data processing.
DOUBLE * xsh_alloc1Darray(int asize)
allocates memory for an array of doubles
int xsh_free2Darray(double **ccdtemp, int asize)
free memory for a 2D array of doubles
int * xsh_alloc1Darray_INT(int asize)
allocates memory for an array of integers
void xsh_3_init(struct xs_3 *)
Pre-compute a number of non-wavelength dependent secondary parameters required by the model.
void xsh_showvector(vec a)
show vector content
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.
void xsh_multiplythreematrix(mat A, mat B, mat C, mat D)
multiply three matrixes A=B*C*D
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.
cpl_frame * xsh_model_THE_create(struct 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)
double ** xsh_alloc2Darray(int asize, int bsize)
allocates memory for a 2D array of doubles
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_addvectors(vec, vec)
add 2 vectors a+=b
void xsh_rotationmatrix(mat A, const char axis, const DOUBLE angle)
matrix rotation
void xsh_multiply(vec a, DOUBLE k)
applies scalar product to vector
void xsh_normall(vec a)
normalize vector
void xsh_rotin(mat A, const DOUBLE x_angle, const DOUBLE y_angle, const DOUBLE z_angle)
matrix rotation
int xsh_free2Darray_i(int **ccdtemp, int asize)
free memory for a 2D array of integers
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 wa...
void xsh_3_eval_check(DOUBLE lambda, int morder, DOUBLE **ref_ind, struct xs_3 *p_xs_3)
void xsh_3_detpix_check(struct xs_3 *p_xs_3)
int xsh_3_readfile(double *abest, double *amin, double *amax, int *aname, const char *, struct xs_3 *, ann_all_par *)
cpl_table * xsh_model_THE(struct xs_3 *p_xs_3, const char *line_list, xsh_instrument *instr, int num_ph, double sep_ph)