uves_physmod_utils.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  * $Id: uves_physmod_utils.c,v 1.19 2010/09/24 09:32:07 amodigli Exp $
00021  * $Name: uves-4_9_1 $
00022  * $Revision: 1.19 $
00023  * $Log: uves_physmod_utils.c,v $
00024  * Revision 1.19  2010/09/24 09:32:07  amodigli
00025  * put back QFITS dependency to fix problem spot by NRI on FIBER mode (with MIDAS calibs) data
00026  *
00027  * Revision 1.17  2007/12/03 10:41:38  amodigli
00028  * added uves_msg_debug on some function
00029  *
00030  * Revision 1.16  2007/11/26 15:28:29  amodigli
00031  * display more info
00032  *
00033  * Revision 1.15  2007/06/06 08:17:33  amodigli
00034  * replace tab with 4 spaces
00035  *
00036  * Revision 1.14  2006/11/06 15:19:41  jmlarsen
00037  * Removed unused include directives
00038  *
00039  * Revision 1.13  2006/08/23 15:41:06  amodigli
00040  * removed warning from checks on line length
00041  *
00042  * Revision 1.12  2006/08/23 09:33:03  jmlarsen
00043  * Renamed local variables shadowing POSIX reserved names
00044  *
00045  * Revision 1.11  2006/06/20 10:56:56  amodigli
00046  * cleaned output, added units
00047  *
00048  * Revision 1.10  2006/06/20 08:40:57  amodigli
00049  * fixed doxigen warnings
00050  *
00051  * Revision 1.9  2006/06/08 11:01:50  amodigli
00052  * fixed some warnings
00053  *
00054  * Revision 1.8  2006/06/07 12:50:44  jmlarsen
00055  * Removed doxygen tag addtogroup
00056  *
00057  * Revision 1.7  2006/06/07 12:45:19  jmlarsen
00058  * Added missing doxygen endmarker
00059  *
00060  * Revision 1.6  2006/06/05 08:51:55  amodigli
00061  * cleaned some warnings from static checks
00062  *
00063  * Revision 1.5  2006/06/01 14:43:17  jmlarsen
00064  * Added missing documentation
00065  *
00066  * Revision 1.4  2006/06/01 14:26:14  amodigli
00067  * fixed typo
00068  *
00069  * Revision 1.3  2006/06/01 14:22:07  amodigli
00070  * added Doxigen doc
00071  *
00072  * Revision 1.2  2006/04/24 09:22:16  jmlarsen
00073  * Added doxygen tag: addtogroup
00074  *
00075  * Revision 1.1  2006/02/03 07:46:30  jmlarsen
00076  * Moved recipe implementations to ./uves directory
00077  *
00078  * Revision 1.18  2006/01/05 14:29:59  jmlarsen
00079  * Removed newline characters from output strings
00080  *
00081  * Revision 1.17  2005/12/05 16:11:47  amodigli
00082  * Fixed some warning
00083  *
00084  * Revision 1.16  2005/12/02 12:56:09  amodigli
00085  * Fixed compilation problems on mac
00086  *
00087  * Revision 1.15  2005/11/28 15:36:34  amodigli
00088  * Renamed global variables and global function with prefix uves_physmod
00089  *
00090  * Revision 1.14  2005/11/28 08:37:27  amodigli
00091  * Fixed compilation warnings
00092  *
00093  * Revision 1.13  2005/11/25 08:05:15  amodigli
00094  *  Added plotting facility in physmod. Commented out some strange things in utils.
00095  *
00096  * Revision 1.12  2005/11/18 11:49:22  amodigli
00097  * More verbosity
00098  *
00099  * Revision 1.11  2005/11/17 08:25:49  amodigli
00100  * Removed uves_necregr.c
00101  *
00102  * Revision 1.10  2005/10/19 13:18:43  jmlarsen
00103  * General update
00104  *
00105  * Revision 1.9  2005/10/18 10:08:01  amodigli
00106  * Removed fctid
00107  *
00108  * Revision 1.8  2005/10/07 11:17:35  amodigli
00109  * Cleaned compilation warnings
00110  *
00111  * Revision 1.7  2005/10/03 07:32:44  amodigli
00112  * Fixed bugs to support RED CCD
00113  *
00114  * Revision 1.6  2005/09/28 12:28:14  jmlarsen
00115  * Replaced fctid -> __func__
00116  *
00117  * Revision 1.5  2005/09/18 14:24:10  amodigli
00118  * Updated
00119  *
00120  * Revision 1.4  2005/08/29 10:05:08  jmlarsen
00121  * Conversion to/from electrons when calculating photonic noise
00122  *
00123  * Revision 1.3  2005/08/29 08:27:58  amodigli
00124  * Put into repository updates on physical model
00125  *
00126  * Revision 1.2  2005/06/17 12:02:04  amodigli
00127  * Fixed compilation problem
00128  *
00129  * Revision 1.1  2005/06/17 11:34:34  amodigli
00130  * First release
00131  *
00132  *
00133  * ===========================================================================
00134  */
00135 /*----------------------------------------------------------------------------*/
00139 /*----------------------------------------------------------------------------*/
00140 
00141 #ifdef HAVE_CONFIG_H
00142 #  include <config.h>
00143 #endif
00144 
00145 /*+++ uves_physmod_utils.c +++++++++++++++++++++++++++++++++++++++++++++++++++
00146  
00147  .COPYRIGHT    (C) 1998  European Southern Observatory
00148  
00149  .IDENT        
00150  
00151  .KEYWORDS    uves physical model, spectroscopy, echelle,
00152  
00153  .USAGE        .
00154  
00155  .INPUT        .
00156         
00157  .OUTPUT    .
00158  
00159  .RETURN    Q1:  0: successful return
00160              -1: a successful return failed
00161  
00162  .PURPOSE    Library of UVES Physical Model Functions. 
00163  
00164  .ALGORITHM    UVES Physical Model.
00165 
00166  .ENVIRON    MIDAS, UVES context
00167     
00168  .LANGUAGE    C
00169  
00170  .AUTHOR    Pascal Ballester, Olivier BOITQUIN, ESO-DMD
00171  
00172  .VERSION    1.0 1999/07/01      Creation
00173                     1999/09/30-SW Binning implemented.
00174             1999/10/27-OB Bugs with n index fixed.
00175 
00176  .COMMENT       
00177 ----------------------------------------------------------------------------*/
00178 
00179 
00180 /*-----------------------------------------------------------------------------
00181                             Includes
00182  -----------------------------------------------------------------------------*/
00183 #include <uves_physmod_utils.h>
00184 
00185 #include <uves_utils.h>
00186 #include <uves_utils_wrappers.h>
00187 #include <uves_error.h>
00188 #include <uves_msg.h>
00189 
00190 #include <cpl.h>
00191 
00192 #include <stdio.h>
00193 #include <math.h>
00194 
00195 /*-----------------------------------------------------------------------------
00196                             Functions prototypes
00197  -----------------------------------------------------------------------------*/
00198 static void 
00199 beta2lamb(double uves_beta_ech, double uves_beta_cd, double* plambda, int m);
00200 
00201 static double 
00202 cameraFocal(double lm);
00203 
00204 static void 
00205 uves_physmod_find_alpha_beta(double lm, 
00206                              int m, 
00207                              double k, 
00208                              double theta, 
00209                              double *alpha, 
00210                              double *beta);
00211 
00212 static double 
00213 uves_physmod_find_lambda(double k, double alpha, double beta);
00214 
00215 static double 
00216 uves_physmod_find_order_lambda(double k, double alpha, double beta);
00217 /* not used:
00218 static void 
00219 uves_physmod_lambda_model(double* plambda, 
00220                           int m, 
00221                           double fc, 
00222                           double x, 
00223                           double y);
00224 */
00225 static void 
00226 uves_physmod_lambda_order_beta(double* plambda, 
00227                                int* pm, 
00228                                double x, 
00229                                double y, 
00230                                double* puves_beta_ech, 
00231                                double* puves_beta_cd);
00232 
00233 static void 
00234 uves_physmod_lambda_order_focus_model(double* plambda, 
00235                                       double* pdm, 
00236                                       double fc, 
00237                                       double x, 
00238                                       double y);
00239 
00240 static double uves_physmod_wave_bin(double l, int m);
00241 
00242 static void uves_physmod_xy2beta(double* puves_beta_ech, 
00243                                  double* puves_beta_cd, 
00244                                  double fc, 
00245                                  double x, 
00246                                  double y);
00247 
00248 static void uves_physmod_set_binning(float binx, float biny);
00249 
00250 static double dsqrarg;
00251 
00252 /*-----------------------------------------------------------------------------
00253                                 Defines
00254  -----------------------------------------------------------------------------*/
00255 
00256 #define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
00257 
00258 #define     PROID "physmod.c" 
00259 
00260 
00261 
00262 
00263 enum uves_arm_ident {UVES_ARM_UNDEF,UVES_ARM_BLUE,UVES_ARM_RED};
00264 enum uves_arm_ident uves_arm_ident = UVES_ARM_UNDEF;
00265 
00266 
00267 /* for messout function: no "static" (clear) -
00268    no "extern" (otherwise redeclaration in all files neccessary) */
00269 
00270 /* globals declared as extern in physmod.h */
00271 
00272 float    uves_bin[2]      = {1, 1}; /* binning of exposure in x and y */
00273 static double   uves_physmod_pix_size[2]  = {15e-6, 15e-6}; /* meters */
00274 static double   delta[2]  = {75.04, 76.0};
00275 
00276 static double   cdgroov[4]  = {1000.0e-6, 660.0e-6, 600.0e-6, 312.5e-6};  /* grooves/nm */
00277 static double   uves_ech_groov[2] = {31.6e-6,  41.59e-6};  /* grooves/nm */
00278 /*double   uves_ech_blaze[2]  = {75.04, 75.9};  degrees */
00279 /*double   uves_ech_blaze[2]  = {74.74,  76.1};*/
00280 static double   uves_ech_blaze[2]  = {74.57, 75.9}; /* degrees */
00281 /*double   cdbeam[2]   = {45.336,  45.0};  degrees */
00282 /*double   cdbeam[2]   = {45.336,  45.9};*/
00283 /*double   cdbeam[2]   = {45.336,  45.0};  degrees */
00284 static double   cdbeam[2]   = {45.336,  46.0}; /* degrees */
00285 /*double   uves_ccd_rot[2]   = {0.7, -0.45};  degrees */
00286 /*double   uves_ccd_rot[2]   = {-1.0,  -1.50}; */
00287 /*double   uves_ccd_rot[2]   = {0.2, -0.45};   degrees */
00288 double   uves_ccd_rot[2]   = {0.3, -0.55};   /* degrees old */
00289 /* blue detector upgrade 2004-10-13 */
00290 /* double   uves_ccd_rot[2]   = {0.3, -0.10}; degrees  new */
00291 static int      imsize[2]   = {4096, 3000}; /* pixels */
00292 static int      uves_physmod_row_size[2]   = {2048, 2048}; /* pixels */
00293 
00294 /* Configurations 
00295    1:Blue CD1,     2:Blue CD2, 
00296    3:Red CD 3 EEV, 4:Red CD 4 EEV, 
00297    5:Red CD3 MIT,  6: Red CD4 MIT 
00298 */
00299 
00300 /* old */
00301 double uves_physmod_offsetx[6]={1391.0,1385.0,1852.0,1835.0,1852.0,1834.0};
00302 double uves_physmod_offsety[6]={1030.0,1025.0,2098.0,2104.0,-52.0,-49.0}; 
00303 
00304 /* blue detector upgrade 2004-10-13 */
00305 /* double uves_physmod_offsetx[6]={1355.0,1350.0,1852.0,1835.0,1852.0,1834.0}; new */
00306 /* double uves_physmod_offsety[6]={1030.0,1023.0,2098.0,2104.0,-52.0,-49.0}; new */
00307 
00308 static double   flipx       = 1.; 
00309 static double   flipy       = -1.;
00310 double   uves_airt        = 25;  /* Celsius */
00311 double   uves_airp        = 760; /* mmHg */
00312 double   uves_airw        = 3;   /* mmHg */
00313 
00314 int      uves_cfg_indx     = 0; 
00315 int      uves_x_disp_id     = 0;
00316 static int      uves_ech_id       = 0;
00317 double   uves_alpha0_cd, uves_beta0_cd;
00318 char     uves_arm_id       = 'x';
00319 
00320 static double   uves_deg2rad     = M_PI/180.;
00321 
00322 /* For history, please keep track HERE of the previous offset used: 
00323 Garching 1: 
00324 double uves_physmod_offsetx[6]={1470.0,1450.0,2130.0,2140.0,2130.0,2140.0}; 
00325 double uves_physmod_offsetx[6]={1515.0,1514.0,2010.0,2000.0,2010.0,2000.0};
00326  
00327 Comissioning 1: 
00328 double uves_physmod_offsetx[6]={1474.0,1471.0,1960.0,1948.0,1961.0,1949.0}; 
00329 
00330 Comissioning 2, Dec 2000:
00331 double uves_physmod_offsetx[6]={1390.0,1386.0,1849.0,1840.0,1854.0,1840.0};
00332  
00333 Paranal 2, Feb 2000: 
00334 double uves_physmod_offsetx[6]={1390.0,1384.0,1851.0,1840.0,1851.0,1839.0}; 
00335 
00336 Garching 1: 
00337 double uves_physmod_offsety[6]={1030.0,1030.0,2020.0,2020.0,-125.0,-115.0}; 
00338 double uves_physmod_offsety[6]={1029.0,1025.0,2072.0,2080.0,-74.0,-65.0}; 
00339 
00340 Comissioning 1: 
00341 double uves_physmod_offsety[6]={1027.0,1024.0,2069.0,2077.0,-74.0,-65.0};
00342 
00343 Comissioning 2, Dec 2000: 
00344 double uves_physmod_offsety[6]={1027.0,1025.0,2084.0,2094.0,-65.0,-54.0}; 
00345 
00346 Paranal 2, Feb 2000:
00347 double uves_physmod_offsety[6]={1030.0,1025.0,2088.0,2094.0,-57.0,-54.0}; 
00348 
00349 The gap between the EEV and MIT chips is estimated to 95 pixels */
00350 /*
00351 Mean pixel-scales for the 6 configurations: 
00352    pixscale : 0.252396, 0.246, 0.182, 0.175266, 0.182, 0.175266 */
00353  
00354 /*---------------------------------------------------------------------*/
00355 
00356 
00368 void 
00369 uves_physmod_set_incidence(double echred, 
00370                            double echblue, 
00371                            double xred, 
00372                            double xblue)
00373 {
00374      uves_ech_blaze[0] += echred;
00375      uves_ech_blaze[1] += echblue;
00376      cdbeam[0]  += xred;
00377      cdbeam[1]  += xblue;
00378      uves_msg_debug("uves_ech_blaze=%f,%f ccdbeam=%f,%f",
00379                    uves_ech_blaze[0],uves_ech_blaze[1],cdbeam[0],cdbeam[1]);
00380 }
00381 
00388 void 
00389 uves_set_ccd_rot(double* ccdrot, 
00390                  double uves_ccd_rot_off_red, 
00391                  double uves_ccd_rot_off_blue)
00392 {
00393   uves_ccd_rot[0] =ccdrot[0];
00394   uves_ccd_rot[1] =ccdrot[1];
00395 
00396   uves_ccd_rot[0] += uves_ccd_rot_off_red;
00397   uves_ccd_rot[1] += uves_ccd_rot_off_blue;
00398 
00399   uves_msg_debug("uves_ccd_rot[0,1]=%f,%f uves_ccd_rot_off: red,blue=%f,%f",
00400   uves_ccd_rot[0],uves_ccd_rot[1],uves_ccd_rot_off_red,uves_ccd_rot_off_blue);
00401 
00402 }
00403 
00413 void 
00414 uves_physmod_set_offset(double offset_x, 
00415                         double offset_y,
00416                         double uves_physmod_x_off, 
00417                         double yoff)
00418 {
00419   uves_physmod_offsetx[uves_cfg_indx-1]=offset_x;
00420   uves_physmod_offsety[uves_cfg_indx-1]=offset_y;
00421 /*
00422   uves_msg("offset_x=%f offset_y=%f",offset_x,offset_y);
00423      uves_msg("uves_physmod_offsetx=%f 
00424                uves_physmod_offsety=%f 
00425                uves_physmod_x_off=%f 
00426                yoff=%f",
00427            uves_physmod_offsetx[uves_cfg_indx-1],
00428                uves_physmod_offsety[uves_cfg_indx-1],
00429                uves_physmod_x_off,
00430                yoff);
00431 */
00432      uves_physmod_offsetx[uves_cfg_indx-1] += uves_physmod_x_off;
00433      uves_physmod_offsety[uves_cfg_indx-1] += yoff;
00434      /*
00435      uves_msg("uves_physmod_offsetx=%f 
00436                uves_physmod_offsety=%f 
00437                uves_physmod_x_off=%f 
00438                yoff=%f",
00439            uves_physmod_offsetx[uves_cfg_indx-1],
00440                uves_physmod_offsety[uves_cfg_indx-1],
00441                uves_physmod_x_off,
00442                yoff);
00443      */
00444 }
00445 
00446 
00453 void uves_physmod_set_binning(float binx, float biny)
00454 {
00455   uves_bin[0] = binx;
00456   uves_bin[1] = biny;
00457 }
00458 
00459 
00470 void uves_air_config(double p, double t, double w)
00471 {
00472     uves_airt = t;
00473     uves_airp = p;
00474     uves_airw = w;
00475     uves_msg_debug("uves_airt=%f uves_airp=%f uves_airw=%f",
00476                     uves_airt,uves_airp,uves_airw);
00477 }
00478 
00483 double uves_air_index(double lambda)
00484 {
00485    /* wavelength is expected in nanometers. */
00486    double t1, t2, t3, airdx;
00487  
00488    t1 = 1.0e-6/lambda/lambda;  /* 1e-6 for nm to um conversion, squared */
00489 
00490    t2 = (64.328+29498.1/(146.0-t1)+255.4/(41.0-t1))*uves_airp*
00491                (1.0+1.0e-6*(1.049-0.0157*uves_airt)*uves_airp)/
00492                (720.883*(1.0+0.003661*uves_airt));
00493 
00494    t3 = t2 - uves_airw*(0.0624 - 0.000680*t1)/(1+0.003661*uves_airt);
00495 
00496    airdx = 1.0+ t3*1.0e-6;
00497    /*   airdx = 1.0; */
00498    /*
00499    uves_msg_debug("uves_airt=%f uves_airp=%f uves_airw=%f",
00500                    uves_airt,uves_airp,uves_airw);
00501    uves_msg_debug("lambda=%f t1=%g t2=%g t3=%g airdx=%g",
00502                   lambda,t1,t2,t3,airdx);
00503    */
00504    return(airdx);
00505 }
00506 
00507 
00517 void 
00518 uves_physmod_find_alpha_beta(double lm, 
00519                              int m, 
00520                              double k, 
00521                              double theta, 
00522                              double *alpha, 
00523                              double *beta)
00524 {
00525 
00526  /* Solves sin(alpha) + sin(beta) = m*k*lm, given beta - alpha = theta */
00527  uves_msg_debug("lm, m, k, theta : %f %d %f %f",lm,m,k,theta);
00528 
00529  lm /= uves_air_index(lm);
00530 
00531  *alpha = 0.5* ( 2*asin( m*k*lm/2/cos(theta*uves_deg2rad/2) ) + 
00532                  theta*uves_deg2rad );
00533  *beta  = 0.5* ( 2*asin( m*k*lm/2/cos(theta*uves_deg2rad/2) ) - 
00534                  theta*uves_deg2rad );
00535  *alpha /= uves_deg2rad;
00536  *beta  /= uves_deg2rad;
00537 }
00538 
00554 int  
00555 uves_config(char uves_arm, 
00556             char uves_ccd_id, 
00557             int disp, 
00558             double waveCent, 
00559             float binx, 
00560             float biny)
00561 {
00562 
00563   int cfg = 0;
00564   uves_ech_id   = 2;
00565   uves_x_disp_id = disp;
00566   uves_arm_id   = uves_arm;
00567   
00568 /*  uves_msg("Configuring: 
00569               Arm %c 
00570               CCD %c  
00571               Xdisp %d 
00572               Wave %f",
00573               uves_arm,
00574               uves_ccd_id,
00575               disp,
00576               waveCent); 
00577 */
00578   uves_msg("Cfg: Arm %c CCD %c  Xdisp %d Wave %f",
00579                   uves_arm,uves_ccd_id,disp,waveCent);
00580 
00581   if (uves_arm == 'b' && disp == 1)  cfg = 1;
00582   if (uves_arm == 'b' && disp == 2)  cfg = 2;
00583 
00584   if (uves_arm == 'r' && disp == 3) {
00585           uves_ech_id  = 1;
00586           if (uves_ccd_id == 'e') cfg = 3;
00587           if (uves_ccd_id == 'm') cfg = 5;
00588   }
00589   if (uves_arm == 'r' && disp == 4) {
00590           uves_ech_id  = 1;
00591           if (uves_ccd_id == 'e') cfg = 4;
00592           if (uves_ccd_id == 'm') cfg = 6;
00593   }
00594 
00595   if (cfg == 0) {
00596     cpl_msg_error(__func__,"Wrong configuration!");
00597     return -1;
00598   }
00599 
00600   uves_cfg_indx = cfg;
00601 
00602   (void) uves_physmod_set_binning(binx, biny);
00603   (void) uves_physmod_find_alpha_beta(waveCent, 1, cdgroov[uves_x_disp_id-1], 
00604                      cdbeam[uves_ech_id-1], &uves_alpha0_cd, &uves_beta0_cd); 
00605 
00606 
00607   uves_msg("alpha, beta for Xdisp: %f %f\nin config %d and CCD-ID %c",
00608                  uves_alpha0_cd, uves_beta0_cd,cfg, uves_ccd_id);
00609   
00610   return(cfg);
00611 
00612 }
00622 int  
00623 uves_config_cpl_new(int uves_arm,
00624                     int upper, 
00625                     int disp, 
00626                     double waveCent, 
00627                     float binx, 
00628                     float biny)
00629 {
00630   int cfg = 0;
00631   uves_ech_id   = 2;
00632   uves_x_disp_id = disp;
00633   
00634 /*  uves_msg("Configuring: 
00635               Arm %c 
00636               CCD %c  
00637               Xdisp %d 
00638               Wave %f",
00639               uves_arm,
00640               uves_ccd_id,
00641               disp,
00642               waveCent); 
00643 */
00644   uves_msg("New Cfg: Arm [b/r] %d CCD eev/mit %d  Xdisp %d Wave %f",
00645                   uves_arm,upper,disp,waveCent);
00646 
00647   if (uves_arm == ARM_BLUE && disp == 1)  cfg = 1;
00648   if (uves_arm == ARM_BLUE && disp == 2)  cfg = 2;
00649 
00650   if (uves_arm == ARM_RED && disp == 3) {
00651           uves_ech_id  = 1;
00652           if (upper == 0) cfg = 3;
00653           if (upper == 1) cfg = 5;
00654   }
00655   if (uves_arm == ARM_RED && disp == 4) {
00656           uves_ech_id  = 1;
00657           if (upper == 0) cfg = 4;
00658           if (upper == 1) cfg = 6;
00659   }
00660 
00661   if (cfg == 0) {
00662     cpl_msg_error(__func__,"Wrong configuration!");
00663     return -1;
00664   }
00665 
00666   uves_cfg_indx = cfg;
00667 
00668   (void) uves_physmod_set_binning(binx, biny);
00669   (void) uves_physmod_find_alpha_beta(waveCent, 1, cdgroov[uves_x_disp_id-1], 
00670                     cdbeam[uves_ech_id-1], &uves_alpha0_cd, &uves_beta0_cd); 
00671 
00672  
00673   uves_msg("alpha, beta for Xdisp: %f %f\nin config %d and CCD-ID %c",
00674        uves_alpha0_cd, uves_beta0_cd,cfg, upper == 0 ? 'e' : 'm');
00675  
00676   return(cfg);
00677 
00678 }
00679 
00698 int  
00699 uves_config_cpl(int blue, 
00700                 int upper, 
00701                 int disp, 
00702                 double waveCent, 
00703                 float binx, 
00704                 float biny)
00705 {
00706 
00707 
00708   int cfg = 0;
00709   uves_ech_id   = 2;
00710   uves_x_disp_id = disp;
00711   
00712 /*  uves_msg("Configuring: 
00713               Arm %c 
00714               CCD %c  
00715               Xdisp %d 
00716               Wave %f",
00717               uves_arm,
00718               uves_ccd_id,
00719               disp,
00720               waveCent); 
00721 */
00722   uves_msg("Cfg cpl: Arm [b/r] %d CCD eev/mit %d  Xdisp %d Wave %f",
00723                   blue,upper,disp,waveCent);
00724 
00725   if (blue == 1 && disp == 1)  cfg = 1;
00726   if (blue == 1 && disp == 2)  cfg = 2;
00727 
00728   if (blue == 0 && disp == 3) {
00729           uves_ech_id  = 1;
00730           if (upper == 0) cfg = 3;
00731           if (upper == 1) cfg = 5;
00732   }
00733   if (blue == 0 && disp == 4) {
00734           uves_ech_id  = 1;
00735           if (upper == 0) cfg = 4;
00736           if (upper == 1) cfg = 6;
00737   }
00738 
00739   if (cfg == 0) {
00740     uves_msg_error("Wrong configuration!");
00741     return -1;
00742   }
00743 
00744   uves_cfg_indx = cfg;
00745 
00746   (void) uves_physmod_set_binning(binx, biny);
00747   (void) uves_physmod_find_alpha_beta(waveCent, 1, cdgroov[uves_x_disp_id-1], 
00748                     cdbeam[uves_ech_id-1], &uves_alpha0_cd, &uves_beta0_cd); 
00749 
00750   
00751   uves_msg("alpha, beta for Xdisp: %f %f\nin config %d and CCD-ID %c",
00752          uves_alpha0_cd, uves_beta0_cd,cfg, upper == 0 ? 'e': 'u');
00753  
00754   return(cfg);
00755 
00756 }
00757 
00777 double cameraFocal(double lm)
00778 
00779 {
00780    double nfk=0.;
00781    /*uves_msg("lm = %f ", lm);*/
00782    /* uves_msg_debug("lm=%g uves_air_index(lm)=%g",lm,uves_air_index(lm)); */
00783 
00784    lm /= uves_air_index(lm);
00785    /* uves_msg_debug("uves_arm=%d",uves_arm_ident); */
00786    if (uves_arm_id == 'b' ) { 
00787      /* uves_msg_debug("uves_arm blue"); */
00788     nfk=5.3961886e-7*lm*lm*lm-0.00079597882*lm*lm+0.41122805*lm+287.89644;
00789    }
00790 
00791    if (uves_arm_id == 'r' ) { 
00792      /* uves_msg_debug("uves_arm red"); */
00793     nfk=6.0172051e-13*lm*lm*lm*lm*lm-2.5623231e-9*lm*lm*lm*lm+
00794         4.3585543e-6*lm*lm*lm -0.0037286381*lm*lm+
00795         1.6289971*lm + 210.06767;
00796 
00797    }
00798    /*  uves_msg_debug("lm=%g nfk=%g",lm,nfk); */
00799 
00800  /*uves_msg("Nfk = %f, lm = %f",nfk/1000.,lm); */
00801 return(nfk/1000.);
00802 
00803 }
00804 
00805 
00811 int uves_physmod_find_order(double lm)
00812 {
00813   int order;
00814   double k, alpha, beta;
00815 
00816   lm /= uves_air_index(lm);
00817 
00818   k     = uves_ech_groov[uves_ech_id-1];
00819   alpha = uves_ech_blaze[uves_ech_id-1];
00820   beta  = uves_ech_blaze[uves_ech_id-1];
00821   order = (int)((sin(alpha*uves_deg2rad) + sin(beta*uves_deg2rad))/k/lm + 0.5);
00822   /*
00823   uves_msg_debug("uves_ech_id=%d lm %g airindex %g k=%g alpha=%g beta=%g 
00824            order=%d",uves_ech_id,lm,uves_air_index(lm),k,alpha,beta,order);
00825   */
00826   return order;
00827 }
00828 
00836 double uves_physmod_find_order_lambda(double k, double alpha, double beta)
00837 {
00838   double ML;
00839   ML =  ( ( sin(alpha*uves_deg2rad) + sin(beta*uves_deg2rad) )/k);
00840   ML *= uves_air_index(ML);
00841   return(ML);
00842 }
00843 
00844 
00851 double uves_physmod_find_lambda(double k, double alpha, double beta)
00852 {
00853   double L;
00854   L = (sin(alpha*uves_deg2rad) + sin(beta*uves_deg2rad) )/k ;
00855   L *= uves_air_index(L);
00856   return(L);
00857 }
00858 
00866 double uves_physmod_find_beta(int m, double k, double l, double alpha)
00867 {
00868    /* uves_msg ("m, k, l, alpha: %d %f %f %f",m, k, l, alpha); */
00869  
00870   l /= uves_air_index(l);
00871   
00872   /*  I check that the argument of asin is <=0 otherwhise return
00873       a dummy angle (~89 deg) which will produce (x,y) pos out
00874       of detector so the line will be discarted
00875    */
00876   /*
00877   uves_msg_debug("l=%g m*k*l=%g alpha=%g",l,m*k*l,alpha);
00878   */
00879   if ( (m*k*l - sin(alpha*uves_deg2rad)) <=1.0 )
00880   {
00881      return( (asin(m*k*l - sin(alpha*uves_deg2rad)))/uves_deg2rad );
00882   }
00883   else
00884   {
00885      return( (asin(0.999))/uves_deg2rad );
00886   }
00887 }
00888 
00897 void 
00898 uves_physmod_lambda_order2beta(double lambda, 
00899                                int m, 
00900                                double* puves_beta_ech, 
00901                                double* puves_beta_cd, 
00902                                double* pfc)
00903 {
00904     /* uves_msg ("Disp: %d Ech: %d",uves_x_disp_id,uves_ech_id-1); */
00905 
00906 /*   lambda /= uves_air_index(lambda);  bog fixed ! */
00907    
00908    *pfc       = cameraFocal(lambda);
00909 
00910     /* uves_msg ("New Camera focal (m) : %f",fc); */
00911 
00912    *puves_beta_ech = uves_physmod_find_beta(m, uves_ech_groov[uves_ech_id-1], 
00913                      lambda, uves_ech_blaze[uves_ech_id-1]);
00914 
00915    *puves_beta_cd  = uves_physmod_find_beta(1, cdgroov[uves_x_disp_id-1], 
00916                      lambda, uves_alpha0_cd); 
00917    /* uves_msg_debug("fc=%g uves_beta_ech=%g uves_beta_cd=%g"
00918       ,*pfc,*puves_beta_ech,*puves_beta_cd); */
00919 
00920 }
00921 
00930 void 
00931 uves_beta2xy(double uves_beta_cd, 
00932              double uves_beta_ech, 
00933              double fc, 
00934              double* px, 
00935              double* py)
00936 {
00937    double  xd, yd, xr, yr, angle;   
00938     
00939    xd       = fc*tan( (uves_beta_ech - uves_ech_blaze[uves_ech_id-1])*
00940                        uves_deg2rad )/
00941                        uves_physmod_pix_size[0]/uves_bin[0];    
00942    yd       = fc*tan( (uves_alpha0_cd - uves_beta_cd - 
00943                        cdbeam[uves_ech_id-1])*uves_deg2rad )/
00944                        uves_physmod_pix_size[1]/uves_bin[1];
00945 
00946    //CHECK
00947    uves_msg_debug("beta(CD), yorg: %f %f", uves_beta_cd, yd); 
00948 
00949    xd = xd*flipx;
00950    yd = yd*flipy;   
00951    uves_msg_debug ("Positions after flip: %f %f",xd,yd); 
00952     
00953    angle    = uves_ccd_rot[uves_ech_id-1]*uves_deg2rad;
00954    xr       =  xd*cos(angle) + yd*sin(angle);
00955    yr       = -xd*sin(angle) + yd*cos(angle);
00956 
00957    uves_msg_debug ("Rotated positions %f %f",xr,yr);
00958 
00959    *px = uves_physmod_offsetx[uves_cfg_indx-1] / uves_bin[0] + xr;
00960    *py = uves_physmod_offsety[uves_cfg_indx-1] / uves_bin[1] + yr;
00961     
00962 
00963 }
00964 
00975 void 
00976 uves_physmod_photo_beta(double lambda, 
00977                         double uves_beta_ech, 
00978                         double uves_beta_cd, 
00979                         double* puves_physmod_rech, 
00980                         double* puves_physmod_rcd, 
00981                         double* pblz)
00982 {
00983    double gam;
00984    /*
00985    uves_msg("uves_ech_id = %d, uves_ech_blaze = %f",
00986              uves_ech_id,uves_ech_blaze[uves_ech_id-1]); 
00987    uves_msg("uves_deg2rad=%f uves_beta_ech=%f uves_alpha0_cd=%f",
00988              uves_deg2rad,uves_beta_ech,uves_alpha0_cd); 
00989    */
00990    *puves_physmod_rech = cos(uves_ech_blaze[uves_ech_id-1]*uves_deg2rad)/
00991                          cos(uves_beta_ech*uves_deg2rad);
00992    
00993    *puves_physmod_rcd = cos(uves_alpha0_cd*uves_deg2rad)/
00994                         cos(uves_beta_cd*uves_deg2rad);
00995    /*
00996    uves_msg("puves_physmod_rech=%f *puves_physmod_rcd=%f",
00997              *puves_physmod_rech,*puves_physmod_rcd);
00998    */
00999    /* Computes the blaze function */
01000    gam = M_PI / uves_ech_groov[uves_ech_id-1] * 
01001                 cos(delta[uves_ech_id-1]*uves_deg2rad) * 
01002          (sin((uves_beta_ech-delta[uves_ech_id-1])*uves_deg2rad)-
01003           sin((uves_ech_blaze[uves_ech_id-1]-delta[uves_ech_id-1])*
01004               uves_deg2rad))
01005      / lambda/ uves_air_index(lambda);
01006    *pblz = DSQR(sin(gam)/gam);
01007    /*
01008    uves_msg("gamma = %f, Blaze function = %g ",gam,blz); 
01009    */  
01010 }
01011 
01035 void uves_physmod_pixscl(
01036                          double wave, 
01037                          int order, 
01038                          double uves_physmod_rech, 
01039                          double uves_physmod_rcd, 
01040                          float binx, 
01041                          float biny, 
01042                          double fc, 
01043                          double slitwidth, 
01044                          double slitlength,
01045                          double* pbinsize, 
01046                          double* ppixscale, 
01047                          double* ppixscalCD, 
01048                      double* plinewidpx, 
01049                          double* plinelenpx, 
01050                          double* plinewidth, 
01051                          double* presol)
01052 {
01053    double binsize, pixscale, pixscalCD, linewidpx, linelenpx, linewidth, resol;
01054    static double scale;
01055 
01056    if (!(scale)) scale = (206265.0*15.0*0.015*200*1e-3*binx)/120000;
01057 
01058    /*
01059    uves_msg("scale=%f 
01060              wave=%f 
01061              order=%d 
01062              fc=%f 
01063              uves_physmod_rech=%f 
01064              binx=%f 
01065              biny=%f 
01066              uves_physmod_rcd=%f",
01067          scale,    
01068              wave,   
01069              order,   
01070              fc,   
01071              uves_physmod_rech,   
01072              binx,   
01073              biny,   
01074              uves_physmod_rcd);
01075    */
01076 /* Computes the width (in pixel and A) and resolution lines */
01077    binsize = uves_physmod_wave_bin(wave, order) * 1e4;  /* in mA */
01078    pixscale = scale/(fc*uves_physmod_rech); /* in arcsec/pixel */
01079    pixscalCD = pixscale *(biny/binx) *uves_physmod_rech/uves_physmod_rcd; /* in arcsec/pixel */ 
01080    linewidpx = slitwidth / pixscale;  /* pixel */
01081    linelenpx = slitlength /pixscalCD;  /* pixel */    
01082    linewidth = binsize * linewidpx * 1e-3; /* in A (* pixel) */
01083    resol = wave * 10.0 / linewidth;  /* without unit */
01084                               /* (10.0: conversion factor from nm to A)*/
01085 
01086    /*
01087    uves_msg("slitwidth=%f slitlength=%f binsize=%f pixscale=%f pixscaleCD=%f",
01088       slitwidth,   slitlength,   binsize,   pixscale,   pixscalCD);
01089 
01090    uves_msg("linewidpx=%f linewidth=%f resol=%f",
01091       linewidpx,    linewidth,   resol);
01092    */
01093    *pbinsize = binsize;
01094    *ppixscale = pixscale;
01095    *ppixscalCD = pixscalCD;
01096    *plinewidpx = linewidpx;
01097    *plinelenpx = linelenpx;
01098    *plinewidth = linewidth;
01099    *presol = resol;
01100 
01101 }
01102 
01110 void 
01111 uves_physmod_xy_model(double lambda, int m, double* px, double* py)
01112 {
01113    double fc, uves_beta_ech, uves_beta_cd;
01114    //CHECK
01115    uves_physmod_lambda_order2beta(lambda, m, &uves_beta_ech, &uves_beta_cd, &fc);
01116    uves_msg_debug("lambda=%f m=%d uves_beta_ech=%f,uves_beta_cd=%f,fc=%f",
01117             lambda,m,uves_beta_ech,uves_beta_cd,fc);
01118 
01119    uves_beta2xy(uves_beta_cd, uves_beta_ech, fc, px, py);
01120    uves_msg_debug("px=%f py=%f",*px,*py);
01121 
01122 /* exemple : 
01123    uves_physmod_photo_beta(lambda, uves_beta_ech, uves_beta_cd, 
01124                            puves_physmod_rech, puves_physmod_rcd, pblz); 
01125 */
01126 
01127 }
01128 
01137 void 
01138 uves_physmod_xy2beta(double* puves_beta_ech, 
01139                      double* puves_beta_cd, 
01140                      double fc, 
01141                      double x, 
01142                      double y)
01143 {
01144    double xr, yr, xd, yd, angle;
01145 
01146    angle    = uves_ccd_rot[uves_ech_id-1]*uves_deg2rad;
01147 
01148    xr = (x - uves_physmod_offsetx[uves_cfg_indx-1]/uves_bin[0]);
01149    yr = (y - uves_physmod_offsety[uves_cfg_indx-1]/uves_bin[1]);
01150 
01151    xd = xr*cos(angle) - yr*sin(angle);
01152    yd = xr*sin(angle) + yr*cos(angle);
01153 
01154    xd  /= flipx;
01155    yd  /= flipy;
01156 
01157    *puves_beta_ech = atan(xd*uves_physmod_pix_size[0]*uves_bin[0]/fc)/
01158                          uves_deg2rad + uves_ech_blaze[uves_ech_id-1];
01159    *puves_beta_cd  =  uves_alpha0_cd - cdbeam[uves_ech_id-1] - 
01160                       atan(yd*uves_physmod_pix_size[1]*uves_bin[1]/fc)/
01161                       uves_deg2rad; 
01162 
01163 }
01164 
01173 static void 
01174 beta2lamb(double uves_beta_ech, 
01175           double uves_beta_cd, 
01176           double* plambda, 
01177           int m)
01178 {
01179   uves_beta_cd=uves_beta_cd;
01180    *plambda = uves_physmod_find_lambda(m*uves_ech_groov[uves_ech_id-1], 
01181               uves_ech_blaze[uves_ech_id-1], uves_beta_ech);
01182 
01183 }
01184 
01197 void 
01198 uves_physmod_lambda_order_focus_model(double* plambda, 
01199                                       double* pdm, 
01200                                       double fc, 
01201                                       double x, 
01202                                       double y)
01203 {
01204 
01205    double uves_beta_ech, uves_beta_cd;
01206    
01207    uves_physmod_xy2beta(&uves_beta_ech, &uves_beta_cd, fc, x, y);
01208    
01209    *plambda = uves_physmod_find_order_lambda(cdgroov[uves_x_disp_id-1], 
01210                uves_alpha0_cd, uves_beta_cd);
01211    *pdm      = uves_physmod_find_order_lambda(uves_ech_groov[uves_ech_id-1], 
01212                 uves_ech_blaze[uves_ech_id-1], uves_beta_ech)/(*plambda);
01213 /*
01214    uves_msg("  m= %f, lambda= %f, position (x,y)= (%f , %f)",
01215             *pdm,*plambda, x,y);
01216 */
01217 }
01218 
01219 /************************************************************************* 
01220  *  Finds the couple lambda,m corresponding to a given position (x,y),
01221  *  assuming the focal of the camera for this wavelength is fc. 
01222  *************************************************************************
01223  */
01224 /* Not used:
01225 void 
01226 uves_physmod_lambda_model(double* plambda, 
01227                           int m, 
01228                           double fc, 
01229                           double x, 
01230                           double y)
01231 {
01232 
01233    double uves_beta_ech, uves_beta_cd;
01234 
01235    uves_physmod_xy2beta(&uves_beta_ech, &uves_beta_cd, fc, x, y);
01236 
01237 
01238    beta2lamb(uves_beta_ech, uves_beta_cd, plambda, m);
01239 
01240 }
01241 */
01242 
01257 void 
01258 uves_physmod_lambda_order_beta(double* plambda, 
01259                                int* pm, 
01260                                double x, 
01261                                double y, 
01262                                double* puves_beta_ech, 
01263                                double* puves_beta_cd)
01264 {
01265 
01266 double fcguess=0., wave=0., mdbl=0., xe=0., ye=0., xd=0., yd=0.;
01267 int  i=0;
01268 
01269 if (uves_arm_id == 'b') fcguess = 0.360;/*0.35722;*/
01270 if (uves_arm_id == 'r') fcguess = 0.500;
01271 
01272 uves_physmod_lambda_order_focus_model(&wave,&mdbl,fcguess,x,y);
01273 /*
01274 if (x == 1500.) {
01275   uves_msg("m= %f, lambda= %f, position (x,y)= (%f , %f)",mdbl,wave, x,y);
01276     uves_msg("focal guess= %f",fcguess);
01277 }
01278 */
01279 do {
01280    
01281    fcguess = cameraFocal(wave);
01282    /*
01283      if (x == 1500.) { 
01284        uves_msg("i= %d, focal = %f, m= %f, lambda= %f", i,fcguess,mdbl,wave);
01285      }
01286    */
01287    if (*pm <= 0) *pm = (int)(mdbl+0.5);
01288 /*   uves_physmod_lambda_model(&wave,*pm,fcguess,x,y); */
01289    uves_physmod_xy2beta(puves_beta_ech, puves_beta_cd, fcguess, x, y);
01290    beta2lamb(*puves_beta_ech, *puves_beta_cd, &wave, *pm);
01291 
01292    /*
01293      if (x == 1500.) { 
01294        uves_msg("i= %d, focal = %f, m= %d, lambda= %f", i,fcguess,*pm,wave);
01295      }
01296    */
01297    
01298    uves_physmod_xy_model(wave,(int)(mdbl+0.5), &xe, &ye);
01299    /*
01300       if (x == 1500.) { 
01301         uves_msg("m= %f, lambda= %f, position (xe,ye)= (%f , %f)",
01302                   mdbl,wave, xe,ye);
01303         uves_msg("focal = %f",fcguess);
01304       }
01305    */
01306    i++;
01307    
01308    xd = fabs(x-xe);
01309    yd = fabs(y-ye);
01310    
01311    } while (!((xd < 1.) && (yd < 1.)) && (i <= 4));
01312 
01313 *plambda = wave;
01314 
01315 /*uves_msg("i= %d", i);*/
01316 /* uves_physmod_photo_beta(wave, *puves_beta_ech, *puves_beta_cd, 
01317                  puves_physmod_rech, puves_physmod_rcd, pblz); 
01318 uves_msg("uves_physmod_lambda_order_beta(%f, %d, %f, %f, %f, %f)",
01319           wave, *pm, x, y, *puves_beta_ech, *puves_beta_cd);
01320 */
01321 
01322 }
01323 
01337 void 
01338 uves_physmod_lambda_order_model(double* plambda, int* pm, double x, double y)
01339 {
01340 
01341   double uves_beta_ech, uves_beta_cd;
01342   
01343   uves_physmod_lambda_order_beta(plambda, pm, x, y, 
01344                                  &uves_beta_ech, &uves_beta_cd);
01345   
01346 /* exemple : 
01347   uves_physmod_photo_beta(*plambda, &uves_beta_ech, &uves_beta_cd, 
01348                    puves_physmod_rech, puves_physmod_rcd, pblz); 
01349 
01350 uves_msg("uves_physmod_lambda_order_beta(%f, %d, %f, %f, %f, %f)",
01351          *plambda, *pm, x, y, uves_beta_ech, uves_beta_cd);
01352 */
01353 }
01354 
01363 void 
01364 uves_physmod_find_FSR(int m, double* lambdaC, double* fsrStart, double* fsrEnd)
01365 {
01366 
01367   double tmp_delta;
01368 
01369   *lambdaC = 2*sin(uves_ech_blaze[uves_ech_id-1]*uves_deg2rad)/
01370                    m/uves_ech_groov[uves_ech_id-1];
01371 
01372   tmp_delta = *lambdaC/m;
01373 
01374   *fsrStart = *lambdaC - tmp_delta/2.;
01375   *fsrEnd   = *lambdaC + tmp_delta/2.;
01376 
01377 }
01378 
01384 double uves_physmod_wave_bin(double l, int m)
01385 {
01386 
01387   double dl, x0,y_0,x1,y_1;
01388 
01389   dl = 20e-4; /* Wavelength increment in nm (nearly one pixel)*/
01390 
01391   uves_physmod_xy_model( l,    m,&x0,&y_0);
01392   uves_physmod_xy_model((l+dl),m,&x1,&y_1);
01393 
01394   return( dl/(x1-x0) );
01395 }
01396 
01402 void uves_ccd_size(int* nx, int* ny)
01403 {
01404   /*
01405   uves_msg("imsize[uves_ech_id-1]=%d 
01406             uves_physmod_row_size[uves_ech_id-1]=%d 
01407             uves_bin[0]=%f uves_bin[1]=%f",
01408         imsize[uves_ech_id-1],   
01409             uves_physmod_row_size[uves_ech_id-1],   
01410             uves_bin[0],   
01411             uves_bin[1]);
01412   */
01413   *nx = imsize[uves_ech_id-1] / uves_bin[0];
01414   *ny = uves_physmod_row_size[uves_ech_id-1] / uves_bin[1];
01415 }
01416 
01427 void uves_physmod_xy_regres(double x,double y,double* px,double* py)
01428 {
01429   double xdiff=0;
01430   double ydiff=0;
01431   int    xnpix=0;
01432   int    ynpix=0;
01433   
01434   goto simplified;
01435   /*  We comment the following to remove a compilation warning
01436       Anyway the code would not be executed due to goto statement      
01437   xdiff = xcoef[uves_cfg_indx-1][8]*DSQR(x*y) + 
01438           xcoef[uves_cfg_indx-1][7]*x*DSQR(y) + 
01439           xcoef[uves_cfg_indx-1][6]*DSQR(y)   + 
01440           xcoef[uves_cfg_indx-1][5]*DSQR(x)*y + 
01441           xcoef[uves_cfg_indx-1][4]*x*y       + 
01442           xcoef[uves_cfg_indx-1][3]*y         + 
01443           xcoef[uves_cfg_indx-1][2]*DSQR(x)   + 
01444           xcoef[uves_cfg_indx-1][1]*x         + 
01445           xcoef[uves_cfg_indx-1][0];
01446 
01447   ydiff = ycoef[uves_cfg_indx-1][8]*DSQR(x*y) + 
01448           ycoef[uves_cfg_indx-1][7]*x*DSQR(y) + 
01449           ycoef[uves_cfg_indx-1][6]*DSQR(y)   + 
01450           ycoef[uves_cfg_indx-1][5]*DSQR(x)*y + 
01451           ycoef[uves_cfg_indx-1][4]*x*y       + 
01452           ycoef[uves_cfg_indx-1][3]*y         + 
01453           ycoef[uves_cfg_indx-1][2]*DSQR(x)   + 
01454           ycoef[uves_cfg_indx-1][1]*x         + 
01455           ycoef[uves_cfg_indx-1][0];
01456   */
01457   
01458   /* New, simplified correction */ 
01459   simplified: {
01460   uves_ccd_size(&xnpix, &ynpix);
01461   /* uves_msg("xnpix=%d ynpix=%d",xnpix,ynpix); */
01462   xdiff = (-7.)*(x-(double)xnpix/2.)/((double)xnpix/2.);
01463   /* ydiff = (5.)*pow((x-(double)xnpix/2.)/((double)xnpix/2.),2.); */
01464   ydiff = (5.)*DSQR((x-(double)xnpix/2.)/((double)xnpix/2.));
01465   /* uves_msg("xdiff=%f ydiff=%f",xdiff,ydiff); */
01466   *px = x + xdiff;
01467   *py = y + ydiff;
01468   }
01469 }
01470 

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