UVES Pipeline Reference Manual  5.4.0
uves_physmod_create_table.c
1 /* *
2  * This file is part of the ESO UVES Pipeline *
3  * Copyright (C) 2004,2005 European Southern Observatory *
4  * *
5  * This library is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18  * */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2010-09-24 09:32:07 $
23  * $Revision: 1.37 $
24  * $Name: not supported by cvs2svn $
25  */
26 
27 /*---------------------------------------------------------------------------*/
31 /*---------------------------------------------------------------------------*/
34 #ifdef HAVE_CONFIG_H
35 # include <config.h>
36 #endif
37 /*----------------------------------------------------------------------------
38  Includes
39  ----------------------------------------------------------------------------*/
40 #include <uves_physmod_create_table.h>
41 
42 #include <uves_physmod_utils.h>
43 #include <uves_utils_wrappers.h>
44 #include <uves_pfits.h>
45 #include <uves_msg.h>
46 #include <uves_error.h>
47 #include <string.h>
48 /*-----------------------------------------------------------------------------
49  Defines
50  ----------------------------------------------------------------------------*/
51 /*-----------------------------------------------------------------------------
52  Functions prototypes
53  ----------------------------------------------------------------------------*/
54 
55 static int
56 flames_get_trans(const int plt_no,
57  enum uves_chip chip,
58  const double wlen,
59  double * TX,
60  double * TY);
61 
62 static int
63 flames_get_physmod_offset(const int plate_no,
64  const int wavec,
65  enum uves_chip chip,
66  double* physmod_shift_x,
67  double* physmod_shift_y,
68  double* rot_1,
69  double* rot_2,
70  double* rot_3);
71 
72 
73 static int
74 uves_get_physmod_offset(const int wavec,
75  enum uves_chip chip,
76  const int binx,
77  const int biny,
78  double* trans_x,
79  double* trans_y,
80  double* rot_1,
81  double* rot_2,
82  double* rot_3);
83 
84 
85 
86 
87 /*-----------------------------------------------------------------------------
88  Static variables
89  ----------------------------------------------------------------------------*/
90 
91 /*-----------------------------------------------------------------------------
92  Functions code
93  ----------------------------------------------------------------------------*/
94 
95 /*---------------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------------*/
119 
120 
121 
122 
123 int
125  enum uves_chip chip,
126  bool flames,
127  const char *recipe_id,
128  const cpl_parameterlist* parameters,
129  cpl_table* line_refer,
130  const double physmod_shift_x,
131  const double physmod_shift_y,
132  cpl_table** mod_tbl,
133  cpl_table** fsr_tbl)
134 
135 {
136 
137  /* General */
138  int MBOX_X=0;
139  int MBOX_Y=0;
140  double TRANS_X=0;
141  double TRANS_Y=0;
142 
143  double ECH_ANG_OFF=0;
144  double CD_ANG_OFF=0;
145  double CCD_ANG_OFF=0;
146 
147 
148  int bin_x=0;
149  int bin_y=0;
150 
151 
152  int CMP_REG_SW=0;
153 
154  double binx=0;
155  double biny=0;
156 
157  double pressure=0;
158  double temp_cam=0;
159  double slit_width=0;
160  double slit_length=0;
161  double humidity=0;
162 
163 
164  double wcent=0;
165  double xtrans=0;
166  double ytrans=0;
167  double ccd_rot[2];
168  double offset_x[6];
169  double offset_y[6];
170 
171  const char* cd_id;
172  int CDID=0;
173  int status=0;
174 
175 
176  int aRowNumber=0;
177  int xpix=0;
178  int ypix=0;
179  int i=0;
180  int mm=0;
181  double xmod=0;
182  double ymod=0;
183  double blaze=0;
184  double binsize=0;
185  double pixscale=0;
186  double pixscalCD=0;
187  double linelenpx=0;
188  double linewidth=0;
189  double linewidpx=0;
190  double resol=0;
191  double xreg=0;
192  double yreg=0;
193  double fsr_min=0;
194  double fsr_max=0;
195  double xfsr_min=0;
196  double xfsr_max=0;
197  double yfsr_min=0;
198  double yfsr_max=0;
199  int m_min=0;
200  int m_max=0;
201  double lmin=0;
202  double lmax=0;
203  double dxpix=0;
204  double dypix=0;
205  double dblwav=0;
206  int imod=0;
207  double dl=0;
208  int mmin=0;
209  int mmax=0;
210  int ncol=0;
211  int order=0;
212  double xr=0;
213  double yr=0;
214  double lcent=0;
215 
216  double mbox_x=0;
217  double mbox_y=0;
218 
219  /* variables which were globals in physmodel */
220  double uves_beta_ech=0;
221  double uves_beta_cd=0 ;
222  double uves_physmod_rcd=0;
223  double uves_physmod_rech=0;
224  double uves_physmod_x_off=0;
225  double uves_physmod_y_off=0;
226  double x=0;
227  double y=0;
228  double fc=0;
229  double l=0;
230  int m=0;
231  int plate_no=0;
232  double ech_ang_off=0;
233  double cd_ang_off=0;
234  double ccd_ang_off=0;
235  double physmod_off_x=0;
236  double physmod_off_y=0;
237  int wavec=0;
238 
239 
240 
241  enum uves_arm_ident {UVES_ARM_UNDEF,UVES_ARM_BLUE,UVES_ARM_RED};
242  enum uves_arm_ident uves_arm_ident = UVES_ARM_UNDEF;
243  int upper;
244 
245  const char* ccd_id="";
246  const char* dpr_tech="";
247  /* initialize the configuration */
248 
249 
250  /* Read recipe parameters */
251  {
252  check( uves_get_parameter(parameters, NULL, recipe_id,
253  "mbox_x", CPL_TYPE_INT, &MBOX_X ) ,
254  "Could not read parameter");
255 
256  check( uves_get_parameter(parameters, NULL, recipe_id,
257  "mbox_y", CPL_TYPE_INT, &MBOX_Y ) ,
258  "Could not read parameter");
259 
260  check( uves_get_parameter(parameters, NULL, recipe_id,
261  "trans_x", CPL_TYPE_DOUBLE, &TRANS_X ) ,
262  "Could not read parameter");
263 
264  check( uves_get_parameter(parameters, NULL, recipe_id,
265  "trans_y", CPL_TYPE_DOUBLE, &TRANS_Y ) ,
266  "Could not read parameter");
267  xtrans=TRANS_X;
268  ytrans=TRANS_Y;
269 
270  /*
271 AMo 02/04/2004
272 We noticed that the physical model has in some way shifted on MIT, thus we apply corrections
273  */
274 
275 if ((xtrans == 0.) && (ytrans == 0.)) {
276  /*
277  If the user has not set its own defaults which we assume as the right ones
278  In case of MIT chip we apply a shift
279  */
280  if (chip == UVES_CHIP_REDU) {
281  //ytrans = 6.7;
282  }
283 }
284 
285  uves_msg_debug("xtrans=%f ytrans=%f",xtrans,ytrans);
286  check( uves_get_parameter(parameters, NULL, recipe_id,
287  "ech_angle_off", CPL_TYPE_DOUBLE, &ECH_ANG_OFF ) ,
288  "Could not read parameter");
289 
290  check( uves_get_parameter(parameters, NULL, recipe_id,
291  "cd_angle_off", CPL_TYPE_DOUBLE, &CD_ANG_OFF ) ,
292  "Could not read parameter");
293 
294  check( uves_get_parameter(parameters, NULL, recipe_id,
295  "ccd_rot_angle_off", CPL_TYPE_DOUBLE, &CCD_ANG_OFF ) ,
296  "Could not read parameter");
297 
298  check( uves_get_parameter(parameters, NULL, recipe_id,
299  "compute_regression_sw", CPL_TYPE_BOOL, &CMP_REG_SW ) ,
300  "Could not read parameter");
301 
302 
303 
304  /* check parameters */
305  }
306 
307  /* get instrument configuration setting keywords */
308  check (ccd_id = uves_pfits_get_chipid(raw_header,chip),
309  "Could not read CCD ID from input header");
310  check (dpr_tech = uves_pfits_get_dpr_tech(raw_header),
311  "Could not read DPR TECH from input header");
312  uves_msg("DPR TECH=%s<",dpr_tech);
313  if(strstr(dpr_tech,"MOS")!=NULL) {
314  check_nomsg( plate_no = uves_flames_pfits_get_plateid(raw_header) );
315  uves_msg("PLATE NO=%d",plate_no);
316  }
317 
318  if(strcmp(ccd_id,"CCD-44b") == 0) {
319  uves_msg("New Spectral Format");
320  offset_x[0]=1355.0;
321  offset_x[1]=1350.0;
322  offset_x[2]=1852.0;
323  offset_x[3]=1835.0;
324  offset_x[4]=1852.0;
325  offset_x[5]=1834.0;
326 
327  offset_y[0]=1030.0;
328  offset_y[1]=1023.0;
329  offset_y[2]=2098.0;
330  offset_y[3]=2104.0;
331  offset_y[4]=-52.0;
332  offset_y[5]=-49.0;
333  ccd_rot[0]=0.3;
334  ccd_rot[1]=-0.10;
335 
336  } else {
337  uves_msg("Old Spectral Format");
338 
339  offset_x[0]=1391.0;
340  offset_x[1]=1385.0;
341  offset_x[2]=1852.0;
342  offset_x[3]=1835.0;
343  offset_x[4]=1852.0;
344  offset_x[5]=1834.0;
345 
346  offset_y[0]=1030.0;
347  offset_y[1]=1025.0;
348  offset_y[2]=2098.0;
349  offset_y[3]=2104.0;
350  offset_y[4]=-52.0;
351  offset_y[5]=-49.0;
352 
353  ccd_rot[0]=0.3;
354  ccd_rot[1]=-0.55;
355 
356  }
357 
358 
359  check (biny = uves_pfits_get_binx(raw_header),
360  "Could not read x binning factor from input header");
361 
362  check (binx = uves_pfits_get_biny(raw_header),
363  "Could not read x binning factor from input header");
364 
365  check (pressure = uves_pfits_get_pressure(raw_header),
366  "Could not read pressure from input header");
367 
368  /*
369  check (humidity = uves_pfits_get_humidity(raw_header),
370  "Could not read humidity from input header");
371  */
372  humidity=3.;
373 
374 
375 /* New code */
376  check (slit_width = uves_pfits_get_slitwidth(raw_header, chip),
377  "Could not read slit width input header");
378 
379  check (slit_length = uves_pfits_get_slitlength(raw_header, chip),
380  "Could not read slit length input header");
381 
382  check (wcent = uves_pfits_get_gratwlen(raw_header, chip),
383  "Could not read central wavelength setting from input header");
384 
385  check (cd_id = uves_pfits_get_gratid(raw_header, chip),
386  "Could not read central CD ID setting from input header");
387 
388  check (temp_cam = uves_pfits_get_tempcam(raw_header,chip),
389  "Could not read camera's temperature from input header");
390 
391  if (chip == UVES_CHIP_BLUE)
392  {
393  uves_arm_id='b';
394  uves_arm_ident=UVES_ARM_BLUE;
395 
396  }
397  else
398  {
399  uves_arm_id='r';
400  uves_arm_ident=UVES_ARM_RED;
401  }
402  upper = (chip == UVES_CHIP_REDU);
403 
404 
405 
406 
407  if(strstr(cd_id,"CD#1") != NULL) {
408  CDID=1;
409  } else if(strstr(cd_id,"CD#2") != NULL) {
410  CDID=2;
411  } else if(strstr(cd_id,"CD#3") != NULL) {
412  CDID=3;
413  } else if(strstr(cd_id,"CD#4") != NULL) {
414  CDID=4;
415  } else {
416  CDID=0;
417  }
418 
419  mbox_x=MBOX_X/binx;
420  mbox_y=MBOX_Y/biny;
421  uves_msg("UVES configuration:");
422  uves_msg("Optical path: %s (%s)",
423  UVES_ARM(chip),UVES_ARMID(chip));
424 
425  uves_msg("Detector: %s Binning: %1.1f, %1.1f pix/bin",
426  UVES_DETECTOR(chip),binx,biny);
427  uves_msg("Cross disperser ID, number: %s %d",cd_id,CDID);
428  uves_msg("Central wavelength: %4.1f nm",wcent);
429  uves_msg("Slit width: %3.1f (arcsecs)",slit_width);
430  uves_msg("Slit length: %3.1f (arcsecs)",slit_length);
431  uves_msg("Temperature: %3.1f C",temp_cam);
432  uves_msg("Air pressure: %4.1f mmHg/cm^2",pressure);
433  uves_msg("Humidity: %2.1f %%",humidity);
434 
435  uves_msg_debug("chip =%s", uves_chip_tostring_upper(chip));
436 
437 
438  /* read input frame (line table) */
439  ncol=cpl_table_get_ncol(line_refer);
440 
441  aRowNumber = cpl_table_get_nrow(line_refer);
442 
443  uves_msg_debug("Opened table %s ncol=%d nrow=%d","line_ref_table" ,ncol,aRowNumber);
444 
445  uves_air_config(pressure/1.33322, temp_cam, humidity);
446  uves_msg("Air Index = %g",uves_air_index(wcent));
447  if(strstr(dpr_tech,"MOS")!=NULL) {
448  uves_msg("uves chip=%s ",uves_chip_tostring_upper(chip));
449  flames_get_trans(plate_no,chip,wcent,&TRANS_X,&TRANS_Y);
450  //xtrans=TRANS_X+physmod_shift_x;
451  //ytrans=TRANS_Y+physmod_shift_y;
452 
453  xtrans=physmod_shift_x;
454  ytrans=physmod_shift_y;
455  }
456 
457 
458  /* check if old or new CCD, and eventually apply shifts */
459  check_nomsg(bin_x=uves_pfits_get_binx(raw_header));
460  check_nomsg(bin_y=uves_pfits_get_biny(raw_header));
461  uves_msg("CHECK: xtrans=%f ytrans=%f,ccdrot[0]=%f,ccdrot[1]=%f",
462  xtrans,ytrans,ccd_rot[0],ccd_rot[1]);
463 
464  if(uves_ccd_is_new(raw_header)) {
465 
466  if(chip != UVES_CHIP_BLUE) {
467  check_nomsg(wavec=(int)uves_pfits_get_gratwlen(raw_header,chip));
468  if(flames) {
469  ck0_nomsg(flames_get_physmod_offset(plate_no,wavec,chip,
470  &physmod_off_x,
471  &physmod_off_y,
472  &ech_ang_off,
473  &cd_ang_off,
474  &ccd_ang_off));
475  } else {
476  ck0_nomsg(uves_get_physmod_offset(wavec,chip,binx,biny,
477  &physmod_off_x,
478  &physmod_off_y,
479  &ech_ang_off,
480  &cd_ang_off,
481  &ccd_ang_off));
482  }
483  ECH_ANG_OFF +=ech_ang_off;
484  CD_ANG_OFF +=cd_ang_off;
485  CCD_ANG_OFF +=ccd_ang_off;
486  xtrans+=physmod_off_x;
487  ytrans+=physmod_off_y;
488 
489  }
490  }
491 
492  uves_msg("CHECK: xtrans=%f ytrans=%f,ccdrot[0]=%f,ccdrot[1]=%f",
493  xtrans,ytrans,ccd_rot[0],ccd_rot[1]);
494  uves_msg("CHECK: ECH_ANG_OFF=%f CD_ANG_OFF=%f,CCD_ANG_OFF=%f",
495  ECH_ANG_OFF,CD_ANG_OFF,CCD_ANG_OFF);
496 
497 
498 
499 
500  uves_msg("Shift in x = %6.3f pix, shift in y = %6.3f pix",TRANS_X,TRANS_Y);
501  uves_msg("External Shift in x = %6.3f pix, shift in y = %6.3f pix",
502  physmod_shift_x,physmod_shift_y);
503  uves_msg("Offset angle of echelle, CD, CCD rotation (deg): "
504  "%4.3f, %4.3f, %4.3f",ECH_ANG_OFF,CD_ANG_OFF,CCD_ANG_OFF);
505 
506  uves_set_ccd_rot(ccd_rot,CCD_ANG_OFF, CCD_ANG_OFF);
507  uves_physmod_set_incidence(ECH_ANG_OFF, ECH_ANG_OFF, CD_ANG_OFF, CD_ANG_OFF);
508  uves_msg_debug("ccdbin=%f,%f",binx,biny);
509  uves_msg_debug("offset x=%f %f %f %f %f %f",
510  offset_x[0],offset_x[1],offset_x[2],offset_x[3],offset_x[4],offset_x[5]);
511 
512  uves_msg_debug("offset y=%f %f %f %f %f %f",
513  offset_y[0],offset_y[1],offset_y[2],offset_y[3],offset_y[4],offset_y[5]);
514 
515  uves_msg("Central wavelength: %4.2f nm",wcent);
516  uves_msg_debug("chip =%s", uves_chip_tostring_upper(chip));
517  /* uves_msg("uves_arm=%c",ArmId); */ /* b/r */
518  uves_msg_debug("uves_arm_ident=%d",uves_arm_ident); /* b/r */
519 
520  /* uves_msg("chipid=%s",CHIP[0]); */ /* upper/lower chip */
521  /* uves_msg("cdid=%s",CDID); */ /* 1-4 for CD#1-4 */
522  /* uves_cfg_indx = uves_config(ArmId[0],CHIP[0],CDID,wcent,binx,biny); */
523  uves_cfg_indx = uves_config_cpl_new(uves_arm_ident,upper,CDID,wcent,binx,biny);
524  uves_msg_debug("uves_cfg_indx=%d",uves_cfg_indx);
525 
526  uves_physmod_set_offset(offset_x[uves_cfg_indx-1],offset_y[uves_cfg_indx-1],
527  uves_physmod_x_off,uves_physmod_y_off);
528 
529 /* =========================================================================
530  * Computation of the true pixel-scale along echelle dispersion
531  * scale = (K*FocalRatioNasmyth*PixelSize*ApertureCamera*1e-3)/FocalNasmyth
532  * K = 206265 : conversion radian to arcsec (1 radian = 206265 arcsec)
533  * scale = (206265.0*15.0*0.015*200*1e-3*CCDBIN[0])/120000;
534  * =========================================================================
535  */
536 
537 /* Creation of modtbl */
538 
539  *mod_tbl= cpl_table_new(3*aRowNumber);
540 
541  uves_msg("table created: %s ncol=%d, nrow=%d","mod_tbl",10,3*aRowNumber);
542  cpl_table_new_column(*mod_tbl,"WAVE",CPL_TYPE_DOUBLE);
543  cpl_table_new_column(*mod_tbl,"ORDER",CPL_TYPE_INT);
544  cpl_table_new_column(*mod_tbl,"XMOD",CPL_TYPE_DOUBLE);
545  cpl_table_new_column(*mod_tbl,"YMOD",CPL_TYPE_DOUBLE);
546  cpl_table_new_column(*mod_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
547  cpl_table_new_column(*mod_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
548  cpl_table_new_column(*mod_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
549  cpl_table_new_column(*mod_tbl,"RESOL",CPL_TYPE_DOUBLE);
550  cpl_table_new_column(*mod_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
551  cpl_table_new_column(*mod_tbl,"BLAZE",CPL_TYPE_DOUBLE);
552 
553  uves_ccd_size(&xpix,&ypix);
554  uves_msg_debug("CCDsize: %d %d",xpix,ypix);
555 
556 
557  for (i=0; i<aRowNumber; i++) {
558 
559  //for (i=450; i<451; i++) {
560 
561 
562 
563 
564  /* why we do access line i+1? */
565  dblwav=cpl_table_get_double(line_refer, "Wave",i,&status);
566  uves_msg_debug(" i: %d Line: %f",i,dblwav);
567 
568  dblwav /= 10.0; /* (10.0: conversion factor from nm to A)*/
569  order = uves_physmod_find_order(dblwav);
570  uves_msg_debug("order=%d",order);
571 
572  order++;
573 
574 /* Computes the positions xmod and ymod for the order-1, order, order+1 */
575 /* and adds a row to the modtbl only if the position are insight the CCD */
576 
577  for (mm=0; mm<3; mm++){
578  /*uves_physmod_xy_model(dblwav, order, &xmod, &ymod);
579  blaze = blz; */
580  /* The next line fails */
581  uves_physmod_lambda_order2beta(dblwav, order, &uves_beta_ech, &uves_beta_cd, &fc);
582 
583  uves_msg_debug("uves_beta_ech %f, uves_beta_cd %f, fc %f",
584  uves_beta_ech, uves_beta_cd, fc);
585 
586  uves_beta2xy(uves_beta_cd, uves_beta_ech, fc, &xmod, &ymod);
587  uves_msg_debug("xmod=%f ymod=%f",xmod,ymod);
588  /* Computes the anamorphic magnification and the blaze function */
589  uves_physmod_photo_beta(dblwav, uves_beta_ech, uves_beta_cd,
590  &uves_physmod_rech, &uves_physmod_rcd, &blaze);
591 
592  uves_msg_debug("uves_physmod_rech %f, uves_physmod_rcd %f, blaze %f",
593  uves_physmod_rech, uves_physmod_rcd, blaze);
594 
595 /* Translation */
596 
597  uves_msg_debug("Before translation: xmod %f, ymod %f",xmod, ymod);
598 
599  xmod += xtrans;
600  ymod += ytrans;
601  uves_msg_debug("xtrans=%f ytrans=%f xmod=%f ymod=%f",
602  xtrans, ytrans, xmod, ymod);
603 
604  uves_msg_debug("After translation: xmod %f, ymod %f",xmod, ymod);
605  uves_msg_debug("xpix=%d ypix=%d",xpix,ypix);
606 
607  uves_msg_debug("binx=%f biny=%f",binx,biny);
608 
609  if (xmod > 0 && xmod < xpix && ymod > 0 && ymod < ypix) {
610 
611 /* Computes the width (in pixel and A) and resolution lines */
612  uves_physmod_pixscl(dblwav, order, uves_physmod_rech, uves_physmod_rcd,
613  binx, biny, fc, slit_width, slit_length,
614  &binsize, &pixscale, &pixscalCD, &linewidpx,
615  &linelenpx, &linewidth, &resol);
616 
617  uves_msg_debug("binsize %f, pixscale %f, pixscalCD %f",
618  binsize,pixscale,pixscalCD);
619  uves_msg_debug("linewidpx %f, linelenpx %f, linewidth %f, resol %f",
620  linewidpx,linelenpx,linewidth,resol);
621 
622 /* Compute/regress */
623  if (CMP_REG_SW) {
624  uves_physmod_xy_regres(xmod,ymod,&xreg,&yreg);
625  } else {
626  xreg = xmod;
627  yreg = ymod;
628  }
629 
630 
631  uves_msg_debug("Fill tab: i=%d wave=%f order=%d xmod=%f ymod=%f",
632  i,dblwav,order,xmod,ymod);
633 
634  uves_msg_debug("Fill tab: bin_sixe=%f xreg=%f yreg=%f ",
635  binsize,xreg,yreg);
636 
637  uves_msg_debug("Fill tab: linewidpx=%f linewidth=%f resol=%f linelenpx=%f blaze=%f",
638 linewidpx,linewidth,resol,linelenpx,blaze);
639 
640 
641  cpl_table_set_double(*mod_tbl, "WAVE" ,imod, dblwav);
642  cpl_table_set_int (*mod_tbl, "ORDER" ,imod, order);
643  cpl_table_set_double(*mod_tbl, "XMOD" ,imod, xreg);
644  cpl_table_set_double(*mod_tbl, "YMOD" ,imod, yreg);
645  cpl_table_set_double(*mod_tbl, "BIN_SIZE" ,imod, binsize);
646  cpl_table_set_double(*mod_tbl, "LINEWIDPX",imod, linewidpx);
647  cpl_table_set_double(*mod_tbl, "LINEWIDTH",imod, linewidth);
648  cpl_table_set_double(*mod_tbl, "RESOL" ,imod, resol);
649  cpl_table_set_double(*mod_tbl, "LINELENPX",imod, linelenpx);
650  cpl_table_set_double(*mod_tbl, "BLAZE" ,imod, blaze);
651  ++imod;
652 
653  }
654  order--;
655  } /* end loop over mm */
656  } /* end loop over i */
657 
658  cpl_table_duplicate_column(*mod_tbl,"IDENT",*mod_tbl,"WAVE");
659  cpl_table_multiply_scalar(*mod_tbl,"IDENT",10.);
660  cpl_table_duplicate_column(*mod_tbl,"XSTART",*mod_tbl,"XMOD");
661  cpl_table_add_scalar(*mod_tbl,"XSTART",-mbox_x/2.);
662  cpl_table_duplicate_column(*mod_tbl,"YSTART",*mod_tbl,"YMOD");
663  cpl_table_add_scalar(*mod_tbl,"YSTART",-mbox_y/2.);
664  cpl_table_duplicate_column(*mod_tbl,"XEND",*mod_tbl,"XMOD");
665  cpl_table_add_scalar(*mod_tbl,"XEND",mbox_x/2.);
666  cpl_table_duplicate_column(*mod_tbl,"YEND",*mod_tbl,"YMOD");
667  cpl_table_add_scalar(*mod_tbl,"YEND",mbox_y/2.);
668 
669 
670 /* close everything */
671 
672 
673 
674  uves_msg("Predicted number of lines: %d",imod);
675 
676 /* Compute the free spectral range */
677 
678  uves_msg("Determine the Free Spectral Range");
679 
680  dxpix = (double) xpix;
681  dypix = (double) ypix;
682 
683  m_min = -1;
684  m_max = -1;
685 /*
686  uves_physmod_lambda_order_model(&l,&m_max,dxpix/2,1.0);
687  uves_physmod_lambda_order_model(&l,&m_min,dxpix/2,dypix);
688 */
689  uves_physmod_lambda_order_model(&lmax,&m_min,1.0,dypix);
690  uves_physmod_lambda_order_model(&lmin,&m_max,dxpix,1.0);
691 
692  uves_physmod_lambda_order_model(&lmax,&m_min,dxpix,dypix);
693  uves_physmod_lambda_order_model(&lmin,&m_max,1.0,1.0);
694 
695 
696  uves_msg_debug("m_min= %d,m_max= %d",m_min,m_max);
697 
698 
699 /* Creation of the modfree_sp_rg.tbl table */
700 
701  *fsr_tbl=cpl_table_new(m_max-m_min+1);
702 
703  uves_msg("FSR tbl created: %s. No of columns: %d, No of rows: %d","free_spectral_range",
704  20,m_max-m_min+1);
705  cpl_table_new_column(*fsr_tbl,"ORDER",CPL_TYPE_INT);
706  cpl_table_new_column(*fsr_tbl,"WVCENTCOL",CPL_TYPE_DOUBLE);
707  cpl_table_new_column(*fsr_tbl,"YCENTCOL",CPL_TYPE_DOUBLE);
708  cpl_table_new_column(*fsr_tbl,"START",CPL_TYPE_DOUBLE);
709  cpl_table_new_column(*fsr_tbl,"END",CPL_TYPE_DOUBLE);
710  cpl_table_new_column(*fsr_tbl,"WAVECENT",CPL_TYPE_DOUBLE);
711  cpl_table_new_column(*fsr_tbl,"YCENT",CPL_TYPE_DOUBLE);
712  cpl_table_new_column(*fsr_tbl,"FSRMIN",CPL_TYPE_DOUBLE);
713  cpl_table_new_column(*fsr_tbl,"FSRMAX",CPL_TYPE_DOUBLE);
714  cpl_table_new_column(*fsr_tbl,"XFSR_MIN",CPL_TYPE_DOUBLE);
715  cpl_table_new_column(*fsr_tbl,"XFSR_MAX",CPL_TYPE_DOUBLE);
716  cpl_table_new_column(*fsr_tbl,"YFSR_MIN",CPL_TYPE_DOUBLE);
717  cpl_table_new_column(*fsr_tbl,"YFSR_MAX",CPL_TYPE_DOUBLE);
718  cpl_table_new_column(*fsr_tbl,"PIXSCALE",CPL_TYPE_DOUBLE);
719  cpl_table_new_column(*fsr_tbl,"PIXSCALCD",CPL_TYPE_DOUBLE);
720  cpl_table_new_column(*fsr_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
721  cpl_table_new_column(*fsr_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
722  cpl_table_new_column(*fsr_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
723  cpl_table_new_column(*fsr_tbl,"RESOL",CPL_TYPE_DOUBLE);
724  cpl_table_new_column(*fsr_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
725 
726 
727  imod = 0;
728  uves_msg_debug("m, waveCentcol, Start, End, yCent, FSRmin, FSRmax, bin (mA)");
729 
730  for (m=m_max; m>=m_min; m--) {
731  uves_msg_debug("%d ",m);
732  uves_physmod_find_FSR(m,&l, &fsr_min, &fsr_max);
733 
734  uves_physmod_xy_model(l,m,&x,&y);
735 
736 /* Translation */
737  x += xtrans;
738  y += ytrans;
739 
740  uves_physmod_xy_model(fsr_min,m,&xfsr_min,&yfsr_min);
741 
742 /* Translation */
743  xfsr_min += xtrans;
744  yfsr_min += ytrans;
745 
746  uves_physmod_xy_model(fsr_max,m,&xfsr_max,&yfsr_max);
747 
748 /* Translation */
749  xfsr_max += xtrans;
750  yfsr_max += ytrans;
751 
752 /* Computes the anamorphic magnification and the blaze function */
753  uves_physmod_lambda_order2beta(l,m, &uves_beta_ech, &uves_beta_cd, &fc);
754  uves_physmod_photo_beta(l, uves_beta_ech, uves_beta_cd,
755  &uves_physmod_rech, &uves_physmod_rcd, &blaze);
756 
757 
758 
759 /* Computes the width (in pixel and A) and resolution lines */
760  uves_physmod_pixscl(l, m, uves_physmod_rech, uves_physmod_rcd,
761  binx, biny, fc, slit_width, slit_length,
762  &dl, &pixscale, &pixscalCD,
763  &linewidpx, &linelenpx, &linewidth, &resol);
764 
765  mmin = m;
766  mmax = m;
767 
768 
769 
770 /* WARNING! The central column doesn't correspond to the central wavelength position */
771  uves_physmod_lambda_order_model(&lcent,&m,dxpix/2,y);
772  uves_physmod_xy_model(lcent,m,&xr,&yr);
773 
774  uves_physmod_lambda_order_model(&lmax,&mmax,dxpix,y);
775  uves_physmod_lambda_order_model(&lmin,&mmin,1.0,y);
776 
777 /* if (y>=0. && y <=dypix) {*/
778 
779  uves_msg_debug("m=%d, waveCent (nm)=%f, Start=%f, End=%f",m,l,lmin,lmax);
780  uves_msg_debug("yCent=%f,FSRmin=%f,FSRmax=%f,bin (mA)=%f",y,fsr_min,fsr_max,dl);
781 
782 
783  uves_msg_debug("%d %f %f %f %f %f %f %f",m,lcent,lmin,lmax,yr,fsr_min,fsr_max,dl);
784 
785 
786  uves_msg_debug("pixel-scale = %f, anamorphic corrections = %f, %f",
787  pixscale, uves_physmod_rech, uves_physmod_rcd);
788 
789 
790  cpl_table_set_int(*fsr_tbl, "ORDER",imod,m);
791  cpl_table_set_double(*fsr_tbl, "WVCENTCOL",imod,lcent);
792  cpl_table_set_double(*fsr_tbl, "YCENTCOL",imod,yr);
793  cpl_table_set_double(*fsr_tbl, "START",imod,lmin);
794  cpl_table_set_double(*fsr_tbl, "END",imod,lmax);
795  cpl_table_set_double(*fsr_tbl, "WAVECENT",imod,l);
796  cpl_table_set_double(*fsr_tbl, "YCENT",imod,y);
797  cpl_table_set_double(*fsr_tbl, "FSRMIN",imod,fsr_min);
798  cpl_table_set_double(*fsr_tbl, "FSRMAX",imod,fsr_max);
799  cpl_table_set_double(*fsr_tbl, "XFSR_MIN",imod,xfsr_min);
800  cpl_table_set_double(*fsr_tbl, "XFSR_MAX",imod,xfsr_max);
801  cpl_table_set_double(*fsr_tbl, "YFSR_MIN",imod,yfsr_min);
802  cpl_table_set_double(*fsr_tbl, "YFSR_MAX",imod,yfsr_max);
803  cpl_table_set_double(*fsr_tbl, "PIXSCALE",imod,pixscale);
804  cpl_table_set_double(*fsr_tbl, "PIXSCALCD",imod,pixscalCD);
805  cpl_table_set_double(*fsr_tbl, "BIN_SIZE",imod,dl);
806  cpl_table_set_double(*fsr_tbl, "LINEWIDPX",imod,linewidpx);
807  cpl_table_set_double(*fsr_tbl, "LINEWIDTH",imod,linewidth);
808  cpl_table_set_double(*fsr_tbl, "RESOL",imod,resol);
809  cpl_table_set_double(*fsr_tbl, "LINELENPX",imod,linelenpx);
810  ++imod;
811 
812 /* }*/
813  }
814 
815  /* To remove possible NULL entries */
816  cpl_table_erase_invalid_rows(*mod_tbl);
817 
818  /* Now we do the polynomial fit */
819  uves_msg_debug("End determination fsr range");
820 
821 
822  cleanup:
823 
824  return 0;
825 }
826 
827 
828 static int
829 flames_get_trans(const int plt_no,
830  enum uves_chip chip,
831  const double wlen,
832  double * TX,
833  double * TY)
834 {
835 
836 
837  if(plt_no==1) {
838  if( chip==UVES_CHIP_REDL) {
839  if(wlen==520) {
840  *TX = -15.330;
841  *TY = -40.461;
842  } else if (wlen == 580) {
843  *TX = -17.972;
844  *TY = -39.200;
845  } else if (wlen == 860) {
846  *TX= -12.212;
847  *TY= -49.370;
848  }
849  } else {
850  if(wlen==520) {
851  *TX = -14.237;
852  *TY = -40.337;
853  } else if (wlen == 580) {
854  *TX= -14.738;
855  *TY= -38.831;
856  } else if (wlen == 860) {
857 
858  *TX = -8.253;
859  *TY = -45.385;
860  }
861  }
862  } else if (plt_no==2) {
863  if( chip==UVES_CHIP_REDL) {
864  if(wlen==520) {
865  *TX = +10.136;
866  *TY = -41.420;
867  } else if (wlen == 580) {
868  *TX = +9.000;
869  *TY = -38.289;
870  } else if (wlen == 860) {
871  *TX = +16.386;
872  *TY = -47.519;
873  }
874  } else {
875  if(wlen==520) {
876  *TX = +12.244;
877  *TY = -41.970;
878  } else if (wlen == 580) {
879  *TX = +12.023;
880  *TY = -38.165;
881  } else if (wlen == 860) {
882  *TX = +18.241;
883  *TY = -43.889;
884  }
885  }
886 
887  } else {
888  uves_msg_warning("plt_no=%d chip=%d Wlen %g is not standard setting setting defaults",plt_no,chip,wlen);
889  *TX = 0;
890  *TY = 0;
891  }
892  return 0;
893 
894 }
895 
896 
897 /*---------------------------------------------------------------------------*/
908 /*---------------------------------------------------------------------------*/
909 
910 
911 static int
912 uves_get_physmod_offset(const int wavec,
913  enum uves_chip chip,
914  const int binx,
915  const int biny,
916  double* trans_x,
917  double* trans_y,
918  double* ech_ang_off,
919  double* cd_ang_off,
920  double* ccd_ang_off)
921 {
922 
923  //For the moment rot angle default is assumed always 0,0,0
924  *ech_ang_off=0;
925  *cd_ang_off=0;
926  *ccd_ang_off=0;
927 
928  uves_msg("wavec=%d,chip=%d binx=%d biny=%d",wavec,chip,binx,biny);
929 
930  if(binx==1 && biny == 1) {
931 
932 
933 
934  if(chip==UVES_CHIP_REDL) {
935  switch(wavec){
936  case 520:
937  *trans_x=3.0703;
938  *trans_y=6.8252;
939  *ccd_ang_off=-0.338;
940  uves_msg("case ech 520 REDL 1x1");
941  break;
942 
943  case 564:
944  *trans_x=2.2151;
945  *trans_y=0.1092;
946  *ccd_ang_off=-.319;
947  uves_msg("case ech 564 REDL 1x1");
948  break;
949 
950  case 580:
951  *trans_x=1.7116;
952  *trans_y=-0.4874;
953  *ccd_ang_off=-0.321;
954  uves_msg("case ech 580 REDL 1x1");
955  break;
956 
957  case 600:
958  *trans_x=0.1581;
959  *trans_y=5.3308;
960  *ccd_ang_off=-.344;
961  uves_msg("case ech 600 REDL 1x1");
962  break;
963 
964  case 620:
965  *trans_x=10.3267;
966  *trans_y=2.7942;
967  *ccd_ang_off=-0.338;
968  uves_msg("case ech 620 REDL 1x1");
969  break;
970 
971 
972  case 640:
973  *trans_x=0.3785;
974  *trans_y=-3.8460;
975  *ccd_ang_off=-0.338;
976  uves_msg("case ech 640 REDL 1x1");
977  break;
978 
979 
980  case 660:
981  *trans_x=9.7465;
982  *trans_y=0.7125;
983  *ccd_ang_off=-0.338;
984  uves_msg("case ech 660 REDL 1x1");
985  break;
986 
987  case 680:
988  *trans_x=9.3649;
989  *trans_y=-2.4116;
990  *ccd_ang_off=-0.338;
991  uves_msg("case ech 680 REDL 1x1");
992  break;
993 
994  case 700:
995  *trans_x=8.9850;
996  *trans_y=-5.6122;
997  *ccd_ang_off=-0.338;
998  uves_msg("case ech 700 REDL 1x1");
999  break;
1000 
1001  case 720:
1002  *trans_x=8.7393;
1003  *trans_y=-7.0060;
1004  *ccd_ang_off=-0.338;
1005  uves_msg("case ech 720 REDL 1x1");
1006  break;
1007 
1008  case 740:
1009  *trans_x=8.2659;
1010  *trans_y=-4.3401;
1011  *ccd_ang_off=-0.338;
1012  uves_msg("case ech 740 REDL 1x1");
1013  break;
1014 
1015 
1016  case 760:
1017  *trans_x=8.6384;
1018  *trans_y=1.9904;
1019  *trans_x=8.1006;
1020  *trans_y=-1.0859;
1021  *ccd_ang_off=-.335;
1022  uves_msg("case ech 760 REDL 1x1");
1023  break;
1024 
1025 
1026  case 780:
1027  *trans_x=7.8761;
1028  *trans_y=0.5324;
1029  *ccd_ang_off=-0.338;
1030  uves_msg("case ech 780 REDL 1x1");
1031  break;
1032 
1033 
1034  case 800:
1035  *trans_x=7.5052;
1036  *trans_y=0.7860;
1037  *ccd_ang_off=-0.338;
1038  uves_msg("case ech 800 REDL 1x1");
1039  break;
1040 
1041  case 820:
1042  *trans_x=7.2100;
1043  *trans_y=-1.8423;
1044  *ccd_ang_off=-0.338;
1045  uves_msg("case ech 820 REDL 1x1");
1046  break;
1047 
1048  case 840:
1049  *trans_x=6.8437;
1050  *trans_y=-4.9477;
1051  *ccd_ang_off=-0.338;
1052  uves_msg("case ech 820 REDL 1x1");
1053  break;
1054 
1055  case 860:
1056  *trans_x=6.8385;
1057  *trans_y=-3.0247;
1058  *ccd_ang_off=-.350;
1059  uves_msg("case ech 860 REDL 1x1");
1060  break;
1061 
1062  case 880:
1063  *trans_x=6.4751;
1064  *trans_y=-8.2393;
1065  *ccd_ang_off=-.350;
1066  uves_msg("case ech 880 REDL 1x1");
1067  break;
1068 
1069  case 900:
1070  *trans_x=5.9872;
1071  *trans_y=-7.5682;
1072  *ccd_ang_off=-.350;
1073  uves_msg("case ech 900 REDL 1x1");
1074  break;
1075 
1076  default:
1077  *ccd_ang_off=-0.338;
1078  break;
1079 
1080  }
1081  } else {
1082 
1083  switch(wavec){
1084  case 520:
1085  *trans_x=3.5471;
1086  *trans_y=14.6995;
1087  *ccd_ang_off=-.131;
1088  uves_msg("case ech 520 REDU 1x1");
1089  break;
1090 
1091  case 564:
1092  *trans_x=3.8134;
1093  *trans_y=8.0660;
1094  *ccd_ang_off=-0.161;
1095  uves_msg("case ech 564 REDU 1x1");
1096  break;
1097 
1098  case 580:
1099  *trans_x=2.2649;
1100  *trans_y=7.5163;
1101  *ccd_ang_off=-.106;
1102  uves_msg("case ech 580 REDU 1x1");
1103  break;
1104 
1105  case 600:
1106  *trans_x=2.3765;
1107  *trans_y=12.9146;
1108  *ccd_ang_off=-.112;
1109  uves_msg("case ech 600 REDU 1x1");
1110  break;
1111 
1112  case 620:
1113  *trans_x=10.7635;
1114  *trans_y=13.2254;
1115  *ccd_ang_off=-.131;
1116  uves_msg("case ech 620 REDL 1x1");
1117  break;
1118 
1119  case 640:
1120  *trans_x=2.6177;
1121  *trans_y=10.0995;
1122  *ccd_ang_off=-.131;
1123  uves_msg("case ech 640 REDL 1x1");
1124  break;
1125 
1126  case 660:
1127  *trans_x=10.4909;
1128  *trans_y=11.3694;
1129  *ccd_ang_off=-.131;
1130  uves_msg("case ech 660 REDL 1x1");
1131  break;
1132 
1133  case 680:
1134  *trans_x=10.4899;
1135  *trans_y=8.4049;
1136  *ccd_ang_off=-.131;
1137  uves_msg("case ech 680 REDL 1x1");
1138  break;
1139 
1140  case 700:
1141  *trans_x=10.2939;
1142  *trans_y=5.3955;
1143  *ccd_ang_off=-.131;
1144  uves_msg("case ech 700 REDL 1x1");
1145  break;
1146 
1147 
1148  case 720:
1149  *trans_x=9.9791;
1150  *trans_y=4.0860;
1151  *ccd_ang_off=-.131;
1152  uves_msg("case ech 720 REDL 1x1");
1153  break;
1154 
1155  case 740:
1156  *trans_x=9.8533;
1157  *trans_y=6.9165;
1158  *ccd_ang_off=-.131;
1159  uves_msg("case ech 740 REDL 1x1");
1160  break;
1161 
1162 
1163  case 760:
1164  *trans_x=11.0378;
1165  *trans_y=12.9732;
1166  *trans_x=10.5357;
1167  *trans_y=10.1393;
1168  *ccd_ang_off=-.160;
1169  uves_msg("case ech 760 REDU 1x1");
1170  break;
1171 
1172  case 780:
1173  *trans_x=9.5521;
1174  *trans_y=11.7901;
1175  *ccd_ang_off=-.131;
1176  uves_msg("case ech 780 REDL 1x1");
1177  break;
1178 
1179  case 800:
1180  *trans_x=9.3306;
1181  *trans_y=17.4402;
1182  *ccd_ang_off=-.131;
1183  uves_msg("case ech 800 REDL 1x1");
1184  break;
1185 
1186  case 820:
1187  *trans_x=9.1435;
1188  *trans_y=14.8772;
1189  *ccd_ang_off=-.131;
1190  uves_msg("case ech 820 REDL 1x1");
1191  break;
1192 
1193  case 840:
1194  *trans_x=8.8927;
1195  *trans_y=11.8143;
1196  *ccd_ang_off=-.131;
1197  uves_msg("case ech 840 REDL 1x1");
1198  break;
1199 
1200 
1201 
1202  case 860:
1203  *trans_x=10.9306;
1204  *trans_y=7.8155;
1205  *ccd_ang_off=-.176;
1206  uves_msg("case ech 860 REDU 1x1");
1207  break;
1208 
1209  case 880:
1210  *trans_x=9.0960;
1211  *trans_y=3.2741;
1212  *ccd_ang_off=-.131;
1213  uves_msg("case ech 880 REDL 1x1");
1214  break;
1215 
1216 
1217  case 900:
1218  *trans_x=8.8903;
1219  *trans_y=8.9738;
1220  *ccd_ang_off=-.131;
1221  uves_msg("case ech 900 REDL 1x1");
1222  break;
1223 
1224 
1225  default:
1226  *ccd_ang_off=-.131;
1227  break;
1228 
1229  }
1230 
1231  }
1232  } else if(binx==2 && biny == 2) {
1233 
1234 
1235 
1236  if(chip==UVES_CHIP_REDL) {
1237  switch(wavec){
1238 
1239 
1240  case 500:
1241  *trans_x=1.6127;
1242  *trans_y=0.3725;
1243  *ccd_ang_off=-.335;
1244  uves_msg("case ech 500 REDL 2x2");
1245  break;
1246 
1247 
1248  case 520:
1249  *trans_x=1.0304;
1250  *trans_y=4.4927;
1251  *ccd_ang_off=-0.338;
1252  uves_msg("case ech 520 REDL 2x2");
1253  break;
1254 
1255 
1256  case 540:
1257  *trans_x=0.9221;
1258  *trans_y=2.6768;
1259  *ccd_ang_off=-.335;
1260  uves_msg("case ech 540 REDL 2x2");
1261  break;
1262 
1263  case 560:
1264  *trans_x=0.7170;
1265  *trans_y=-0.0175;
1266  *ccd_ang_off=-.335;
1267  uves_msg("case ech 560 REDL 2x2");
1268  break;
1269 
1270 
1271  case 564:
1272  *trans_x=0.5659;
1273  *trans_y=1.2151;
1274  *ccd_ang_off=-.319;
1275  uves_msg("case ech 564 REDL 2x2");
1276  break;
1277 
1278  case 580:
1279  *trans_x=0.4406;
1280  *trans_y=0.7901;
1281  *ccd_ang_off=-0.321;
1282  uves_msg("case ech 580 REDL 2x2");
1283  break;
1284 
1285  case 600:
1286  *trans_x=0.2550;
1287  *trans_y=3.7476;
1288  *ccd_ang_off=-0.315;
1289  uves_msg("case ech 600 REDL 2x2");
1290  break;
1291 
1292  case 620:
1293  *trans_x=0.1970;
1294  *trans_y=3.0182;
1295  *ccd_ang_off=-.335;
1296  uves_msg("case ech 620 REDL 2x2");
1297  break;
1298 
1299  case 640:
1300  *trans_x=0.0203;
1301  *trans_y=-0.0638;
1302  *ccd_ang_off=-.335;
1303  uves_msg("case ech 640 REDL 2x2");
1304  break;
1305 
1306  case 660:
1307  *trans_x=5.2122;
1308  *trans_y=1.5986;
1309  *ccd_ang_off=-.335;
1310  uves_msg("case ech 660 REDL 2x2");
1311  break;
1312 
1313  case 680:
1314  *trans_x=5.0355;
1315  *trans_y=-0.1277;
1316  *ccd_ang_off=-.335;
1317  uves_msg("case ech 680 REDL 2x2");
1318  break;
1319 
1320  case 700:
1321  *trans_x=4.8466;
1322  *trans_y=-1.8237;
1323  *ccd_ang_off=-.335;
1324  uves_msg("case ech 700 REDL 2x2");
1325  break;
1326 
1327  case 720:
1328  *trans_x=4.7320;
1329  *trans_y=-2.4860;
1330  *ccd_ang_off=-.335;
1331  uves_msg("case ech 720 REDL 2x2");
1332  break;
1333 
1334  case 740:
1335  *trans_x=4.5968;
1336  *trans_y=-1.1956;
1337  *ccd_ang_off=-.335;
1338  uves_msg("case ech 740 REDL 2x2");
1339  break;
1340 
1341  case 760:
1342  *trans_x=3.7298;
1343  *trans_y=2.0585;
1344  *trans_x=4.5392;
1345  *trans_y=0.4414;
1346  *ccd_ang_off=-.335;
1347  uves_msg("case ech 760 REDL 2x2");
1348  break;
1349 
1350  case 780:
1351  *trans_x=4.4156;
1352  *trans_y=1.2900;
1353  *ccd_ang_off=-.335;
1354  uves_msg("case ech 780 REDL 2x2");
1355  break;
1356 
1357  case 800:
1358  *trans_x=4.2877;
1359  *trans_y=2.2643;
1360  *ccd_ang_off=-.335;
1361  uves_msg("case ech 800 REDL 2x2");
1362  break;
1363 
1364 
1365  case 820:
1366  *trans_x=4.1695;
1367  *trans_y=1.0259;
1368  *ccd_ang_off=-.335;
1369  uves_msg("case ech 820 REDL 2x2");
1370  break;
1371 
1372  case 840:
1373  *trans_x=4.1004;
1374  *trans_y=-0.6081;
1375  *ccd_ang_off=-.335;
1376  uves_msg("case ech 840 REDL 2x2");
1377  break;
1378 
1379  case 860:
1380  *trans_x=3.1362;
1381  *trans_y=-.6278;
1382  *ccd_ang_off=-.350;
1383  uves_msg("case ech 860 REDL 2x2");
1384  break;
1385 
1386  case 880:
1387  *trans_x=3.8903;
1388  *trans_y=-3.1012;
1389  *ccd_ang_off=-.335;
1390  uves_msg("case ech 880 REDL 2x2");
1391  break;
1392 
1393  case 900:
1394  *trans_x=3.7873;
1395  *trans_y=-2.0264;
1396  *ccd_ang_off=-.335;
1397  uves_msg("case ech 900 REDL 2x2");
1398  break;
1399 
1400 
1401 
1402  default:
1403  *ccd_ang_off=-.335;
1404  break;
1405  }
1406  } else {
1407 
1408  switch(wavec){
1409 
1410 
1411  case 500:
1412  *trans_x=1.6644;
1413  *trans_y=2.1540;
1414  *ccd_ang_off=-.131;
1415  uves_msg("case ech 500 REDU 2x2");
1416  break;
1417 
1418 
1419 
1420  case 520:
1421  *trans_x=1.3965;
1422  *trans_y=6.2855;
1423  *ccd_ang_off=-.131;
1424  uves_msg("case ech 520 REDU 2x2");
1425  break;
1426 
1427  case 540:
1428  *trans_x=1.3951;
1429  *trans_y=4.7774;
1430  *ccd_ang_off=-.131;
1431  uves_msg("case ech 540 REDU 2x2");
1432  break;
1433 
1434  case 560:
1435  *trans_x=1.3307;
1436  *trans_y=2.0433;
1437  *ccd_ang_off=-.131;
1438  uves_msg("case ech 560 REDU 2x2");
1439  break;
1440 
1441 
1442  case 564:
1443  *trans_x=1.3329;
1444  *trans_y=2.9888;
1445  *ccd_ang_off=-0.161;
1446  uves_msg("case ech 564 REDU 2x2");
1447  break;
1448 
1449  case 580:
1450  *trans_x=0.9856;
1451  *trans_y=2.5873;
1452  *ccd_ang_off=-.106;
1453  uves_msg("case ech 580 REDU 2x2");
1454  break;
1455 
1456  case 600:
1457  *trans_x=0.9223;
1458  *trans_y=5.5208;
1459  *ccd_ang_off=-.112;
1460  uves_msg("case ech 600 REDU 2x2");
1461  break;
1462 
1463 
1464  case 620:
1465  *trans_x=1.1483;
1466  *trans_y=5.2252;
1467  *ccd_ang_off=-.131;
1468  uves_msg("case ech 620 REDU 2x2");
1469  break;
1470 
1471 
1472 
1473  case 640:
1474  *trans_x=1.0534;
1475  *trans_y=2.1526;
1476  *ccd_ang_off=-.131;
1477  uves_msg("case ech 640 REDU 2x2");
1478  break;
1479 
1480  case 660:
1481  *trans_x=5.8447;
1482  *trans_y=4.8530;
1483  *ccd_ang_off=-.131;
1484  uves_msg("case ech 660 REDU 2x2");
1485  break;
1486 
1487 
1488  case 680:
1489  *trans_x=5.7227;
1490  *trans_y=3.2191;
1491  *ccd_ang_off=-.131;
1492  uves_msg("case ech 680 REDU 2x2");
1493  break;
1494 
1495  case 700:
1496  *trans_x=5.6851;
1497  *trans_y=1.6912;
1498  *ccd_ang_off=-.131;
1499  uves_msg("case ech 700 REDU 2x2");
1500  break;
1501 
1502  case 720:
1503  *trans_x=5.5375;
1504  *trans_y=1.0217;
1505  *ccd_ang_off=-.131;
1506  uves_msg("case ech 720 REDU 2x2");
1507  break;
1508 
1509  case 740:
1510  *trans_x=5.4927;
1511  *trans_y=2.3500;
1512  *ccd_ang_off=-.131;
1513  uves_msg("case ech 740 REDU 2x2");
1514  break;
1515 
1516 
1517 
1518  case 760:
1519  *trans_x=4.8082;
1520  *trans_y=5.3052;
1521  *trans_x=5.6659;
1522  *trans_y=3.9673;
1523  *ccd_ang_off=-.160;
1524  uves_msg("case ech 760 REDU 2x2");
1525  break;
1526 
1527 
1528  case 780:
1529  *trans_x=5.3406;
1530  *trans_y=4.7919;
1531  *ccd_ang_off=-.131;
1532  uves_msg("case ech 780 REDU 2x2");
1533  break;
1534 
1535 
1536  case 800:
1537  *trans_x=5.2926;
1538  *trans_y=5.8133;
1539  *ccd_ang_off=-.131;
1540  uves_msg("case ech 800 REDU 2x2");
1541  break;
1542 
1543  case 820:
1544  *trans_x=5.1947;
1545  *trans_y=4.5974;
1546  *ccd_ang_off=-.131;
1547  uves_msg("case ech 820 REDU 2x2");
1548  break;
1549 
1550 
1551  case 840:
1552  *trans_x=5.1033;
1553  *trans_y=2.9638;
1554  *ccd_ang_off=-.131;
1555  uves_msg("case ech 840 REDU 2x2");
1556  break;
1557 
1558  case 860:
1559  *trans_x=4.5923;
1560  *trans_y=2.6809;
1561  *ccd_ang_off=-.176;
1562  uves_msg("case ech 860 REDU 2x2");
1563  break;
1564 
1565 
1566  case 880:
1567  *trans_x=4.9641;
1568  *trans_y=0.3260;
1569  *ccd_ang_off=-.131;
1570  uves_msg("case ech 880 REDU 2x2");
1571  break;
1572 
1573  case 900:
1574  *trans_x=4.9610;
1575  *trans_y=1.4586;
1576  *ccd_ang_off=-.131;
1577  uves_msg("case ech 900 REDU 2x2");
1578  break;
1579 
1580 
1581  default:
1582  *ccd_ang_off=-.131;
1583  break;
1584 
1585  }
1586 
1587  }
1588 
1589  } else if(binx==2 && biny == 1) {
1590 
1591 
1592 
1593  if(chip==UVES_CHIP_REDL) {
1594 
1595  switch(wavec){
1596  case 520:
1597  *trans_x=-0.5469;
1598  *trans_y=3.1225;
1599  *ccd_ang_off=-.400;
1600  uves_msg("case ech 520 REDL 2x1");
1601  break;
1602 
1603  case 564:
1604  *trans_x=-1.3918;
1605  *trans_y=-2.9967;
1606 
1607  *ccd_ang_off=-.400;
1608  uves_msg("case ech 564 REDL 2x1");
1609  break;
1610 
1611  case 580:
1612  *trans_x=-1.4333;
1613  *trans_y=-4.3223;
1614 
1615  *ccd_ang_off=-.400;
1616  uves_msg("case ech 580 REDL 2x1");
1617  break;
1618 
1619  case 600:
1620  *trans_x=-1.6725;
1621  *trans_y=1.5057;
1622 
1623 
1624  *ccd_ang_off=-.400;
1625  uves_msg("case ech 600 REDL 2x1");
1626  break;
1627 
1628 
1629  case 760:
1630  *trans_x=1.5073;
1631  *trans_y=-1.6050;
1632  *ccd_ang_off=-.400;
1633  uves_msg("case ech 760 REDL 2x1");
1634  break;
1635 
1636  case 860:
1637  *trans_x=0.9818;
1638  *trans_y=-6.9373;
1639  *ccd_ang_off=-.400;
1640  uves_msg("case ech 860 REDL 2x1");
1641  break;
1642 
1643  default:
1644  *ccd_ang_off=-.400;
1645  break;
1646 
1647  }
1648  } else {
1649  switch(wavec){
1650  case 520:
1651  *trans_x=-1.0242;
1652  *trans_y=11.4442;
1653  *ccd_ang_off=-.100;
1654  uves_msg("case ech 520 REDU 2x1");
1655  break;
1656 
1657  case 564:
1658  *trans_x=-1.2162;
1659  *trans_y=5.7253;
1660  *ccd_ang_off=-.100;
1661  uves_msg("case ech 564 REDU 2x1");
1662  break;
1663 
1664  case 580:
1665  *trans_x=-1.0591;
1666  *trans_y=4.5918;
1667  *ccd_ang_off=-.100;
1668  uves_msg("case ech 580 REDU 2x1");
1669  break;
1670 
1671  case 600:
1672  *trans_x=-1.1089;
1673  *trans_y=10.0907;
1674  *ccd_ang_off=-.100;
1675  uves_msg("case ech 600 REDU 2x1");
1676  break;
1677 
1678  case 760:
1679  *trans_x=1.9719;
1680  *trans_y=9.6496;
1681 
1682  *ccd_ang_off=-.100;
1683  uves_msg("case ech 760 REDU 2x1");
1684  break;
1685 
1686  case 860:
1687  *trans_x=1.9402;
1688  *trans_y=4.2234;
1689  *ccd_ang_off=-.100;
1690  uves_msg("case ech 860 REDU 2x1");
1691  break;
1692 
1693  default:
1694  *ccd_ang_off=-.100;
1695  break;
1696  }
1697  }
1698  } else if(binx==3 && biny == 2) {
1699 
1700 
1701 
1702  if(chip==UVES_CHIP_REDL) {
1703  switch(wavec){
1704  case 520:
1705  *trans_x=2.0359;
1706  *trans_y=2.9332;
1707  *ccd_ang_off=-.190;
1708  uves_msg("case ech 520 REDL 3x2");
1709  break;
1710 
1711  case 564:
1712  *trans_x=1.5143;
1713  *trans_y=-0.2408;
1714  *ccd_ang_off=-.190;
1715  uves_msg("case ech 564 REDL 3x2");
1716  break;
1717 
1718  case 580:
1719  *trans_x=1.2014;
1720  *trans_y=-0.9518;
1721  *ccd_ang_off=-.190;
1722  uves_msg("case ech 580 REDL 3x2");
1723  break;
1724 
1725  case 600:
1726  *trans_x=1.2753;
1727  *trans_y=1.8916;
1728  *ccd_ang_off=-.190;
1729  uves_msg("case ech 600 REDL 3x2");
1730  break;
1731 
1732 
1733  case 760:
1734  *trans_x=3.5390;
1735  *trans_y=0.3579;
1736  *ccd_ang_off=-.190;
1737  uves_msg("case ech 760 REDL 3x2");
1738  break;
1739 
1740  case 860:
1741  *trans_x=3.0845;
1742  *trans_y=-2.2232;
1743  *ccd_ang_off=-.190;
1744  uves_msg("case ech 860 REDL 3x2");
1745  break;
1746 
1747  default:
1748  *ccd_ang_off=-.190;
1749  break;
1750 
1751  }
1752  } else {
1753  switch(wavec){
1754 
1755  case 520:
1756  *trans_x=0.4483;
1757  *trans_y=4.5161;
1758  *ccd_ang_off=-.100;
1759  uves_msg("case ech 520 REDU 3x2");
1760  break;
1761 
1762  case 564:
1763  *trans_x=0.0711;
1764  *trans_y=1.5479;
1765  *ccd_ang_off=-.100;
1766  uves_msg("case ech 564 REDU 3x2");
1767  break;
1768 
1769  case 580:
1770  *trans_x=0.2785;
1771  *trans_y=0.9470;
1772  *ccd_ang_off=-.100;
1773  uves_msg("case ech 580 REDU 3x2");
1774  break;
1775 
1776  case 600:
1777  *trans_x=0.1448;
1778  *trans_y=3.7903;
1779  *ccd_ang_off=-.100;
1780  uves_msg("case ech 600 REDU 3x2");
1781  break;
1782 
1783  case 760:
1784  *trans_x=2.1704;
1785  *trans_y=3.6996;
1786  *ccd_ang_off=-.100;
1787  uves_msg("case ech 760 REDU 3x2");
1788  break;
1789 
1790  case 860:
1791  *trans_x=1.9817;
1792  *trans_y=1.0266;
1793  *ccd_ang_off=-.100;
1794  uves_msg("case ech 860 REDU 3x2");
1795  break;
1796 
1797  default:
1798  *ccd_ang_off=-.100;
1799  break;
1800 
1801  }
1802 
1803  }
1804 
1805  } else {
1806 
1807  uves_msg_warning("New CCD, frame is unbinned.");
1808  uves_msg_warning("You may have to compute proper CCD rotation angle and X, Y offsets");
1809 
1810 
1811  }
1812 
1813  uves_msg("NEW CCD Physical Model shifts trans=%f,%f rot=%f,%f,%f",
1814  *trans_x,*trans_y,*ech_ang_off,*cd_ang_off,*ccd_ang_off);
1815  return 0;
1816 }
1817 
1818 
1819 /*---------------------------------------------------------------------------*/
1831 /*---------------------------------------------------------------------------*/
1832 
1833 
1834 static int
1835 flames_get_physmod_offset(const int plate_no,
1836  const int wavec,
1837  enum uves_chip chip,
1838  double* trans_x,
1839  double* trans_y,
1840  double* ech_ang_off,
1841  double* cd_ang_off,
1842  double* ccd_ang_off)
1843 {
1844 
1845  //For the moment rot angle default is assumed always 0,0,0
1846  *ech_ang_off=0;
1847  *cd_ang_off=0;
1848  *ccd_ang_off=0;
1849  uves_msg_warning("New CCD, frame is unbinned, FIBER mode");;
1850  uves_msg_warning("You may have to compute proper CCD rotation angle and X, Y offsets");
1851 
1852  uves_msg("plate_no=%d,wavec=%d,chip=%d",plate_no,wavec,chip);
1853  switch(plate_no){
1854 
1855  case 1:
1856 
1857  if(chip==UVES_CHIP_REDL) {
1858  switch(wavec){
1859 
1860  case 520:
1861  *trans_x=4.5211;
1862  *trans_y=0.2826;
1863  *ccd_ang_off=-0.338;
1864  uves_msg("case FIBRE 520 REDL plt1");
1865  break;
1866 
1867  case 580:
1868  *trans_x=6.0388;
1869  *trans_y=-7.4226;
1870  *ccd_ang_off=-0.321;
1871  uves_msg("case FIBRE 580 REDL plt1");
1872  break;
1873 
1874  case 860:
1875  *trans_x=4.1211;
1876  *trans_y=-2.3926;
1877  *ccd_ang_off=-.350;
1878  uves_msg("case FIBRE 860 REDL plt1");
1879  break;
1880 
1881  }
1882  } else {
1883 
1884  switch(wavec){
1885 
1886  case 520:
1887  *trans_x=2.1001;
1888  *trans_y=8.0998;
1889  *ccd_ang_off=-0.131;
1890  uves_msg("case FIBRE 520 REDU plt1");
1891  break;
1892 
1893  case 580:
1894  *trans_x=2.1388;
1895  *trans_y=0.1226;
1896  *ccd_ang_off=-.106;
1897  uves_msg("case FIBRE 580 REDU plt1");
1898  break;
1899 
1900  case 860:
1901  *trans_x=3.7411;
1902  *trans_y=5.1006;
1903  *ccd_ang_off=-.176;
1904  uves_msg("case FIBRE 860 REDU plt1");
1905  break;
1906 
1907  }
1908  }
1909  break;
1910 
1911  case 2:
1912 
1913  if(chip==UVES_CHIP_REDL) {
1914  switch(wavec){
1915 
1916  case 520:
1917  *trans_x=4.0311;
1918  *trans_y=3.2253;
1919  *ccd_ang_off=-0.338;
1920  uves_msg("case FIBER 520 REDL plt2");
1921  break;
1922 
1923  case 580:
1924  *trans_x=4.1158;
1925  *trans_y=-7.2539;
1926  *ccd_ang_off=-.321;
1927  uves_msg("case FIBER 580 REDL plt2");
1928  break;
1929 
1930  case 860:
1931  *trans_x=1.5000;
1932  *trans_y=-2.4624;
1933  *ccd_ang_off=-.343;
1934  uves_msg("case FIBER 860 REDL plt2");
1935  break;
1936 
1937  }
1938  } else {
1939 
1940  switch(wavec){
1941 
1942  case 520:
1943  *trans_x=2.3911;
1944  *trans_y=11.9726;
1945  *ccd_ang_off=-0.131;
1946  uves_msg("case FIBER 520 REDU plt2");
1947  break;
1948 
1949  case 580:
1950  *trans_x=1.5658;
1951  *trans_y=0.6239;
1952  *ccd_ang_off=-.106;
1953  uves_msg("case FIBER 580 REDU plt2");
1954  break;
1955 
1956  case 860:
1957  *trans_x=3.1174;
1958  *trans_y=4.7984;
1959  *ccd_ang_off=-.176;
1960  uves_msg("case FIBER 860 REDU plt2");
1961  break;
1962 
1963  }
1964  }
1965  break;
1966 
1967  default:
1968  *trans_x=0;
1969  *trans_y=0;
1970 
1971  }
1972 
1973 
1974  uves_msg("NEW CCD Physical Model shifts trans=%f,%f rot=%f,%f,%f",
1975  *trans_x,*trans_y,*ech_ang_off,*cd_ang_off,*ccd_ang_off);
1976  return 0;
1977 }
1978 
1979 
1980 
1981 
1982 
1983