uves_physmod_create_table.c

00001 /*                                                                           *
00002  *   This file is part of the ESO UVES Pipeline                              *
00003  *   Copyright (C) 2004,2005 European Southern Observatory                   *
00004  *                                                                           *
00005  *   This library is free software; you can redistribute it and/or modify    *
00006  *   it under the terms of the GNU General Public License as published by    *
00007  *   the Free Software Foundation; either version 2 of the License, or       *
00008  *   (at your option) any later version.                                     *
00009  *                                                                           *
00010  *   This program is distributed in the hope that it will be useful,         *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
00013  *   GNU General Public License for more details.                            *
00014  *                                                                           *
00015  *   You should have received a copy of the GNU General Public License       *
00016  *   along with this program; if not, write to the Free Software             *
00017  *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA    *
00018  *                                                                           */
00019 
00020 /*
00021  * $Author: amodigli $
00022  * $Date: 2010/09/24 09:32:07 $
00023  * $Revision: 1.37 $
00024  * $Name: uves-4_9_1 $
00025  */
00026 
00027 /*---------------------------------------------------------------------------*/
00031 /*---------------------------------------------------------------------------*/
00034 #ifdef HAVE_CONFIG_H
00035 #  include <config.h>
00036 #endif
00037 /*----------------------------------------------------------------------------
00038                                 Includes
00039  ----------------------------------------------------------------------------*/
00040 #include <uves_physmod_create_table.h>
00041 
00042 #include <uves_physmod_utils.h>
00043 #include <uves_utils_wrappers.h>
00044 #include <uves_pfits.h>
00045 #include <uves_msg.h>
00046 #include <uves_error.h>
00047 #include <string.h>
00048 /*-----------------------------------------------------------------------------
00049                                 Defines
00050  ----------------------------------------------------------------------------*/
00051 /*-----------------------------------------------------------------------------
00052                             Functions prototypes
00053  ----------------------------------------------------------------------------*/
00054 
00055 static int
00056 flames_get_trans(const int plt_no,
00057                  enum uves_chip chip, 
00058                  const double wlen, 
00059                  double * TX,
00060                  double * TY);
00061 
00062 static int
00063 flames_get_physmod_offset(const int plate_no,
00064                          const int wavec,
00065                          enum uves_chip chip,
00066              double* physmod_shift_x,
00067                          double* physmod_shift_y,
00068              double* rot_1,
00069                          double* rot_2,
00070                          double* rot_3);
00071 
00072 
00073 static int
00074 uves_get_physmod_offset(const int wavec,
00075                         enum uves_chip chip,
00076               const int binx,
00077               const int biny,
00078                          double* trans_x,
00079                          double* trans_y,
00080                          double* rot_1,
00081                          double* rot_2,
00082             double* rot_3);
00083 
00084 
00085 
00086 
00087 /*-----------------------------------------------------------------------------
00088                             Static variables
00089  ----------------------------------------------------------------------------*/
00090 
00091 /*-----------------------------------------------------------------------------
00092                             Functions code
00093  ----------------------------------------------------------------------------*/
00094 
00095 /*---------------------------------------------------------------------------*/
00118 /*---------------------------------------------------------------------------*/
00119 
00120 
00121 
00122 
00123 int 
00124 uves_physmod_create_table(const uves_propertylist *raw_header, 
00125                           enum uves_chip chip, 
00126               bool flames,
00127               const char *recipe_id,
00128                           const cpl_parameterlist* parameters, 
00129                           cpl_table* line_refer,
00130                           const double physmod_shift_x,
00131                           const double physmod_shift_y,
00132                           cpl_table** mod_tbl,
00133                           cpl_table** fsr_tbl)
00134 
00135 {
00136 
00137   /* General */
00138   int      MBOX_X=0;
00139   int      MBOX_Y=0;
00140   double   TRANS_X=0;
00141   double   TRANS_Y=0;
00142 
00143   double      ECH_ANG_OFF=0;
00144   double      CD_ANG_OFF=0;
00145   double      CCD_ANG_OFF=0;
00146 
00147 
00148   int bin_x=0;
00149   int bin_y=0;
00150 
00151 
00152   int      CMP_REG_SW=0;
00153 
00154   double binx=0;
00155   double biny=0;
00156 
00157   double pressure=0;
00158   double temp_cam=0;
00159   double slit_width=0;
00160   double slit_length=0;
00161   double humidity=0;
00162 
00163 
00164   double wcent=0;
00165   double xtrans=0;
00166   double ytrans=0;
00167   double ccd_rot[2];
00168   double offset_x[6];
00169   double offset_y[6];
00170 
00171   const char*   cd_id;
00172   int     CDID=0;
00173   int status=0;
00174 
00175 
00176   int aRowNumber=0;
00177   int xpix=0;
00178   int ypix=0;
00179   int i=0;
00180   int mm=0;
00181   double xmod=0;
00182   double ymod=0;
00183   double blaze=0;
00184   double binsize=0;
00185   double pixscale=0;
00186   double pixscalCD=0;
00187   double linelenpx=0;
00188   double linewidth=0;
00189   double linewidpx=0;
00190   double resol=0;
00191   double xreg=0;
00192   double yreg=0;
00193   double fsr_min=0;
00194   double fsr_max=0;
00195   double xfsr_min=0;
00196   double xfsr_max=0;
00197   double yfsr_min=0;
00198   double yfsr_max=0;
00199   int m_min=0;
00200   int m_max=0;
00201   double lmin=0;
00202   double lmax=0;
00203   double dxpix=0;
00204   double dypix=0;
00205   double dblwav=0;
00206   int imod=0;
00207   double dl=0;
00208   int mmin=0;
00209   int mmax=0;
00210   int ncol=0;
00211   int order=0;
00212   double xr=0;
00213   double yr=0;
00214   double lcent=0;
00215 
00216   double mbox_x=0;
00217   double mbox_y=0;
00218 
00219   /* variables which were globals in physmodel */
00220   double uves_beta_ech=0;
00221   double uves_beta_cd=0 ;
00222   double uves_physmod_rcd=0;
00223   double uves_physmod_rech=0;
00224   double uves_physmod_x_off=0;
00225   double uves_physmod_y_off=0;
00226   double x=0;
00227   double y=0;
00228   double fc=0;
00229   double l=0;
00230   int m=0;
00231   int plate_no=0;
00232   double ech_ang_off=0;
00233   double cd_ang_off=0;
00234   double ccd_ang_off=0;
00235   double physmod_off_x=0;
00236   double physmod_off_y=0;
00237   int wavec=0;
00238  
00239  
00240   
00241   enum uves_arm_ident {UVES_ARM_UNDEF,UVES_ARM_BLUE,UVES_ARM_RED};
00242   enum uves_arm_ident uves_arm_ident = UVES_ARM_UNDEF;
00243   int upper;
00244 
00245   const char* ccd_id="";
00246   const char* dpr_tech="";
00247   /* initialize the configuration */
00248 
00249 
00250     /* Read recipe parameters */
00251   {
00252     check( uves_get_parameter(parameters, NULL, recipe_id, 
00253            "mbox_x", CPL_TYPE_INT, &MBOX_X )  , 
00254        "Could not read parameter");
00255 
00256     check( uves_get_parameter(parameters, NULL, recipe_id, 
00257            "mbox_y", CPL_TYPE_INT, &MBOX_Y )  , 
00258        "Could not read parameter");
00259 
00260     check( uves_get_parameter(parameters, NULL, recipe_id, 
00261            "trans_x", CPL_TYPE_DOUBLE, &TRANS_X )  , 
00262        "Could not read parameter");
00263 
00264     check( uves_get_parameter(parameters, NULL, recipe_id, 
00265            "trans_y", CPL_TYPE_DOUBLE, &TRANS_Y )  ,
00266        "Could not read parameter");
00267     xtrans=TRANS_X;
00268     ytrans=TRANS_Y;
00269 
00270     /*
00271 AMo 02/04/2004
00272 We noticed that the physical model has in some way shifted on MIT, thus we apply corrections
00273     */
00274 
00275 if ((xtrans == 0.) && (ytrans == 0.)) {
00276   /*
00277    If the user has not set its own defaults which we assume as the right ones
00278    In case of MIT chip we apply a shift
00279   */
00280      if (chip == UVES_CHIP_REDU) {
00281        //ytrans = 6.7;
00282      }
00283 }
00284 
00285  uves_msg_debug("xtrans=%f ytrans=%f",xtrans,ytrans);
00286     check( uves_get_parameter(parameters, NULL, recipe_id, 
00287            "ech_angle_off", CPL_TYPE_DOUBLE, &ECH_ANG_OFF )  , 
00288        "Could not read parameter");
00289 
00290     check( uves_get_parameter(parameters, NULL, recipe_id, 
00291            "cd_angle_off", CPL_TYPE_DOUBLE, &CD_ANG_OFF )  , 
00292        "Could not read parameter");
00293 
00294     check( uves_get_parameter(parameters, NULL, recipe_id, 
00295            "ccd_rot_angle_off", CPL_TYPE_DOUBLE, &CCD_ANG_OFF )  , 
00296        "Could not read parameter");
00297 
00298     check( uves_get_parameter(parameters, NULL, recipe_id, 
00299           "compute_regression_sw", CPL_TYPE_BOOL, &CMP_REG_SW )  , 
00300           "Could not read parameter");
00301 
00302 
00303 
00304     /* check parameters */
00305   }
00306     
00307   /* get instrument configuration setting keywords */
00308   check (ccd_id = uves_pfits_get_chipid(raw_header,chip), 
00309      "Could not read CCD ID from input header");
00310   check (dpr_tech = uves_pfits_get_dpr_tech(raw_header), 
00311      "Could not read DPR TECH from input header");
00312   uves_msg("DPR TECH=%s<",dpr_tech);
00313   if(strstr(dpr_tech,"MOS")!=NULL) {
00314       check_nomsg( plate_no = uves_flames_pfits_get_plateid(raw_header) );
00315       uves_msg("PLATE NO=%d",plate_no);
00316   }
00317 
00318   if(strcmp(ccd_id,"CCD-44b") == 0) {
00319     uves_msg("New Spectral Format");
00320     offset_x[0]=1355.0;
00321     offset_x[1]=1350.0;
00322     offset_x[2]=1852.0;
00323     offset_x[3]=1835.0;
00324     offset_x[4]=1852.0;
00325     offset_x[5]=1834.0;
00326 
00327     offset_y[0]=1030.0;
00328     offset_y[1]=1023.0;
00329     offset_y[2]=2098.0;
00330     offset_y[3]=2104.0;
00331     offset_y[4]=-52.0;
00332     offset_y[5]=-49.0;
00333     ccd_rot[0]=0.3;
00334     ccd_rot[1]=-0.10;
00335 
00336   } else {
00337     uves_msg("Old Spectral Format");
00338 
00339     offset_x[0]=1391.0;
00340     offset_x[1]=1385.0;
00341     offset_x[2]=1852.0;
00342     offset_x[3]=1835.0;
00343     offset_x[4]=1852.0;
00344     offset_x[5]=1834.0;
00345 
00346     offset_y[0]=1030.0;
00347     offset_y[1]=1025.0;
00348     offset_y[2]=2098.0;
00349     offset_y[3]=2104.0;
00350     offset_y[4]=-52.0;
00351     offset_y[5]=-49.0;
00352 
00353     ccd_rot[0]=0.3;
00354     ccd_rot[1]=-0.55;
00355     
00356   }
00357 
00358 
00359   check (biny = uves_pfits_get_binx(raw_header),
00360      "Could not read x binning factor from input header");
00361 
00362   check (binx = uves_pfits_get_biny(raw_header), 
00363      "Could not read x binning factor from input header");
00364 
00365   check (pressure = uves_pfits_get_pressure(raw_header), 
00366      "Could not read pressure from input header");
00367 
00368   /*
00369     check (humidity = uves_pfits_get_humidity(raw_header), 
00370            "Could not read humidity from input header");
00371   */
00372   humidity=3.;
00373 
00374 
00375 /* New code */
00376   check (slit_width = uves_pfits_get_slitwidth(raw_header, chip), 
00377      "Could not read slit width input header");
00378   
00379   check (slit_length = uves_pfits_get_slitlength(raw_header, chip), 
00380      "Could not read slit length input header");
00381   
00382   check (wcent = uves_pfits_get_gratwlen(raw_header, chip), 
00383      "Could not read central wavelength setting from input header");
00384   
00385   check (cd_id =  uves_pfits_get_gratid(raw_header, chip), 
00386      "Could not read central CD ID setting from input header");
00387 
00388   check (temp_cam = uves_pfits_get_tempcam(raw_header,chip), 
00389      "Could not read camera's temperature from input header");
00390 
00391   if (chip == UVES_CHIP_BLUE)
00392       {
00393       uves_arm_id='b';
00394       uves_arm_ident=UVES_ARM_BLUE;
00395 
00396       }
00397   else
00398       {
00399       uves_arm_id='r';
00400       uves_arm_ident=UVES_ARM_RED;
00401       }
00402   upper = (chip == UVES_CHIP_REDU);
00403 
00404 
00405 
00406 
00407          if(strstr(cd_id,"CD#1") != NULL) {
00408        CDID=1;
00409   } else if(strstr(cd_id,"CD#2") != NULL) {
00410        CDID=2;
00411   } else if(strstr(cd_id,"CD#3") != NULL) {
00412        CDID=3;
00413   } else if(strstr(cd_id,"CD#4") != NULL) {
00414        CDID=4;
00415   } else {
00416            CDID=0;
00417   }
00418     
00419      mbox_x=MBOX_X/binx;
00420      mbox_y=MBOX_Y/biny;
00421      uves_msg("UVES configuration:");
00422          uves_msg("Optical path: %s (%s)",
00423                             UVES_ARM(chip),UVES_ARMID(chip));
00424        
00425          uves_msg("Detector: %s Binning: %1.1f, %1.1f pix/bin",
00426                       UVES_DETECTOR(chip),binx,biny);
00427          uves_msg("Cross disperser ID, number: %s %d",cd_id,CDID);
00428          uves_msg("Central wavelength: %4.1f nm",wcent);
00429          uves_msg("Slit width: %3.1f (arcsecs)",slit_width);
00430          uves_msg("Slit length: %3.1f (arcsecs)",slit_length);
00431      uves_msg("Temperature: %3.1f C",temp_cam);
00432      uves_msg("Air pressure: %4.1f mmHg/cm^2",pressure);
00433      uves_msg("Humidity: %2.1f %%",humidity);
00434 
00435   uves_msg_debug("chip    =%s", uves_chip_tostring_upper(chip));
00436 
00437 
00438   /* read input frame (line table) */
00439   ncol=cpl_table_get_ncol(line_refer);
00440  
00441   aRowNumber = cpl_table_get_nrow(line_refer);
00442   
00443   uves_msg_debug("Opened table %s ncol=%d nrow=%d","line_ref_table" ,ncol,aRowNumber);
00444 
00445   uves_air_config(pressure/1.33322, temp_cam, humidity);
00446   uves_msg("Air Index = %g",uves_air_index(wcent));
00447   if(strstr(dpr_tech,"MOS")!=NULL) {
00448     uves_msg("uves chip=%s ",uves_chip_tostring_upper(chip));
00449      flames_get_trans(plate_no,chip,wcent,&TRANS_X,&TRANS_Y);
00450      //xtrans=TRANS_X+physmod_shift_x;
00451      //ytrans=TRANS_Y+physmod_shift_y;
00452 
00453      xtrans=physmod_shift_x;
00454      ytrans=physmod_shift_y;
00455   }
00456 
00457 
00458   /* check if old or new CCD, and eventually apply shifts */
00459   check_nomsg(bin_x=uves_pfits_get_binx(raw_header));
00460   check_nomsg(bin_y=uves_pfits_get_biny(raw_header));
00461   uves_msg("CHECK: xtrans=%f ytrans=%f,ccdrot[0]=%f,ccdrot[1]=%f",
00462            xtrans,ytrans,ccd_rot[0],ccd_rot[1]);
00463   
00464   if(uves_ccd_is_new(raw_header)) {
00465 
00466     if(chip != UVES_CHIP_BLUE) {
00467       check_nomsg(wavec=(int)uves_pfits_get_gratwlen(raw_header,chip));
00468       if(flames) {
00469     ck0_nomsg(flames_get_physmod_offset(plate_no,wavec,chip,
00470                         &physmod_off_x,
00471                         &physmod_off_y,
00472                         &ech_ang_off,
00473                         &cd_ang_off,
00474                         &ccd_ang_off));
00475       } else {
00476     ck0_nomsg(uves_get_physmod_offset(wavec,chip,binx,biny,
00477                       &physmod_off_x,
00478                       &physmod_off_y,
00479                       &ech_ang_off,
00480                       &cd_ang_off,
00481                       &ccd_ang_off));
00482       }
00483       ECH_ANG_OFF  +=ech_ang_off;
00484       CD_ANG_OFF   +=cd_ang_off;
00485       CCD_ANG_OFF  +=ccd_ang_off;
00486       xtrans+=physmod_off_x;
00487       ytrans+=physmod_off_y;
00488 
00489     }
00490   }
00491   
00492   uves_msg("CHECK: xtrans=%f ytrans=%f,ccdrot[0]=%f,ccdrot[1]=%f",
00493            xtrans,ytrans,ccd_rot[0],ccd_rot[1]);
00494   uves_msg("CHECK: ECH_ANG_OFF=%f CD_ANG_OFF=%f,CCD_ANG_OFF=%f",
00495            ECH_ANG_OFF,CD_ANG_OFF,CCD_ANG_OFF);
00496  
00497 
00498 
00499 
00500   uves_msg("Shift in x = %6.3f pix, shift in y = %6.3f pix",TRANS_X,TRANS_Y);
00501   uves_msg("External Shift in x = %6.3f pix, shift in y = %6.3f pix",
00502        physmod_shift_x,physmod_shift_y);
00503   uves_msg("Offset angle of echelle, CD, CCD rotation (deg): "
00504        "%4.3f, %4.3f, %4.3f",ECH_ANG_OFF,CD_ANG_OFF,CCD_ANG_OFF);
00505   
00506   uves_set_ccd_rot(ccd_rot,CCD_ANG_OFF, CCD_ANG_OFF);
00507   uves_physmod_set_incidence(ECH_ANG_OFF, ECH_ANG_OFF, CD_ANG_OFF, CD_ANG_OFF);
00508   uves_msg_debug("ccdbin=%f,%f",binx,biny);
00509   uves_msg_debug("offset x=%f %f %f %f %f %f",
00510    offset_x[0],offset_x[1],offset_x[2],offset_x[3],offset_x[4],offset_x[5]);
00511 
00512   uves_msg_debug("offset y=%f %f %f %f %f %f",
00513    offset_y[0],offset_y[1],offset_y[2],offset_y[3],offset_y[4],offset_y[5]);
00514 
00515   uves_msg("Central wavelength: %4.2f nm",wcent);
00516   uves_msg_debug("chip    =%s", uves_chip_tostring_upper(chip));
00517   /* uves_msg("uves_arm=%c",ArmId); */      /* b/r */
00518   uves_msg_debug("uves_arm_ident=%d",uves_arm_ident);       /* b/r */
00519 
00520   /* uves_msg("chipid=%s",CHIP[0]); */ /* upper/lower chip */
00521   /* uves_msg("cdid=%s",CDID); */       /* 1-4 for CD#1-4 */
00522   /* uves_cfg_indx = uves_config(ArmId[0],CHIP[0],CDID,wcent,binx,biny); */
00523   uves_cfg_indx = uves_config_cpl_new(uves_arm_ident,upper,CDID,wcent,binx,biny);
00524   uves_msg_debug("uves_cfg_indx=%d",uves_cfg_indx);
00525 
00526   uves_physmod_set_offset(offset_x[uves_cfg_indx-1],offset_y[uves_cfg_indx-1],
00527                           uves_physmod_x_off,uves_physmod_y_off);
00528 
00529 /* =========================================================================
00530  * Computation of the true pixel-scale along echelle dispersion 
00531  * scale = (K*FocalRatioNasmyth*PixelSize*ApertureCamera*1e-3)/FocalNasmyth
00532  * K = 206265 : conversion radian to arcsec (1 radian = 206265 arcsec)
00533  * scale = (206265.0*15.0*0.015*200*1e-3*CCDBIN[0])/120000; 
00534  * =========================================================================
00535  */
00536 
00537 /* Creation of modtbl */
00538   
00539   *mod_tbl= cpl_table_new(3*aRowNumber);
00540  
00541   uves_msg("table created: %s ncol=%d, nrow=%d","mod_tbl",10,3*aRowNumber);  
00542   cpl_table_new_column(*mod_tbl,"WAVE",CPL_TYPE_DOUBLE);
00543   cpl_table_new_column(*mod_tbl,"ORDER",CPL_TYPE_INT);
00544   cpl_table_new_column(*mod_tbl,"XMOD",CPL_TYPE_DOUBLE);
00545   cpl_table_new_column(*mod_tbl,"YMOD",CPL_TYPE_DOUBLE);
00546   cpl_table_new_column(*mod_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
00547   cpl_table_new_column(*mod_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
00548   cpl_table_new_column(*mod_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
00549   cpl_table_new_column(*mod_tbl,"RESOL",CPL_TYPE_DOUBLE);
00550   cpl_table_new_column(*mod_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
00551   cpl_table_new_column(*mod_tbl,"BLAZE",CPL_TYPE_DOUBLE);
00552   
00553   uves_ccd_size(&xpix,&ypix); 
00554   uves_msg_debug("CCDsize: %d %d",xpix,ypix);
00555 
00556   
00557   for (i=0; i<aRowNumber; i++) {
00558     
00559   //for (i=450; i<451; i++) {
00560     
00561   
00562    
00563   
00564     /* why we do access line i+1? */
00565       dblwav=cpl_table_get_double(line_refer, "Wave",i,&status);
00566       uves_msg_debug(" i: %d Line: %f",i,dblwav); 
00567      
00568       dblwav /= 10.0;     /* (10.0: conversion factor from nm to A)*/
00569       order = uves_physmod_find_order(dblwav);
00570       uves_msg_debug("order=%d",order); 
00571       
00572       order++;  
00573 
00574 /* Computes the positions xmod and ymod for the order-1, order, order+1 */
00575 /* and adds a row to the modtbl only if the position are insight the CCD */
00576  
00577       for (mm=0; mm<3; mm++){
00578         /*uves_physmod_xy_model(dblwav, order, &xmod, &ymod);
00579         blaze = blz; */
00580         /* The next line fails */
00581         uves_physmod_lambda_order2beta(dblwav, order, &uves_beta_ech, &uves_beta_cd, &fc);
00582     
00583         uves_msg_debug("uves_beta_ech %f, uves_beta_cd %f, fc %f",
00584                         uves_beta_ech,    uves_beta_cd,    fc);
00585         
00586         uves_beta2xy(uves_beta_cd, uves_beta_ech, fc, &xmod, &ymod);
00587         uves_msg_debug("xmod=%f ymod=%f",xmod,ymod);
00588     /* Computes the anamorphic magnification and the blaze function  */    
00589         uves_physmod_photo_beta(dblwav, uves_beta_ech, uves_beta_cd, 
00590                       &uves_physmod_rech, &uves_physmod_rcd, &blaze);
00591     
00592         uves_msg_debug("uves_physmod_rech %f, uves_physmod_rcd %f, blaze %f",
00593                         uves_physmod_rech,    uves_physmod_rcd,    blaze); 
00594     
00595 /* Translation */
00596         
00597         uves_msg_debug("Before translation: xmod %f, ymod %f",xmod, ymod); 
00598         
00599         xmod += xtrans;
00600         ymod += ytrans;
00601         uves_msg_debug("xtrans=%f ytrans=%f xmod=%f ymod=%f",
00602                         xtrans,   ytrans,   xmod,   ymod);
00603     
00604         uves_msg_debug("After translation: xmod %f, ymod %f",xmod, ymod); 
00605     uves_msg_debug("xpix=%d ypix=%d",xpix,ypix);
00606     
00607     uves_msg_debug("binx=%f biny=%f",binx,biny); 
00608     
00609         if (xmod > 0 && xmod < xpix && ymod > 0 && ymod < ypix) {     
00610 
00611 /* Computes the width (in pixel and A) and resolution lines */
00612       uves_physmod_pixscl(dblwav, order, uves_physmod_rech, uves_physmod_rcd, 
00613                  binx, biny, fc, slit_width, slit_length, 
00614          &binsize, &pixscale, &pixscalCD, &linewidpx, 
00615                  &linelenpx, &linewidth, &resol);
00616       
00617           uves_msg_debug("binsize %f, pixscale %f, pixscalCD %f",
00618           binsize,pixscale,pixscalCD);
00619           uves_msg_debug("linewidpx %f, linelenpx %f, linewidth %f, resol %f",
00620           linewidpx,linelenpx,linewidth,resol);
00621       
00622 /* Compute/regress */
00623       if (CMP_REG_SW) {
00624         uves_physmod_xy_regres(xmod,ymod,&xreg,&yreg);
00625       } else {
00626         xreg = xmod;
00627         yreg = ymod;
00628       }
00629 
00630      
00631           uves_msg_debug("Fill tab: i=%d wave=%f order=%d xmod=%f ymod=%f",
00632              i,dblwav,order,xmod,ymod);
00633 
00634           uves_msg_debug("Fill tab: bin_sixe=%f xreg=%f yreg=%f ",
00635              binsize,xreg,yreg);
00636 
00637           uves_msg_debug("Fill tab: linewidpx=%f linewidth=%f resol=%f linelenpx=%f blaze=%f",
00638 linewidpx,linewidth,resol,linelenpx,blaze);
00639       
00640       
00641       cpl_table_set_double(*mod_tbl, "WAVE"     ,imod, dblwav);
00642       cpl_table_set_int   (*mod_tbl, "ORDER"    ,imod, order);
00643       cpl_table_set_double(*mod_tbl, "XMOD"     ,imod, xreg);
00644       cpl_table_set_double(*mod_tbl, "YMOD"     ,imod, yreg);
00645       cpl_table_set_double(*mod_tbl, "BIN_SIZE" ,imod, binsize);
00646       cpl_table_set_double(*mod_tbl, "LINEWIDPX",imod, linewidpx);
00647       cpl_table_set_double(*mod_tbl, "LINEWIDTH",imod, linewidth);
00648       cpl_table_set_double(*mod_tbl, "RESOL"    ,imod, resol);
00649       cpl_table_set_double(*mod_tbl, "LINELENPX",imod, linelenpx);
00650       cpl_table_set_double(*mod_tbl, "BLAZE"    ,imod, blaze);
00651           ++imod;
00652 
00653     }
00654     order--;
00655       } /* end loop over mm */
00656     } /* end loop over i */
00657  
00658   cpl_table_duplicate_column(*mod_tbl,"IDENT",*mod_tbl,"WAVE");
00659   cpl_table_multiply_scalar(*mod_tbl,"IDENT",10.);
00660   cpl_table_duplicate_column(*mod_tbl,"XSTART",*mod_tbl,"XMOD");
00661   cpl_table_add_scalar(*mod_tbl,"XSTART",-mbox_x/2.);
00662   cpl_table_duplicate_column(*mod_tbl,"YSTART",*mod_tbl,"YMOD");
00663   cpl_table_add_scalar(*mod_tbl,"YSTART",-mbox_y/2.);
00664   cpl_table_duplicate_column(*mod_tbl,"XEND",*mod_tbl,"XMOD");
00665   cpl_table_add_scalar(*mod_tbl,"XEND",mbox_x/2.);
00666   cpl_table_duplicate_column(*mod_tbl,"YEND",*mod_tbl,"YMOD");
00667   cpl_table_add_scalar(*mod_tbl,"YEND",mbox_y/2.);
00668 
00669 
00670 /* close everything */
00671 
00672 
00673 
00674     uves_msg("Predicted number of lines: %d",imod);
00675 
00676 /* Compute the free spectral range */
00677 
00678     uves_msg("Determine the Free Spectral Range");
00679  
00680     dxpix = (double) xpix;
00681     dypix = (double) ypix;
00682 
00683     m_min = -1;
00684     m_max = -1;
00685 /*
00686    uves_physmod_lambda_order_model(&l,&m_max,dxpix/2,1.0);
00687    uves_physmod_lambda_order_model(&l,&m_min,dxpix/2,dypix);
00688 */
00689     uves_physmod_lambda_order_model(&lmax,&m_min,1.0,dypix);
00690     uves_physmod_lambda_order_model(&lmin,&m_max,dxpix,1.0);
00691 
00692     uves_physmod_lambda_order_model(&lmax,&m_min,dxpix,dypix);
00693     uves_physmod_lambda_order_model(&lmin,&m_max,1.0,1.0);
00694 
00695    
00696    uves_msg_debug("m_min= %d,m_max= %d",m_min,m_max);
00697 
00698    
00699 /* Creation of the modfree_sp_rg.tbl table */
00700 
00701     *fsr_tbl=cpl_table_new(m_max-m_min+1);
00702   
00703     uves_msg("FSR tbl created: %s. No of columns: %d, No of rows: %d","free_spectral_range",
00704              20,m_max-m_min+1);
00705   cpl_table_new_column(*fsr_tbl,"ORDER",CPL_TYPE_INT);
00706   cpl_table_new_column(*fsr_tbl,"WVCENTCOL",CPL_TYPE_DOUBLE);
00707   cpl_table_new_column(*fsr_tbl,"YCENTCOL",CPL_TYPE_DOUBLE);
00708   cpl_table_new_column(*fsr_tbl,"START",CPL_TYPE_DOUBLE);
00709   cpl_table_new_column(*fsr_tbl,"END",CPL_TYPE_DOUBLE);
00710   cpl_table_new_column(*fsr_tbl,"WAVECENT",CPL_TYPE_DOUBLE);
00711   cpl_table_new_column(*fsr_tbl,"YCENT",CPL_TYPE_DOUBLE);
00712   cpl_table_new_column(*fsr_tbl,"FSRMIN",CPL_TYPE_DOUBLE);
00713   cpl_table_new_column(*fsr_tbl,"FSRMAX",CPL_TYPE_DOUBLE);
00714   cpl_table_new_column(*fsr_tbl,"XFSR_MIN",CPL_TYPE_DOUBLE);
00715   cpl_table_new_column(*fsr_tbl,"XFSR_MAX",CPL_TYPE_DOUBLE);
00716   cpl_table_new_column(*fsr_tbl,"YFSR_MIN",CPL_TYPE_DOUBLE);
00717   cpl_table_new_column(*fsr_tbl,"YFSR_MAX",CPL_TYPE_DOUBLE);
00718   cpl_table_new_column(*fsr_tbl,"PIXSCALE",CPL_TYPE_DOUBLE);
00719   cpl_table_new_column(*fsr_tbl,"PIXSCALCD",CPL_TYPE_DOUBLE);
00720   cpl_table_new_column(*fsr_tbl,"BIN_SIZE",CPL_TYPE_DOUBLE);
00721   cpl_table_new_column(*fsr_tbl,"LINEWIDPX",CPL_TYPE_DOUBLE);
00722   cpl_table_new_column(*fsr_tbl,"LINEWIDTH",CPL_TYPE_DOUBLE);
00723   cpl_table_new_column(*fsr_tbl,"RESOL",CPL_TYPE_DOUBLE);
00724   cpl_table_new_column(*fsr_tbl,"LINELENPX",CPL_TYPE_DOUBLE);
00725 
00726 
00727   imod = 0;
00728   uves_msg_debug("m, waveCentcol,   Start,     End,       yCent,    FSRmin,   FSRmax,  bin (mA)");
00729 
00730   for (m=m_max; m>=m_min; m--) {
00731      uves_msg_debug("%d ",m);
00732      uves_physmod_find_FSR(m,&l, &fsr_min, &fsr_max);
00733      
00734      uves_physmod_xy_model(l,m,&x,&y);
00735 
00736 /* Translation */
00737       x += xtrans;
00738       y += ytrans;
00739      
00740      uves_physmod_xy_model(fsr_min,m,&xfsr_min,&yfsr_min);
00741      
00742 /* Translation */
00743       xfsr_min += xtrans;
00744       yfsr_min += ytrans;
00745 
00746      uves_physmod_xy_model(fsr_max,m,&xfsr_max,&yfsr_max);
00747      
00748 /* Translation */
00749       xfsr_max += xtrans;
00750       yfsr_max += ytrans;
00751 
00752 /* Computes the anamorphic magnification and the blaze function */      
00753      uves_physmod_lambda_order2beta(l,m, &uves_beta_ech, &uves_beta_cd, &fc);
00754      uves_physmod_photo_beta(l, uves_beta_ech, uves_beta_cd, 
00755                              &uves_physmod_rech, &uves_physmod_rcd, &blaze); 
00756      
00757 
00758 
00759 /* Computes the width (in pixel and A) and resolution lines */  
00760      uves_physmod_pixscl(l, m, uves_physmod_rech, uves_physmod_rcd, 
00761                          binx, biny, fc, slit_width, slit_length, 
00762                          &dl, &pixscale, &pixscalCD, 
00763                      &linewidpx, &linelenpx, &linewidth, &resol);
00764 
00765      mmin  = m;
00766      mmax = m;
00767 
00768   
00769 
00770 /* WARNING! The central column doesn't correspond to the central wavelength position */     
00771      uves_physmod_lambda_order_model(&lcent,&m,dxpix/2,y);
00772      uves_physmod_xy_model(lcent,m,&xr,&yr);
00773      
00774      uves_physmod_lambda_order_model(&lmax,&mmax,dxpix,y);
00775      uves_physmod_lambda_order_model(&lmin,&mmin,1.0,y); 
00776 
00777 /*     if (y>=0. && y <=dypix) {*/
00778 
00779        uves_msg_debug("m=%d, waveCent (nm)=%f, Start=%f, End=%f",m,l,lmin,lmax);
00780        uves_msg_debug("yCent=%f,FSRmin=%f,FSRmax=%f,bin (mA)=%f",y,fsr_min,fsr_max,dl);
00781 
00782 
00783        uves_msg_debug("%d %f %f %f %f %f %f %f",m,lcent,lmin,lmax,yr,fsr_min,fsr_max,dl);
00784 
00785 
00786        uves_msg_debug("pixel-scale = %f, anamorphic corrections = %f, %f", 
00787                       pixscale, uves_physmod_rech, uves_physmod_rcd);
00788 
00789 
00790        cpl_table_set_int(*fsr_tbl, "ORDER",imod,m);
00791        cpl_table_set_double(*fsr_tbl, "WVCENTCOL",imod,lcent);
00792        cpl_table_set_double(*fsr_tbl, "YCENTCOL",imod,yr);
00793        cpl_table_set_double(*fsr_tbl, "START",imod,lmin);
00794        cpl_table_set_double(*fsr_tbl, "END",imod,lmax);
00795        cpl_table_set_double(*fsr_tbl, "WAVECENT",imod,l);
00796        cpl_table_set_double(*fsr_tbl, "YCENT",imod,y);
00797        cpl_table_set_double(*fsr_tbl, "FSRMIN",imod,fsr_min);
00798        cpl_table_set_double(*fsr_tbl, "FSRMAX",imod,fsr_max);
00799        cpl_table_set_double(*fsr_tbl, "XFSR_MIN",imod,xfsr_min);
00800        cpl_table_set_double(*fsr_tbl, "XFSR_MAX",imod,xfsr_max);
00801        cpl_table_set_double(*fsr_tbl, "YFSR_MIN",imod,yfsr_min);
00802        cpl_table_set_double(*fsr_tbl, "YFSR_MAX",imod,yfsr_max);
00803        cpl_table_set_double(*fsr_tbl, "PIXSCALE",imod,pixscale);
00804        cpl_table_set_double(*fsr_tbl, "PIXSCALCD",imod,pixscalCD);
00805        cpl_table_set_double(*fsr_tbl, "BIN_SIZE",imod,dl);
00806        cpl_table_set_double(*fsr_tbl, "LINEWIDPX",imod,linewidpx);
00807        cpl_table_set_double(*fsr_tbl, "LINEWIDTH",imod,linewidth);
00808        cpl_table_set_double(*fsr_tbl, "RESOL",imod,resol);
00809        cpl_table_set_double(*fsr_tbl, "LINELENPX",imod,linelenpx);
00810          ++imod;
00811 
00812 /*     }*/
00813   }
00814 
00815   /* To remove possible NULL entries */
00816   cpl_table_erase_invalid_rows(*mod_tbl);
00817 
00818   /* Now we do the polynomial fit */
00819   uves_msg_debug("End determination fsr range");
00820 
00821 
00822    cleanup:
00823 
00824   return 0;
00825 }
00826 
00827 
00828 static int
00829 flames_get_trans(const int plt_no,
00830                  enum uves_chip chip, 
00831                  const double wlen, 
00832                  double * TX,
00833                  double * TY)
00834 {
00835 
00836 
00837   if(plt_no==1) {
00838     if( chip==UVES_CHIP_REDL) {
00839       if(wlen==520) {
00840         *TX = -15.330;
00841         *TY = -40.461; 
00842       } else if (wlen == 580) {
00843     *TX = -17.972;
00844         *TY = -39.200;    
00845       } else if (wlen == 860) {
00846         *TX= -12.212;
00847         *TY= -49.370;
00848       }
00849     } else {
00850       if(wlen==520) {
00851         *TX = -14.237;
00852         *TY = -40.337;
00853       } else if (wlen == 580) {
00854         *TX= -14.738;
00855         *TY= -38.831;  
00856       } else if (wlen == 860) {
00857 
00858         *TX = -8.253;
00859         *TY = -45.385;
00860       }
00861     }
00862   } else if (plt_no==2) {
00863     if( chip==UVES_CHIP_REDL) {
00864       if(wlen==520) {
00865         *TX = +10.136;
00866         *TY = -41.420;
00867       } else if (wlen == 580) {
00868         *TX = +9.000;
00869         *TY = -38.289;  
00870       } else if (wlen == 860) {
00871         *TX = +16.386;
00872         *TY = -47.519;
00873       }
00874     } else {
00875       if(wlen==520) {
00876         *TX = +12.244;
00877         *TY = -41.970;
00878       } else if (wlen == 580) {
00879         *TX = +12.023;
00880         *TY = -38.165;
00881       } else if (wlen == 860) {
00882         *TX = +18.241;
00883         *TY = -43.889; 
00884       }
00885     }
00886 
00887   } else {
00888     uves_msg_warning("plt_no=%d chip=%d Wlen %g is not standard setting setting defaults",plt_no,chip,wlen); 
00889     *TX = 0;
00890     *TY = 0;
00891   }
00892   return 0;
00893 
00894 }
00895 
00896 
00897 /*---------------------------------------------------------------------------*/
00908 /*---------------------------------------------------------------------------*/
00909 
00910 
00911 static int
00912 uves_get_physmod_offset(const int wavec,
00913                         enum uves_chip chip,
00914                         const int binx,
00915                         const int biny,
00916             double* trans_x,
00917             double* trans_y,
00918             double* ech_ang_off,
00919             double* cd_ang_off,
00920             double* ccd_ang_off)
00921 {
00922 
00923    //For the moment rot angle default is assumed always 0,0,0
00924    *ech_ang_off=0;
00925    *cd_ang_off=0;
00926    *ccd_ang_off=0;
00927 
00928    uves_msg("wavec=%d,chip=%d binx=%d biny=%d",wavec,chip,binx,biny);
00929 
00930    if(binx==1 && biny == 1) {
00931 
00932 
00933 
00934       if(chip==UVES_CHIP_REDL) {
00935          switch(wavec){
00936             case 520:
00937                *trans_x=3.0703;
00938                *trans_y=6.8252;
00939                *ccd_ang_off=-0.338;
00940                uves_msg("case ech 520 REDL 1x1");
00941                break;
00942 
00943             case 564:
00944                *trans_x=2.2151;
00945                *trans_y=0.1092;
00946                *ccd_ang_off=-.319;
00947                uves_msg("case ech 564 REDL 1x1");
00948                break;
00949 
00950             case 580:
00951                *trans_x=1.7116;
00952                *trans_y=-0.4874;
00953                *ccd_ang_off=-0.321;
00954                uves_msg("case ech 580 REDL 1x1");
00955                break;
00956 
00957             case 600:
00958                *trans_x=0.1581;
00959                *trans_y=5.3308;
00960                *ccd_ang_off=-.344;
00961                uves_msg("case ech 600 REDL 1x1");
00962                break;
00963 
00964             case 620:
00965                *trans_x=10.3267;
00966                *trans_y=2.7942;
00967                *ccd_ang_off=-0.338;
00968                uves_msg("case ech 620 REDL 1x1");
00969                break;
00970 
00971 
00972             case 640:
00973                *trans_x=0.3785;
00974                *trans_y=-3.8460;
00975                *ccd_ang_off=-0.338;
00976                uves_msg("case ech 640 REDL 1x1");
00977                break;
00978 
00979 
00980             case 660:
00981                *trans_x=9.7465;
00982                *trans_y=0.7125;
00983                *ccd_ang_off=-0.338;
00984                uves_msg("case ech 660 REDL 1x1");
00985                break;
00986 
00987             case 680:
00988                *trans_x=9.3649;
00989                *trans_y=-2.4116;
00990                *ccd_ang_off=-0.338;
00991                uves_msg("case ech 680 REDL 1x1");
00992                break;
00993 
00994             case 700:
00995                *trans_x=8.9850;
00996                *trans_y=-5.6122;
00997                *ccd_ang_off=-0.338;
00998                uves_msg("case ech 700 REDL 1x1");
00999                break;
01000 
01001             case 720:
01002                *trans_x=8.7393;
01003                *trans_y=-7.0060;
01004                *ccd_ang_off=-0.338;
01005                uves_msg("case ech 720 REDL 1x1");
01006                break;
01007 
01008             case 740:
01009                *trans_x=8.2659;
01010                *trans_y=-4.3401;
01011                *ccd_ang_off=-0.338;
01012                uves_msg("case ech 740 REDL 1x1");
01013                break;
01014 
01015 
01016             case 760:
01017                *trans_x=8.6384;
01018                *trans_y=1.9904;
01019                *trans_x=8.1006;
01020                *trans_y=-1.0859;
01021                *ccd_ang_off=-.335;
01022                uves_msg("case ech 760 REDL 1x1");
01023                break;
01024 
01025 
01026             case 780:
01027                *trans_x=7.8761;
01028                *trans_y=0.5324;
01029                *ccd_ang_off=-0.338;
01030                uves_msg("case ech 780 REDL 1x1");
01031                break;
01032 
01033 
01034             case 800:
01035                *trans_x=7.5052;
01036                *trans_y=0.7860;
01037                *ccd_ang_off=-0.338;
01038                uves_msg("case ech 800 REDL 1x1");
01039                break;
01040 
01041             case 820:
01042                *trans_x=7.2100;
01043                *trans_y=-1.8423;
01044                *ccd_ang_off=-0.338;
01045                uves_msg("case ech 820 REDL 1x1");
01046                break;
01047 
01048             case 840:
01049                *trans_x=6.8437;
01050                *trans_y=-4.9477;
01051                *ccd_ang_off=-0.338;
01052                uves_msg("case ech 820 REDL 1x1");
01053                break;
01054 
01055             case 860:
01056                *trans_x=6.8385;
01057                *trans_y=-3.0247;
01058                *ccd_ang_off=-.350;
01059                uves_msg("case ech 860 REDL 1x1");
01060                break;
01061 
01062             case 880:
01063                *trans_x=6.4751;
01064                *trans_y=-8.2393;
01065                *ccd_ang_off=-.350;
01066                uves_msg("case ech 880 REDL 1x1");
01067                break;
01068 
01069             case 900:
01070                *trans_x=5.9872;
01071                *trans_y=-7.5682;
01072                *ccd_ang_off=-.350;
01073                uves_msg("case ech 900 REDL 1x1");
01074                break;
01075 
01076             default:
01077                *ccd_ang_off=-0.338;
01078                break;
01079 
01080          }
01081       } else {
01082 
01083          switch(wavec){
01084             case 520:
01085                *trans_x=3.5471;
01086                *trans_y=14.6995;
01087                *ccd_ang_off=-.131;
01088                uves_msg("case ech 520 REDU 1x1");
01089                break;
01090 
01091             case 564:
01092                *trans_x=3.8134;
01093                *trans_y=8.0660;
01094                *ccd_ang_off=-0.161;
01095                uves_msg("case ech 564 REDU 1x1");
01096                break;
01097 
01098             case 580:
01099                *trans_x=2.2649;
01100                *trans_y=7.5163;
01101                *ccd_ang_off=-.106;
01102                uves_msg("case ech 580 REDU 1x1");
01103                break;
01104 
01105             case 600:
01106                *trans_x=2.3765;
01107                *trans_y=12.9146;
01108                *ccd_ang_off=-.112;
01109                uves_msg("case ech 600 REDU 1x1");
01110                break;
01111 
01112             case 620:
01113                *trans_x=10.7635;
01114                *trans_y=13.2254;
01115                *ccd_ang_off=-.131;
01116                uves_msg("case ech 620 REDL 1x1");
01117                break;
01118 
01119             case 640:
01120                *trans_x=2.6177;
01121                *trans_y=10.0995;
01122                *ccd_ang_off=-.131;
01123                uves_msg("case ech 640 REDL 1x1");
01124                break;
01125 
01126             case 660:
01127                *trans_x=10.4909;
01128                *trans_y=11.3694;
01129                *ccd_ang_off=-.131;
01130                uves_msg("case ech 660 REDL 1x1");
01131                break;
01132 
01133             case 680:
01134                *trans_x=10.4899;
01135                *trans_y=8.4049;
01136                *ccd_ang_off=-.131;
01137                uves_msg("case ech 680 REDL 1x1");
01138                break;
01139 
01140             case 700:
01141                *trans_x=10.2939;
01142                *trans_y=5.3955;
01143                *ccd_ang_off=-.131;
01144                uves_msg("case ech 700 REDL 1x1");
01145                break;
01146 
01147 
01148             case 720:
01149                *trans_x=9.9791;
01150                *trans_y=4.0860;
01151                *ccd_ang_off=-.131;
01152                uves_msg("case ech 720 REDL 1x1");
01153                break;
01154 
01155             case 740:
01156                *trans_x=9.8533;
01157                *trans_y=6.9165;
01158                *ccd_ang_off=-.131;
01159                uves_msg("case ech 740 REDL 1x1");
01160                break;
01161 
01162 
01163             case 760:
01164                *trans_x=11.0378;
01165                *trans_y=12.9732;
01166                *trans_x=10.5357;
01167                *trans_y=10.1393;
01168                *ccd_ang_off=-.160;
01169                uves_msg("case ech 760 REDU 1x1");
01170                break;
01171 
01172             case 780:
01173                *trans_x=9.5521;
01174                *trans_y=11.7901;
01175                *ccd_ang_off=-.131;
01176                uves_msg("case ech 780 REDL 1x1");
01177                break;
01178 
01179             case 800:
01180                *trans_x=9.3306;
01181                *trans_y=17.4402;
01182                *ccd_ang_off=-.131;
01183                uves_msg("case ech 800 REDL 1x1");
01184                break;
01185 
01186             case 820:
01187                *trans_x=9.1435;
01188                *trans_y=14.8772;
01189                *ccd_ang_off=-.131;
01190                uves_msg("case ech 820 REDL 1x1");
01191                break;
01192 
01193             case 840:
01194                *trans_x=8.8927;
01195                *trans_y=11.8143;
01196                *ccd_ang_off=-.131;
01197                uves_msg("case ech 840 REDL 1x1");
01198                break;
01199 
01200 
01201 
01202             case 860:
01203                *trans_x=10.9306;
01204                *trans_y=7.8155;
01205                *ccd_ang_off=-.176;
01206                uves_msg("case ech 860 REDU 1x1");
01207                break;
01208 
01209             case 880:
01210                *trans_x=9.0960;
01211                *trans_y=3.2741;
01212                *ccd_ang_off=-.131;
01213                uves_msg("case ech 880 REDL 1x1");
01214                break;
01215 
01216 
01217             case 900:
01218                *trans_x=8.8903;
01219                *trans_y=8.9738;
01220                *ccd_ang_off=-.131;
01221                uves_msg("case ech 900 REDL 1x1");
01222                break;
01223 
01224 
01225             default:
01226                *ccd_ang_off=-.131;
01227                break;
01228 
01229          }
01230   
01231       }
01232    } else if(binx==2 && biny == 2) {
01233 
01234 
01235 
01236       if(chip==UVES_CHIP_REDL) {
01237          switch(wavec){
01238 
01239 
01240             case 500:
01241                *trans_x=1.6127;
01242                *trans_y=0.3725;
01243                *ccd_ang_off=-.335;
01244                uves_msg("case ech 500 REDL 2x2");
01245                break;
01246 
01247 
01248             case 520:
01249                *trans_x=1.0304;
01250                *trans_y=4.4927;
01251                *ccd_ang_off=-0.338;
01252                uves_msg("case ech 520 REDL 2x2");
01253                break;
01254 
01255 
01256             case 540:
01257                *trans_x=0.9221;
01258                *trans_y=2.6768;
01259                *ccd_ang_off=-.335;
01260                uves_msg("case ech 540 REDL 2x2");
01261                break;
01262 
01263             case 560:
01264                *trans_x=0.7170;
01265                *trans_y=-0.0175;
01266                *ccd_ang_off=-.335;
01267                uves_msg("case ech 560 REDL 2x2");
01268                break;
01269 
01270 
01271             case 564:
01272                *trans_x=0.5659;
01273                *trans_y=1.2151;
01274                *ccd_ang_off=-.319;
01275                uves_msg("case ech 564 REDL 2x2");
01276                break;
01277 
01278             case 580:
01279                *trans_x=0.4406;
01280                *trans_y=0.7901;
01281                *ccd_ang_off=-0.321;
01282                uves_msg("case ech 580 REDL 2x2");
01283                break;
01284 
01285             case 600:
01286                *trans_x=0.2550;
01287                *trans_y=3.7476;
01288                *ccd_ang_off=-0.315;
01289                uves_msg("case ech 600 REDL 2x2");
01290                break;
01291 
01292             case 620:
01293                *trans_x=0.1970;
01294                *trans_y=3.0182;
01295                *ccd_ang_off=-.335;
01296                uves_msg("case ech 620 REDL 2x2");
01297                break;
01298 
01299             case 640:
01300                *trans_x=0.0203;
01301                *trans_y=-0.0638;
01302                *ccd_ang_off=-.335;
01303                uves_msg("case ech 640 REDL 2x2");
01304                break;
01305 
01306             case 660:
01307                *trans_x=5.2122;
01308                *trans_y=1.5986;
01309                *ccd_ang_off=-.335;
01310                uves_msg("case ech 660 REDL 2x2");
01311                break;
01312 
01313             case 680:
01314                *trans_x=5.0355;
01315                *trans_y=-0.1277;
01316                *ccd_ang_off=-.335;
01317                uves_msg("case ech 680 REDL 2x2");
01318                break;
01319 
01320             case 700:
01321                *trans_x=4.8466;
01322                *trans_y=-1.8237;
01323                *ccd_ang_off=-.335;
01324                uves_msg("case ech 700 REDL 2x2");
01325                break;
01326 
01327             case 720:
01328                *trans_x=4.7320;
01329                *trans_y=-2.4860;
01330                *ccd_ang_off=-.335;
01331                uves_msg("case ech 720 REDL 2x2");
01332                break;
01333 
01334             case 740:
01335                *trans_x=4.5968;
01336                *trans_y=-1.1956;
01337                *ccd_ang_off=-.335;
01338                uves_msg("case ech 740 REDL 2x2");
01339                break;
01340 
01341             case 760:
01342                *trans_x=3.7298;
01343                *trans_y=2.0585;
01344                *trans_x=4.5392;
01345                *trans_y=0.4414;
01346                *ccd_ang_off=-.335;
01347                uves_msg("case ech 760 REDL 2x2");
01348                break;
01349 
01350             case 780:
01351                *trans_x=4.4156;
01352                *trans_y=1.2900;
01353                *ccd_ang_off=-.335;
01354                uves_msg("case ech 780 REDL 2x2");
01355                break;
01356 
01357             case 800:
01358                *trans_x=4.2877;
01359                *trans_y=2.2643;
01360                *ccd_ang_off=-.335;
01361                uves_msg("case ech 800 REDL 2x2");
01362                break;
01363 
01364 
01365             case 820:
01366                *trans_x=4.1695;
01367                *trans_y=1.0259;
01368                *ccd_ang_off=-.335;
01369                uves_msg("case ech 820 REDL 2x2");
01370                break;
01371 
01372             case 840:
01373                *trans_x=4.1004;
01374                *trans_y=-0.6081;
01375                *ccd_ang_off=-.335;
01376                uves_msg("case ech 840 REDL 2x2");
01377                break;
01378 
01379             case 860:
01380                *trans_x=3.1362;
01381                *trans_y=-.6278;
01382                *ccd_ang_off=-.350;
01383                uves_msg("case ech 860 REDL 2x2");
01384                break;
01385 
01386             case 880:
01387                *trans_x=3.8903;
01388                *trans_y=-3.1012;
01389                *ccd_ang_off=-.335;
01390                uves_msg("case ech 880 REDL 2x2");
01391                break;
01392 
01393             case 900:
01394                *trans_x=3.7873;
01395                *trans_y=-2.0264;
01396                *ccd_ang_off=-.335;
01397                uves_msg("case ech 900 REDL 2x2");
01398                break;
01399 
01400 
01401 
01402             default:
01403                *ccd_ang_off=-.335;
01404                break;
01405          }
01406       } else {
01407 
01408          switch(wavec){
01409 
01410 
01411             case 500:
01412                *trans_x=1.6644;
01413                *trans_y=2.1540;
01414                *ccd_ang_off=-.131;
01415                uves_msg("case ech 500 REDU 2x2");
01416                break;
01417 
01418 
01419 
01420             case 520:
01421                *trans_x=1.3965;
01422                *trans_y=6.2855;
01423                *ccd_ang_off=-.131;
01424                uves_msg("case ech 520 REDU 2x2");
01425                break;
01426 
01427             case 540:
01428                *trans_x=1.3951;
01429                *trans_y=4.7774;
01430                *ccd_ang_off=-.131;
01431                uves_msg("case ech 540 REDU 2x2");
01432                break;
01433 
01434             case 560:
01435                *trans_x=1.3307;
01436                *trans_y=2.0433;
01437                *ccd_ang_off=-.131;
01438                uves_msg("case ech 560 REDU 2x2");
01439                break;
01440 
01441 
01442             case 564:
01443                *trans_x=1.3329;
01444                *trans_y=2.9888;
01445                *ccd_ang_off=-0.161;
01446                uves_msg("case ech 564 REDU 2x2");
01447                break;
01448 
01449             case 580:
01450                *trans_x=0.9856;
01451                *trans_y=2.5873;
01452                *ccd_ang_off=-.106;
01453                uves_msg("case ech 580 REDU 2x2");
01454                break;
01455 
01456             case 600:
01457                *trans_x=0.9223;
01458                *trans_y=5.5208;
01459                *ccd_ang_off=-.112;
01460                uves_msg("case ech 600 REDU 2x2");
01461                break;
01462 
01463 
01464             case 620:
01465                *trans_x=1.1483;
01466                *trans_y=5.2252;
01467                *ccd_ang_off=-.131;
01468                uves_msg("case ech 620 REDU 2x2");
01469                break;
01470 
01471 
01472 
01473             case 640:
01474                *trans_x=1.0534;
01475                *trans_y=2.1526;
01476                *ccd_ang_off=-.131;
01477                uves_msg("case ech 640 REDU 2x2");
01478                break;
01479 
01480             case 660:
01481                *trans_x=5.8447;
01482                *trans_y=4.8530;
01483                *ccd_ang_off=-.131;
01484                uves_msg("case ech 660 REDU 2x2");
01485                break;
01486 
01487 
01488             case 680:
01489                *trans_x=5.7227;
01490                *trans_y=3.2191;
01491                *ccd_ang_off=-.131;
01492                uves_msg("case ech 680 REDU 2x2");
01493                break;
01494 
01495             case 700:
01496                *trans_x=5.6851;
01497                *trans_y=1.6912;
01498                *ccd_ang_off=-.131;
01499                uves_msg("case ech 700 REDU 2x2");
01500                break;
01501 
01502             case 720:
01503                *trans_x=5.5375;
01504                *trans_y=1.0217;
01505                *ccd_ang_off=-.131;
01506                uves_msg("case ech 720 REDU 2x2");
01507                break;
01508 
01509             case 740:
01510                *trans_x=5.4927;
01511                *trans_y=2.3500;
01512                *ccd_ang_off=-.131;
01513                uves_msg("case ech 740 REDU 2x2");
01514                break;
01515 
01516 
01517 
01518             case 760:
01519                *trans_x=4.8082;
01520                *trans_y=5.3052;
01521                *trans_x=5.6659;
01522                *trans_y=3.9673;
01523                *ccd_ang_off=-.160;
01524                uves_msg("case ech 760 REDU 2x2");
01525                break;
01526 
01527 
01528             case 780:
01529                *trans_x=5.3406;
01530                *trans_y=4.7919;
01531                *ccd_ang_off=-.131;
01532                uves_msg("case ech 780 REDU 2x2");
01533                break;
01534 
01535 
01536             case 800:
01537                *trans_x=5.2926;
01538                *trans_y=5.8133;
01539                *ccd_ang_off=-.131;
01540                uves_msg("case ech 800 REDU 2x2");
01541                break;
01542 
01543             case 820:
01544                *trans_x=5.1947;
01545                *trans_y=4.5974;
01546                *ccd_ang_off=-.131;
01547                uves_msg("case ech 820 REDU 2x2");
01548                break;
01549 
01550 
01551             case 840:
01552                *trans_x=5.1033;
01553                *trans_y=2.9638;
01554                *ccd_ang_off=-.131;
01555                uves_msg("case ech 840 REDU 2x2");
01556                break;
01557 
01558             case 860:
01559                *trans_x=4.5923;
01560                *trans_y=2.6809;
01561                *ccd_ang_off=-.176;
01562                uves_msg("case ech 860 REDU 2x2");
01563                break;
01564 
01565 
01566             case 880:
01567                *trans_x=4.9641;
01568                *trans_y=0.3260;
01569                *ccd_ang_off=-.131;
01570                uves_msg("case ech 880 REDU 2x2");
01571                break;
01572 
01573             case 900:
01574                *trans_x=4.9610;
01575                *trans_y=1.4586;
01576                *ccd_ang_off=-.131;
01577                uves_msg("case ech 900 REDU 2x2");
01578                break;
01579 
01580 
01581             default:
01582                *ccd_ang_off=-.131;
01583                break;
01584 
01585          }
01586   
01587       }
01588 
01589    } else if(binx==2 && biny == 1) {
01590 
01591 
01592 
01593       if(chip==UVES_CHIP_REDL) {
01594 
01595          switch(wavec){
01596             case 520:
01597                *trans_x=-0.5469;
01598                *trans_y=3.1225;
01599                *ccd_ang_off=-.400;
01600                uves_msg("case ech 520 REDL 2x1");
01601                break;
01602 
01603             case 564:
01604                *trans_x=-1.3918;
01605                *trans_y=-2.9967;
01606 
01607                *ccd_ang_off=-.400;
01608                uves_msg("case ech 564 REDL 2x1");
01609                break;
01610 
01611             case 580:
01612                *trans_x=-1.4333;
01613                *trans_y=-4.3223;
01614 
01615                *ccd_ang_off=-.400;
01616                uves_msg("case ech 580 REDL 2x1");
01617                break;
01618 
01619             case 600:
01620                *trans_x=-1.6725;
01621                *trans_y=1.5057;
01622 
01623 
01624                *ccd_ang_off=-.400;
01625                uves_msg("case ech 600 REDL 2x1");
01626                break;
01627 
01628 
01629             case 760:
01630                *trans_x=1.5073;
01631                *trans_y=-1.6050;
01632                *ccd_ang_off=-.400;
01633                uves_msg("case ech 760 REDL 2x1");
01634                break;
01635 
01636             case 860:
01637                *trans_x=0.9818;
01638                *trans_y=-6.9373;
01639                *ccd_ang_off=-.400;
01640                uves_msg("case ech 860 REDL 2x1");
01641                break;
01642 
01643             default:
01644                *ccd_ang_off=-.400;
01645                break;
01646 
01647          }
01648       } else {
01649          switch(wavec){
01650             case 520:
01651                *trans_x=-1.0242;
01652                *trans_y=11.4442;
01653                *ccd_ang_off=-.100;
01654                uves_msg("case ech 520 REDU 2x1");
01655                break;
01656 
01657             case 564:
01658                *trans_x=-1.2162;
01659                *trans_y=5.7253;
01660                *ccd_ang_off=-.100;
01661                uves_msg("case ech 564 REDU 2x1");
01662                break;
01663 
01664             case 580:
01665                *trans_x=-1.0591;
01666                *trans_y=4.5918;
01667                *ccd_ang_off=-.100;
01668                uves_msg("case ech 580 REDU 2x1");
01669                break;
01670 
01671             case 600:
01672                *trans_x=-1.1089;
01673                *trans_y=10.0907;
01674                *ccd_ang_off=-.100;
01675                uves_msg("case ech 600 REDU 2x1");
01676                break;
01677 
01678             case 760:
01679                *trans_x=1.9719;
01680                *trans_y=9.6496;
01681 
01682                *ccd_ang_off=-.100;
01683                uves_msg("case ech 760 REDU 2x1");
01684                break;
01685 
01686             case 860:
01687                *trans_x=1.9402;
01688                *trans_y=4.2234;
01689                *ccd_ang_off=-.100;
01690                uves_msg("case ech 860 REDU 2x1");
01691                break;
01692 
01693             default:
01694                *ccd_ang_off=-.100;
01695                break;
01696          }
01697       }
01698    } else if(binx==3 && biny == 2) {
01699 
01700 
01701 
01702       if(chip==UVES_CHIP_REDL) {
01703          switch(wavec){
01704             case 520:
01705                *trans_x=2.0359;
01706                *trans_y=2.9332;
01707                *ccd_ang_off=-.190;
01708                uves_msg("case ech 520 REDL 3x2");
01709                break;
01710 
01711             case 564:
01712                *trans_x=1.5143;
01713                *trans_y=-0.2408;
01714                *ccd_ang_off=-.190;
01715                uves_msg("case ech 564 REDL 3x2");
01716                break;
01717 
01718             case 580:
01719                *trans_x=1.2014;
01720                *trans_y=-0.9518;
01721                *ccd_ang_off=-.190;
01722                uves_msg("case ech 580 REDL 3x2");
01723                break;
01724 
01725             case 600:
01726                *trans_x=1.2753;
01727                *trans_y=1.8916;
01728                *ccd_ang_off=-.190;
01729                uves_msg("case ech 600 REDL 3x2");
01730                break;
01731 
01732 
01733             case 760:
01734                *trans_x=3.5390;
01735                *trans_y=0.3579;
01736                *ccd_ang_off=-.190;
01737                uves_msg("case ech 760 REDL 3x2");
01738                break;
01739 
01740             case 860:
01741                *trans_x=3.0845;
01742                *trans_y=-2.2232;
01743                *ccd_ang_off=-.190;
01744                uves_msg("case ech 860 REDL 3x2");
01745                break;
01746 
01747             default:
01748                *ccd_ang_off=-.190;
01749                break;
01750 
01751          }
01752       } else {
01753          switch(wavec){
01754 
01755             case 520:
01756                *trans_x=0.4483;
01757                *trans_y=4.5161;
01758                *ccd_ang_off=-.100;
01759                uves_msg("case ech 520 REDU 3x2");
01760                break;
01761 
01762             case 564:
01763                *trans_x=0.0711;
01764                *trans_y=1.5479;
01765                *ccd_ang_off=-.100;
01766                uves_msg("case ech 564 REDU 3x2");
01767                break;
01768 
01769             case 580:
01770                *trans_x=0.2785;
01771                *trans_y=0.9470;
01772                *ccd_ang_off=-.100;
01773                uves_msg("case ech 580 REDU 3x2");
01774                break;
01775 
01776             case 600:
01777                *trans_x=0.1448;
01778                *trans_y=3.7903;
01779                *ccd_ang_off=-.100;
01780                uves_msg("case ech 600 REDU 3x2");
01781                break;
01782 
01783             case 760:
01784                *trans_x=2.1704;
01785                *trans_y=3.6996;
01786                *ccd_ang_off=-.100;
01787                uves_msg("case ech 760 REDU 3x2");
01788                break;
01789 
01790             case 860:
01791                *trans_x=1.9817;
01792                *trans_y=1.0266;
01793                *ccd_ang_off=-.100;
01794                uves_msg("case ech 860 REDU 3x2");
01795                break;
01796 
01797             default:
01798                *ccd_ang_off=-.100;
01799                break;
01800 
01801          }
01802   
01803       }
01804  
01805    } else {
01806 
01807       uves_msg_warning("New CCD, frame is unbinned."); 
01808       uves_msg_warning("You may have to compute proper CCD rotation angle and X, Y offsets");
01809 
01810 
01811    }
01812 
01813    uves_msg("NEW CCD Physical Model shifts trans=%f,%f rot=%f,%f,%f",
01814             *trans_x,*trans_y,*ech_ang_off,*cd_ang_off,*ccd_ang_off);
01815    return 0;
01816 }
01817 
01818 
01819 /*---------------------------------------------------------------------------*/
01831 /*---------------------------------------------------------------------------*/
01832 
01833 
01834 static int
01835 flames_get_physmod_offset(const int plate_no,
01836               const int wavec,
01837               enum uves_chip chip,
01838               double* trans_x,
01839               double* trans_y,
01840               double* ech_ang_off,
01841               double* cd_ang_off,
01842               double* ccd_ang_off)
01843 {
01844 
01845    //For the moment rot angle default is assumed always 0,0,0
01846    *ech_ang_off=0;
01847    *cd_ang_off=0;
01848    *ccd_ang_off=0;
01849    uves_msg_warning("New CCD, frame is unbinned, FIBER mode");;
01850    uves_msg_warning("You may have to compute proper CCD rotation angle and X, Y offsets");
01851 
01852    uves_msg("plate_no=%d,wavec=%d,chip=%d",plate_no,wavec,chip);
01853    switch(plate_no){
01854 
01855       case 1:
01856 
01857          if(chip==UVES_CHIP_REDL) {
01858             switch(wavec){
01859 
01860                case 520:
01861                   *trans_x=4.5211;
01862                   *trans_y=0.2826;
01863                   *ccd_ang_off=-0.338;
01864                   uves_msg("case FIBRE 520 REDL plt1");
01865                   break;
01866 
01867                case 580:
01868                   *trans_x=6.0388;
01869                   *trans_y=-7.4226;
01870                   *ccd_ang_off=-0.321;
01871                   uves_msg("case FIBRE 580 REDL plt1");
01872                   break;
01873 
01874                case 860:
01875                   *trans_x=4.1211;
01876                   *trans_y=-2.3926;
01877                   *ccd_ang_off=-.350;
01878                   uves_msg("case FIBRE 860 REDL plt1");
01879                   break;
01880 
01881             }
01882          } else {
01883 
01884             switch(wavec){
01885 
01886                case 520:
01887                   *trans_x=2.1001;
01888                   *trans_y=8.0998;
01889                   *ccd_ang_off=-0.131;
01890                   uves_msg("case FIBRE 520 REDU plt1");
01891                   break;
01892 
01893                case 580:
01894                   *trans_x=2.1388;
01895                   *trans_y=0.1226;
01896                   *ccd_ang_off=-.106;
01897                   uves_msg("case FIBRE 580 REDU plt1");
01898                   break;
01899 
01900                case 860:
01901                   *trans_x=3.7411;
01902                   *trans_y=5.1006;
01903                   *ccd_ang_off=-.176;
01904                   uves_msg("case FIBRE 860 REDU plt1");
01905                   break;
01906 
01907             }  
01908          }
01909          break;
01910 
01911       case 2:
01912 
01913          if(chip==UVES_CHIP_REDL) {
01914             switch(wavec){
01915 
01916                case 520:
01917                   *trans_x=4.0311;
01918                   *trans_y=3.2253;
01919                   *ccd_ang_off=-0.338;
01920                   uves_msg("case FIBER 520 REDL plt2");
01921                   break;
01922 
01923                case 580:
01924                   *trans_x=4.1158;
01925                   *trans_y=-7.2539;
01926                   *ccd_ang_off=-.321;
01927                   uves_msg("case FIBER 580 REDL plt2");
01928                   break;
01929 
01930                case 860:
01931                   *trans_x=1.5000;
01932                   *trans_y=-2.4624;
01933                   *ccd_ang_off=-.343;
01934                   uves_msg("case FIBER 860 REDL plt2");
01935                   break;
01936 
01937             }
01938          } else {
01939 
01940             switch(wavec){
01941 
01942                case 520:
01943                   *trans_x=2.3911;
01944                   *trans_y=11.9726;
01945                   *ccd_ang_off=-0.131;
01946                   uves_msg("case FIBER 520 REDU plt2");
01947                   break;
01948 
01949                case 580:
01950                   *trans_x=1.5658;
01951                   *trans_y=0.6239;
01952                   *ccd_ang_off=-.106;
01953                   uves_msg("case FIBER 580 REDU plt2");
01954                   break;
01955 
01956                case 860:
01957                   *trans_x=3.1174;
01958                   *trans_y=4.7984;
01959                   *ccd_ang_off=-.176;
01960                   uves_msg("case FIBER 860 REDU plt2");
01961                   break;
01962 
01963             }  
01964          }
01965          break;
01966 
01967   default:
01968     *trans_x=0;
01969     *trans_y=0;
01970   
01971   }
01972 
01973 
01974   uves_msg("NEW CCD Physical Model shifts trans=%f,%f rot=%f,%f,%f",
01975        *trans_x,*trans_y,*ech_ang_off,*cd_ang_off,*ccd_ang_off);
01976   return 0;
01977 }
01978 
01979 
01980 
01981 
01982 
01983 

Generated on 8 Mar 2011 for UVES Pipeline Reference Manual by  doxygen 1.6.1