Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

extract/lib/proc_config.c

Go to the documentation of this file.
00001 /* === Doxygen Comment ======================================= */
00017 /* =========================================================== */
00018 
00019 #include <IFU_io.h>
00020 #include <IFU_math.h>
00021 #include <snifs.h>
00022 #include <snifs_materials.h>
00023 #include <extract.h>
00024 #include <ctype.h>         /* read_channel and read_focus toupper() */
00025 
00026 /* === Doxygen Comment ======================================= */
00030 /* =========================================================== */
00031 
00032 float read_lbdaref(void *anyfile) 
00033 {
00034   float lbdaref;
00035   
00036   if (DEBUG)
00037     print_msg("Reading ref. wavelength from descriptor %s in file %s...",
00038               MPUP_LBDAPUP,((Anyfile *)anyfile)->name);
00039 
00040   disable_user_warnings();
00041   if (RD_desc(anyfile,MPUP_LBDAPUP,FLOAT,1,&lbdaref) != 1) {
00042     print_error("Cannot read descriptor %s in file %s",
00043                 MPUP_LBDAPUP,((Anyfile *)anyfile)->name);
00044     lbdaref = 0;
00045   }
00046   else
00047     print_msg("   Ref. wavelength: %.1f AA",lbdaref);
00048   restore_user_warnings();
00049 
00050   return(lbdaref);
00051 }
00052 
00053 /* === Doxygen Comment ======================================= */
00057 /* =========================================================== */
00058 
00059 Channel read_channel(void *anyfile) 
00060 {
00061   Channel channel;
00062   char name[lg_ident+1];
00063   
00064   if (DEBUG) 
00065     print_msg("Reading channel from descriptor %s in file %s...",
00066               CHANNEL,((Anyfile *)anyfile)->name);
00067 
00068   /* Read string descriptor */
00069   disable_user_warnings();
00070   if (RD_desc(anyfile,CHANNEL,CHAR,lg_ident+1,&name) <= 0) {
00071     print_warning("Cannot read descriptor %s in file %s",
00072                   CHANNEL,((Anyfile *)anyfile)->name);
00073     return(UNKNOWN_CHANNEL);
00074   }
00075   restore_user_warnings();
00076 
00077   /* Decipher descriptor */
00078   switch (toupper(name[0])) {
00079   case '1':                                  /* Back compatibility */
00080   case 'B': channel = BLUE_CHANNEL;    break;
00081   case '2':                                  /* Back compatibility */
00082   case 'R': channel = RED_CHANNEL;     break;
00083   default:  
00084     print_warning("Channel '%s' does not match any channel",name);
00085     return(UNKNOWN_CHANNEL);
00086     break;
00087   }
00088   print_msg("   Channel: '%s' [identified as %s]",name,channel_names[channel]);
00089 
00090   return(channel);
00091 }
00092 
00093 /* === Doxygen Comment ======================================= */
00103 /* =========================================================== */
00104 
00105 int read_focus(void *anyfile) 
00106 {
00107   static int narc=1;                      /* Frame rank in calling sequence */
00108 
00109   Channel channel;
00110   char focdesc[9];
00111   int specfoc;
00112   
00113   /* Read spectrograph position in descriptor */
00114   channel = read_channel(anyfile);
00115   sprintf(focdesc,"%c%s",toupper(channel_names[channel][0]),SPECFOC);
00116 
00117   disable_user_warnings();
00118   if (channel == UNKNOWN_CHANNEL ||
00119       RD_desc(anyfile,focdesc,INT,1,&specfoc) < 0) {
00120     specfoc = -narc;
00121     print_warning("%s descriptor absent from frame #%d %s",
00122                   focdesc,ABS(specfoc),((Anyfile *)anyfile)->name);
00123   } 
00124   else print_msg("   Focus [%s]: %d",focdesc,specfoc);
00125   restore_user_warnings();
00126 
00127   narc ++;
00128   return(specfoc);
00129 }
00130 
00131 /* === Doxygen Comment ======================================= */
00160 /* =========================================================== */
00161 
00162 int read_default_snifs_config(const Channel channel, SnifsConfig *config) 
00163 {
00164   float l1, l2, l1u, l2u;
00165 
00166   SnifsOptics   *Optics = &(config->optics);
00167   Telescope     *UHT    = &(config->telescope);
00168   SnifsDetector *CCD    = &(config->ccd);
00169 
00170   print_msg("Reading default configuration for %s channel...", 
00171             channel_names[channel]);
00172 
00173   /* ===== Channel-independant settings ============================== */
00174 
00175   /* ----- Optics ------------------------------ */
00176 
00177   /* Channel */
00178   Optics->channel = channel;
00179 
00180   /* Enlarger */
00181   Optics->enlarger.gamma = SNIFS_GAMMA;
00182 
00183   /* Grism */
00184   Optics->grism.set   = 1;  
00185   Optics->grism.tiltx = 0.;
00186   Optics->grism.tilty = 0.;
00187   Optics->grism.rotz  = 0.; /* Red is down, blue is up */
00188 
00189   /* MLA */
00190   Optics->MLA.size = SNIFS_LENS_MM;
00191 
00192   /* ----- Telescope ------------------------------ */
00193 
00194   UHT->aperture            = UHT_DIAM;
00195   UHT->central_obscuration = UHT_COBS; 
00196   UHT->fratio              = UHT_FOCR;
00197   UHT->scale               = UHT_SCALE;
00198 
00199   /* ===== Channel-specific settings ============================== */
00200 
00201   switch (channel) {
00202   case BLUE_CHANNEL:
00203     /* Configuration name */
00204     strcpy(config->name,DFLT_BLU_CFG_NAME);
00205 
00206     /* ----- Optics ------------------------------ */
00207 
00208     /* Collimator */
00209     Optics->collimator.focal                = SNIFSB_COLL_F;
00210     Optics->collimator.distor               = SNIFSB_COLL_E;
00211     Optics->collimator.LateralColor.coef[0] = SNIFSB_COLL_A1;
00212     Optics->collimator.LateralColor.coef[1] = SNIFSB_COLL_A2;
00213     Optics->collimator.LateralColor.coef[2] = SNIFSB_COLL_A3;
00214     Optics->collimator.LateralColor.lbdaref = SNIFSB_LBDA_REF;
00215 
00216     /* Grism */
00217     Optics->grism.prism.id   = SNIFSB_GRISM_GLA;
00218     Optics->grism.A          = SNIFSB_GRISM_ANG * M_PI/180.;
00219     Optics->grism.grating.id = SNIFSB_GRISM_RES;
00220     Optics->grism.g_per_mm   = SNIFSB_GRISM_GRA; 
00221     Optics->grism.blaze      = SNIFSB_GRISM_BLA * M_PI/180.;
00222     Optics->grism.w_disp     = SNIFSB_GRISM_D / (CCDB_PIX/1000.); /* AA/mm */
00223 
00224     /* Camera parameters */
00225     Optics->camera.focal                = SNIFSB_CAM_F;
00226     Optics->camera.distor               = SNIFSB_CAM_E;
00227     Optics->camera.LateralColor.coef[0] = SNIFSB_CAM_A1;
00228     Optics->camera.LateralColor.coef[1] = SNIFSB_CAM_A2;
00229     Optics->camera.LateralColor.coef[2] = SNIFSB_CAM_A3;
00230     Optics->camera.LateralColor.lbdaref = SNIFSB_LBDA_REF;
00231 
00232     /* MLA */
00233     Optics->MLA.sizepix = SNIFSB_LENS_PX;
00234     Optics->MLA.angle   = SNIFSB_LENS_AN * M_PI/180.;
00235 
00236     /* Filter */
00237     l1  = SNIFSB_FILT_L; l2  = SNIFSB_FILT_H; /* Total coverage  */
00238     l1u = SNIFSB_FILT_S; l2u = SNIFSB_FILT_E; /* Useful coverage */
00239 
00240     /* ----- Detector ------------------------------ */
00241 
00242     strcpy(CCD->name, CCDB_NAME);
00243     CCD->pixsize = CCDB_PIX; /* in microns */
00244     CCD->gain    = CCDB_GAIN;
00245     CCD->ron     = CCDB_RON;
00246     CCD->dark    = 0.;
00247     CCD->nx      = CCDB_NX;
00248     CCD->ny      = CCDB_NY;
00249 
00250     break;
00251 
00252   case RED_CHANNEL:
00253     /* Configuration name */
00254     strcpy(config->name,DFLT_RED_CFG_NAME);
00255 
00256     /* ----- Optics ------------------------------ */
00257 
00258     /* Collimator */
00259     Optics->collimator.focal                = SNIFSR_COLL_F;
00260     Optics->collimator.distor               = SNIFSR_COLL_E;
00261     Optics->collimator.LateralColor.coef[0] = SNIFSR_COLL_A1;
00262     Optics->collimator.LateralColor.coef[1] = SNIFSR_COLL_A2;
00263     Optics->collimator.LateralColor.coef[2] = SNIFSR_COLL_A3;
00264     Optics->collimator.LateralColor.lbdaref = SNIFSR_LBDA_REF;
00265 
00266     /* Grism */
00267     Optics->grism.prism.id   = SNIFSR_GRISM_GLA;
00268     Optics->grism.A          = SNIFSR_GRISM_ANG * M_PI/180.;
00269     Optics->grism.grating.id = SNIFSR_GRISM_RES;
00270     Optics->grism.g_per_mm   = SNIFSR_GRISM_GRA; 
00271     Optics->grism.blaze      = SNIFSR_GRISM_BLA * M_PI/180.;
00272     Optics->grism.w_disp     = SNIFSR_GRISM_D / (CCDR_PIX/1000.); /* AA/mm */
00273 
00274     /* Camera parameters */
00275     Optics->camera.focal                = SNIFSR_CAM_F;
00276     Optics->camera.distor               = SNIFSR_CAM_E;
00277     Optics->camera.LateralColor.coef[0] = SNIFSR_CAM_A1;
00278     Optics->camera.LateralColor.coef[1] = SNIFSR_CAM_A2;
00279     Optics->camera.LateralColor.coef[2] = SNIFSR_CAM_A3;
00280     Optics->camera.LateralColor.lbdaref = SNIFSR_LBDA_REF;
00281 
00282     /* MLA */
00283     Optics->MLA.sizepix = SNIFSR_LENS_PX;
00284     Optics->MLA.angle   = SNIFSR_LENS_AN * M_PI/180.;
00285 
00286     /* Filter */
00287     l1  = SNIFSR_FILT_L; l2  = SNIFSR_FILT_H; /* Total coverage  */
00288     l1u = SNIFSR_FILT_S; l2u = SNIFSR_FILT_E; /* Useful coverage */
00289 
00290     /* ----- Detector ------------------------------ */
00291 
00292     strcpy(CCD->name, CCDR_NAME);
00293     CCD->pixsize = CCDR_PIX; /* in microns */
00294     CCD->gain    = CCDR_GAIN;
00295     CCD->ron     = CCDR_RON;
00296     CCD->dark    = 0.;
00297     CCD->nx      = CCDR_NX;
00298     CCD->ny      = CCDR_NY;
00299 
00300     break;
00301 
00302   default:
00303     print_error("Unknown SNIFS spectroscopic channel (%d)",channel);
00304     return(ERR_NOIMPL);
00305     break;
00306   }
00307 
00308   /* ===== Channel-independant settings ][ ============================== */
00309 
00310   /* Filter parameters */
00311   Optics->filter.inf_total    = l1;
00312   Optics->filter.sup_total    = l2;
00313   Optics->filter.central_total= (l1 + l2)/2.;
00314   Optics->filter.width_total  = ABS(l2 - l1);
00315 
00316   Optics->filter.inf_util     = l1u;
00317   Optics->filter.sup_util     = l2u;
00318   Optics->filter.central_util = (l1u + l2u)/2.;
00319   Optics->filter.width_util   = ABS(l2u - l1u);
00320 
00321   /* Grism parameters */
00322   strcpy(Optics->grism.prism.name,material_names[Optics->grism.prism.id]);
00323   Optics->grism.prism.sellcoeffs = 
00324     material_sellcoeffs[Optics->grism.prism.id];
00325 
00326   strcpy(Optics->grism.grating.name,material_names[Optics->grism.grating.id]);
00327   Optics->grism.grating.sellcoeffs = 
00328     material_sellcoeffs[Optics->grism.grating.id];
00329 
00330   /* Set default value for center of distortion */
00331   Optics->center.xc = CCD->nx/2;
00332   Optics->center.yc = CCD->ny/2;
00333 
00334   return(OK);
00335 }
00336 
00337 /* === Doxygen Comment ======================================= */
00341 /* =========================================================== */
00342 
00343 void optics2dval(const SnifsOptics *Optics, double *dval)
00344 {
00345   dval[ 0] = Optics->enlarger.gamma;                   /* Enlarger */
00346   dval[ 1] = Optics->collimator.focal;                 /* Collimator */
00347   dval[ 2] = Optics->collimator.distor;
00348   dval[ 3] = Optics->collimator.LateralColor.coef[0];
00349   dval[ 4] = Optics->collimator.LateralColor.coef[1];
00350   dval[ 5] = Optics->collimator.LateralColor.coef[2];
00351   dval[ 6] = Optics->collimator.LateralColor.lbdaref;
00352   dval[ 7] = Optics->grism.A;                          /* Grism */
00353   dval[ 8] = Optics->grism.g_per_mm;
00354   dval[ 9] = Optics->grism.blaze;
00355   dval[10] = Optics->grism.w_disp;                                 
00356   dval[11] = Optics->grism.tiltx;                                  
00357   dval[12] = Optics->grism.tilty;                                  
00358   dval[13] = Optics->grism.rotz;                                   
00359   dval[14] = Optics->camera.focal;                     /* Camera */
00360   dval[15] = Optics->camera.distor;                                
00361   dval[16] = Optics->camera.LateralColor.coef[0];                  
00362   dval[17] = Optics->camera.LateralColor.coef[1];                  
00363   dval[18] = Optics->camera.LateralColor.coef[2];                  
00364   dval[19] = Optics->camera.LateralColor.lbdaref;                  
00365   dval[20] = Optics->MLA.size;                         /* MLA */   
00366   dval[21] = Optics->MLA.sizepix;                                  
00367   dval[22] = Optics->MLA.angle;                                    
00368   dval[23] = Optics->filter.inf_util;                  /* Filter */
00369   dval[24] = Optics->filter.sup_util;                              
00370   dval[25] = Optics->filter.central_util;                          
00371   dval[26] = Optics->filter.width_util;                            
00372   dval[27] = Optics->filter.inf_total;                             
00373   dval[28] = Optics->filter.sup_total;                             
00374   dval[29] = Optics->filter.central_total;                         
00375   dval[30] = Optics->filter.width_total;                           
00376   dval[31] = Optics->center.xc;                        /* Center */
00377   dval[32] = Optics->center.yc; 
00378 }
00379 
00380 /* === Doxygen Comment ======================================= */
00384 /* =========================================================== */
00385 
00386 void dval2optics(const double dval[], SnifsOptics *Optics)
00387 {
00388   Optics->enlarger.gamma                   = dval[ 0]; /* Enlarger */
00389   Optics->collimator.focal                 = dval[ 1]; /* Collimator */
00390   Optics->collimator.distor                = dval[ 2];
00391   Optics->collimator.LateralColor.coef[0]  = dval[ 3];
00392   Optics->collimator.LateralColor.coef[1]  = dval[ 4];
00393   Optics->collimator.LateralColor.coef[2]  = dval[ 5];
00394   Optics->collimator.LateralColor.lbdaref  = dval[ 6];
00395   Optics->grism.A                          = dval[ 7]; /* Grism */
00396   Optics->grism.g_per_mm                   = dval[ 8];
00397   Optics->grism.blaze                      = dval[ 9];
00398   Optics->grism.w_disp                     = dval[10];
00399   Optics->grism.tiltx                      = dval[11];
00400   Optics->grism.tilty                      = dval[12];
00401   Optics->grism.rotz                       = dval[13];
00402   Optics->camera.focal                     = dval[14]; /* Camera */
00403   Optics->camera.distor                    = dval[15];             
00404   Optics->camera.LateralColor.coef[0]      = dval[16];             
00405   Optics->camera.LateralColor.coef[1]      = dval[17];             
00406   Optics->camera.LateralColor.coef[2]      = dval[18];             
00407   Optics->camera.LateralColor.lbdaref      = dval[19];             
00408   Optics->MLA.size                         = dval[20]; /* MLA */   
00409   Optics->MLA.sizepix                      = dval[21];             
00410   Optics->MLA.angle                        = dval[22];             
00411   Optics->filter.inf_util                  = dval[23]; /* Filter */
00412   Optics->filter.sup_util                  = dval[24];             
00413   Optics->filter.central_util              = dval[25];             
00414   Optics->filter.width_util                = dval[26];             
00415   Optics->filter.inf_total                 = dval[27];             
00416   Optics->filter.sup_total                 = dval[28];             
00417   Optics->filter.central_total             = dval[29];             
00418   Optics->filter.width_total               = dval[30];             
00419   Optics->center.xc                        = dval[31]; /* Center */
00420   Optics->center.yc                        = dval[32];
00421 }
00422 
00423 /* === Doxygen Comment ======================================= */
00435 /* =========================================================== */
00436 
00437 int write_snifs_config_to_mask(TABLE *mask, SnifsConfig *config)
00438 {
00439 #define ERROR_DESC(s) \
00440   print_error("Cannot write configuration to mask '%s' "\
00441               "(desc. '%s')",mask->name,s); return(ERR_BAD_DESC)
00442 
00443   char back, oldname[lg_ident+1];
00444   int ival[3];
00445   float fval[3];
00446   double dval[33];
00447 
00448   SnifsOptics   *Optics = &(config->optics);
00449   Telescope     *UHT    = &(config->telescope);
00450   SnifsDetector *CCD    = &(config->ccd);
00451 
00452   print_msg("Writing configuration '%s' to mask '%s'...",
00453             config->name,mask->name);
00454 
00455   set_control_level(NONE);
00456   if (RD_desc(mask,CONFIG_NAME,CHAR,lg_ident,oldname) > 0 &&
00457       strcmp(oldname,DFLT_BLU_CFG_NAME) &&
00458       strcmp(oldname,DFLT_RED_CFG_NAME) ) {
00459     /* There's already a non-default configuration stored, ask confirmation */
00460     print_warning("Configuration '%s' is already stored in mask %s",
00461                   oldname,mask->name);
00462     if (ASK) {
00463       printf("   Overwrite it? [Y/N] ");
00464       back = getchar();
00465       if (back == 'N' || back=='n') {
00466         print_warning("Original configuration '%s' will not be overwritten!",
00467                       oldname);
00468         return(OK);
00469       }
00470     }
00471     print_warning("Overwriting configuration '%s'",oldname);
00472   }
00473   set_control_level(FATAL);
00474 
00475   /* Channel & Config Name */
00476   //  if (WR_desc(mask, CHANNEL, INT, 1, &(Optics->channel))) { 
00477   if (WR_desc(mask, CHANNEL, CHAR, lg_ident+1, channel_names[Optics->channel])) { 
00478     ERROR_DESC(CHANNEL); 
00479   }
00480   if (WR_desc(mask, CONFIG_NAME,CHAR,lg_ident,config->name)) { 
00481     ERROR_DESC(CONFIG_NAME); 
00482   }
00483 
00484   /* Optics parameters (DOUBLE) */
00485   optics2dval(Optics,dval);
00486   if (WR_desc(mask,MSK_DOPTPAR, DOUBLE, 33, dval)) { 
00487     ERROR_DESC(MSK_DOPTPAR); 
00488   }
00489 
00490   /* Optics parameters (INT) */
00491   ival[0] = Optics->grism.set;
00492   ival[1] = Optics->grism.prism.id;
00493   ival[2] = Optics->grism.grating.id;
00494   if (WR_desc(mask,MSK_IOPTPAR, LONG, 3, ival)) { 
00495     ERROR_DESC(MSK_IOPTPAR);
00496   }
00497 
00498   /* Telescope parameters */
00499   dval[0] = UHT->aperture;
00500   dval[1] = UHT->central_obscuration;
00501   dval[2] = UHT->scale;
00502   if (WR_desc(mask,MSK_DTELPAR, DOUBLE, 3, dval)) { 
00503     ERROR_DESC(MSK_DTELPAR); 
00504   }
00505 
00506   fval[0] = UHT->fratio;
00507   if (WR_desc(mask,MSK_FTELPAR, FLOAT, 1, fval)) { 
00508     ERROR_DESC(MSK_FTELPAR);
00509   }
00510 
00511   /* Detector parameters */
00512   if (WR_desc(mask,CCD_NAME, CHAR, lg_ident, CCD->name)) { 
00513     ERROR_DESC(CCD_NAME);
00514   }
00515 
00516   ival[0] = CCD->nx;
00517   ival[1] = CCD->ny;
00518   if (WR_desc(mask,MSK_ICCDPAR, LONG, 2, ival)) { 
00519     ERROR_DESC(MSK_ICCDPAR); 
00520   }
00521 
00522   fval[0] = CCD->pixsize;
00523   if (WR_desc(mask,MSK_FCCDPAR, FLOAT, 1, fval)) { 
00524     ERROR_DESC(MSK_FCCDPAR);
00525   }
00526 
00527   dval[0] = CCD->gain;
00528   dval[1] = CCD->ron;
00529   dval[2] = CCD->dark;
00530   if (WR_desc(mask,MSK_DCCDPAR, DOUBLE, 3, dval)) { 
00531     ERROR_DESC(MSK_DCCDPAR);
00532   }
00533 
00534   return(OK);
00535 
00536 #undef ERROR_DESC
00537 }
00538 
00539 /* === Doxygen Comment ======================================= */
00547 /* =========================================================== */
00548 
00549 int read_snifs_config_from_mask(TABLE *mask, SnifsConfig *config)
00550 {
00551 #define ERROR_DESC(s) \
00552   print_error("Cannot read configuration from mask '%s' "\
00553               "(desc. '%s' missing)",mask->name,s); return(ERR_NODESC)
00554 
00555   long ival[5];
00556   float fval[3];
00557   double dval[33];
00558 
00559   SnifsOptics   *Optics = &(config->optics);
00560   Telescope     *UHT    = &(config->telescope);
00561   SnifsDetector *CCD    = &(config->ccd);
00562 
00563   print_msg("Reading configuration from mask '%s'...",mask->name);
00564 
00565   /* Config Name & Channel */
00566   set_control_level(NONE);
00567   if (RD_desc(mask,CONFIG_NAME,CHAR,lg_ident,config->name) <= 0) {
00568     print_error("Cannot read configuration from mask, try option -default",
00569                 mask->name); 
00570     return(ERR_NODESC);
00571   }
00572   else 
00573     print_msg("   Configuration '%s' found",config->name); 
00574   set_control_level(FATAL);
00575 
00576 //  if (RD_desc(mask,CHANNEL,INT,1,&(Optics->channel)) <= 0) { 
00577 //    ERROR_DESC(CHANNEL);
00578 //  }
00579   if (!(Optics->channel=read_channel(mask))) return(ERR_NODESC);
00580 
00581   /* Optics parameters (DOUBLE) */
00582   if (RD_desc(mask,MSK_DOPTPAR,DOUBLE,33,dval) != 33) { 
00583     ERROR_DESC(MSK_DOPTPAR); 
00584   }
00585   dval2optics(dval,Optics); 
00586 
00587   /* Optics parameters (INT) */
00588   if (RD_desc(mask,MSK_IOPTPAR, LONG, 3, ival) != 3) { 
00589     ERROR_DESC(MSK_IOPTPAR); 
00590   }
00591   Optics->grism.set        = ival[0];
00592   Optics->grism.prism.id   = ival[1];
00593   strcpy(Optics->grism.prism.name,material_names[Optics->grism.prism.id]);
00594   Optics->grism.prism.sellcoeffs = 
00595     material_sellcoeffs[Optics->grism.prism.id];
00596   Optics->grism.grating.id = ival[2];
00597   strcpy(Optics->grism.grating.name,material_names[Optics->grism.grating.id]);
00598   Optics->grism.grating.sellcoeffs = 
00599     material_sellcoeffs[Optics->grism.grating.id];
00600 
00601   /* Telescope parameters (DOUBLE) */
00602   if (RD_desc(mask,MSK_DTELPAR,DOUBLE,3,dval) != 3) { 
00603     ERROR_DESC(MSK_DTELPAR); 
00604   } 
00605   UHT->aperture            = dval[0];
00606   UHT->central_obscuration = dval[1];
00607   UHT->scale               = dval[2];
00608 
00609   if (RD_desc(mask,MSK_FTELPAR, FLOAT, 1, fval) != 1) { 
00610     ERROR_DESC(MSK_FTELPAR);
00611   }
00612   UHT->fratio = fval[0];
00613 
00614   /* Detector parameters */
00615   if (RD_desc(mask,CCD_NAME,CHAR,lg_ident,CCD->name) <= 0) {
00616     ERROR_DESC(CCD_NAME);
00617   }
00618 
00619   if (RD_desc(mask,MSK_ICCDPAR, LONG, 2, ival) != 2) { 
00620     ERROR_DESC(MSK_ICCDPAR);
00621   } 
00622   CCD->nx = ival[0];
00623   CCD->ny = ival[1];
00624 
00625   if (RD_desc(mask,MSK_FCCDPAR, FLOAT, 1, fval) !=1 ) { 
00626     ERROR_DESC(MSK_FCCDPAR); 
00627   }
00628   CCD->pixsize = fval[0];
00629 
00630   if (RD_desc(mask,MSK_DCCDPAR,DOUBLE,3,dval) != 3) { 
00631     ERROR_DESC(MSK_DCCDPAR); 
00632   } 
00633   CCD->gain = dval[0];
00634   CCD->ron  = dval[1];
00635   CCD->dark = dval[2];
00636 
00637   return(OK);
00638 
00639 #undef ERROR_DESC
00640 }
00641 
00642 /* === Doxygen Comment ======================================= */
00646 /* =========================================================== */
00647 
00648 void print_snifs_optics(const SnifsOptics *Optics)
00649 {  
00650   print_msg("Channel: %s", channel_names[Optics->channel]);
00651 
00652   print_msg("Enlarger: gamma = %.2f", Optics->enlarger.gamma);
00653 
00654   print_msg("Collimator:\n"
00655             "   Focal length = %.1f mm, Distortion parameter = %g\n"
00656             "   Lateral color [%.1f AA] = %g,%g,%g",
00657             Optics->collimator.focal, 
00658             Optics->collimator.distor,
00659             Optics->collimator.LateralColor.lbdaref,
00660             Optics->collimator.LateralColor.coef[0],
00661             Optics->collimator.LateralColor.coef[1],
00662             Optics->collimator.LateralColor.coef[2]);
00663 
00664   print_msg("Grism:\n"
00665             "   Prism:   Glass = %s, Angle = %.2f deg\n"
00666             "   Grating: Glass = %s, Lines/mm = %.1f, Blaze = %.2f deg\n"
00667             "   Tilts [deg]: ax = %.2f, ay = %.2f, az = %.2f\n"
00668             "   Dispersion = %.2f AA/mm",
00669             Optics->grism.prism.name, Optics->grism.A*180./M_PI,
00670             Optics->grism.grating.name, Optics->grism.g_per_mm, 
00671             Optics->grism.blaze*180./M_PI,
00672             Optics->grism.tiltx*180./M_PI, 
00673             Optics->grism.tilty*180./M_PI,
00674             Optics->grism.rotz*180./M_PI,
00675             Optics->grism.w_disp);
00676 
00677   print_msg("Camera:\n"
00678             "   Focal length = %.1f mm, Distortion parameter = %g\n"
00679             "   Lateral color [%.1f AA] = %g,%g,%g",
00680             Optics->camera.focal, 
00681             Optics->camera.distor,
00682             Optics->camera.LateralColor.lbdaref,
00683             Optics->camera.LateralColor.coef[0],
00684             Optics->camera.LateralColor.coef[1],
00685             Optics->camera.LateralColor.coef[2]);
00686 
00687   print_msg("MLA: Lens size = %.2f mm", Optics->MLA.size);
00688 
00689   print_msg("Filter wavelength range:\n"
00690             "   Total = %.1f-%.1f AA, Useful = %.1f-%.1f AA",
00691             Optics->filter.inf_total, Optics->filter.sup_total, 
00692             Optics->filter.inf_util, Optics->filter.sup_util);
00693 }
00694 
00695 /* === Doxygen Comment ======================================= */
00699 /* =========================================================== */
00700 
00701 void print_snifs_telescope(const Telescope *UHT)
00702 {
00703   print_msg("Telescope aperture: %.1f mm, Central obscuration: %.1f mm", 
00704             UHT->aperture, UHT->central_obscuration);
00705   print_msg("Telescope f-ratio: %.2f", UHT->fratio);
00706   print_msg("Telescope scale: %.1f micron/arcsec", UHT->scale);
00707 }
00708 
00709 /* === Doxygen Comment ======================================= */
00713 /* =========================================================== */
00714 
00715 void print_snifs_detector(const SnifsDetector *CCD)
00716 {
00717   print_msg("CCD %s (default values):\n"
00718             "   Format = %dx%d pixels of %.1f microns\n"
00719             "   Gain = %.1f e-/ADU, RoN = %.1f e-, Dark = %.1f e-/h",
00720             CCD->name,CCD->nx,CCD->ny,CCD->pixsize,
00721             CCD->gain,CCD->ron,CCD->dark);
00722 } 
00723 
00724 /* === Doxygen Comment ======================================= */
00728 /* =========================================================== */
00729 
00730 void print_snifs_config(const SnifsConfig *config)
00731 {
00732   print_msg("\n===== Configuration ==============================");
00733   print_msg("Configuration name: '%s'", config->name);
00734   print_msg("----- OPTICS -------------------------------------");
00735   print_snifs_optics(&(config->optics));
00736   print_msg("----- TELESCOPE ----------------------------------");
00737   print_snifs_telescope(&(config->telescope));
00738   print_msg("----- CCD ----------------------------------------");
00739   print_snifs_detector(&(config->ccd));
00740   print_msg("==================================================\n");
00741 }

Generated on Wed Oct 26 23:59:39 2005 for Snifs by doxygen 1.3.5