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

Generated on Fri Apr 18 14:11:42 2008 for UVES Pipeline Reference Manual by  doxygen 1.5.1