visir_pfits.c

00001 /* $Id: visir_pfits.c,v 1.46 2012/02/02 10:22:05 jtaylor Exp $
00002  *
00003  * This file is part of the VISIR Pipeline
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jtaylor $
00023  * $Date: 2012/02/02 10:22:05 $
00024  * $Revision: 1.46 $
00025  * $Name: visir-3_5_0 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                    Defines
00034  -----------------------------------------------------------------------------*/
00035 
00036 #define visir_pfits_get_double(KEY) irplib_pfits_get_double(self, KEY)
00037 #define visir_pfits_get_int(KEY)    irplib_pfits_get_int(self, KEY)
00038 #define visir_pfits_get_string(KEY) irplib_pfits_get_string(self, KEY)
00039 
00040 
00041 /*-----------------------------------------------------------------------------
00042                                    Includes
00043  -----------------------------------------------------------------------------*/
00044 
00045 #include <string.h>
00046 #include <assert.h>
00047 #include <math.h>
00048 #include <cpl.h>
00049 
00050 #include "irplib_pfits.h"
00051 
00052 #include "visir_utils.h"
00053 #include "visir_pfits.h"
00054 
00055 
00056 /*-----------------------------------------------------------------------------
00057                         Private function prototypes
00058  -----------------------------------------------------------------------------*/
00059 
00060 static const char * visir_pfits_get_slitname(const cpl_propertylist *);
00061 static double visir_pfits_get_slitwidth_raw(const cpl_propertylist *);
00062 
00063 /*----------------------------------------------------------------------------*/
00068 /*----------------------------------------------------------------------------*/
00069 
00072 /*-----------------------------------------------------------------------------
00073                               Function codes
00074  -----------------------------------------------------------------------------*/
00075 
00076 /*----------------------------------------------------------------------------*/
00082 /*----------------------------------------------------------------------------*/
00083 double visir_pfits_get_airmass_start(const cpl_propertylist * self)
00084 {
00085     return visir_pfits_get_double("ESO TEL AIRM START");
00086 }
00087 
00088 /*----------------------------------------------------------------------------*/
00094 /*----------------------------------------------------------------------------*/
00095 double visir_pfits_get_airmass_end(const cpl_propertylist * self)
00096 {
00097     return visir_pfits_get_double("ESO TEL AIRM END");
00098 }
00099 
00100 /*----------------------------------------------------------------------------*/
00106 /*----------------------------------------------------------------------------*/
00107 double visir_pfits_get_alpha(const cpl_propertylist * self)
00108 {
00109     return visir_pfits_get_double("ESO TEL TARG OFFSETALPHA");
00110 }
00111 
00112 /*----------------------------------------------------------------------------*/
00118 /*----------------------------------------------------------------------------*/
00119 const char * visir_pfits_get_arcfile(const cpl_propertylist * self)
00120 {
00121     return visir_pfits_get_string("ARCFILE");
00122 }
00123 
00124 /*----------------------------------------------------------------------------*/
00130 /*----------------------------------------------------------------------------*/
00131 const char * visir_pfits_get_chopnod_dir(const cpl_propertylist * self)
00132 {
00133     return visir_pfits_get_string(VISIR_PFITS_STRING_CHOPNOD_DIR);
00134 }
00135 
00136 
00137 /*----------------------------------------------------------------------------*/
00143 /*----------------------------------------------------------------------------*/
00144 double visir_pfits_get_chop_throw(const cpl_propertylist * self)
00145 {
00146     return visir_pfits_get_double(VISIR_PFITS_DOUBLE_CHOP_THROW);
00147 }
00148 
00149 
00150 /*----------------------------------------------------------------------------*/
00156 /*----------------------------------------------------------------------------*/
00157 double visir_pfits_get_chop_pthrow(const cpl_propertylist * self)
00158 {
00159     const double throw = visir_pfits_get_chop_throw(self);
00160     const char * sscale = visir_pfits_get_pixscale(self);
00161     const double pscale       = sscale ? atof(sscale) : 0.0;
00162     return pscale > 0.0 ? throw / pscale : 0.0;
00163 }
00164 
00165 
00166 /*----------------------------------------------------------------------------*/
00172 /*----------------------------------------------------------------------------*/
00173 int visir_pfits_get_chop_ncycles(const cpl_propertylist * self)
00174 {
00175     return visir_pfits_get_int("ESO DET CHOP NCYCLES");
00176 }
00177 
00178 /*----------------------------------------------------------------------------*/
00184 /*----------------------------------------------------------------------------*/
00185 double visir_pfits_get_cumoffsetx(const cpl_propertylist * self)
00186 {
00187     return visir_pfits_get_double("ESO SEQ CUMOFFSETX");
00188 }
00189 
00190 /*----------------------------------------------------------------------------*/
00196 /*----------------------------------------------------------------------------*/
00197 double visir_pfits_get_cumoffsety(const cpl_propertylist * self)
00198 {
00199     return visir_pfits_get_double("ESO SEQ CUMOFFSETY");
00200 }
00201 
00202 /*----------------------------------------------------------------------------*/
00208 /*----------------------------------------------------------------------------*/
00209 const char * visir_pfits_get_date_obs(const cpl_propertylist * self)
00210 {
00211     return visir_pfits_get_string("DATE-OBS");
00212 }
00213 
00214 /*----------------------------------------------------------------------------*/
00220 /*----------------------------------------------------------------------------*/
00221 double visir_pfits_get_delta(const cpl_propertylist * self)
00222 {
00223     return visir_pfits_get_double("ESO TEL TARG OFFSETDELTA");
00224 }
00225 
00226 /*----------------------------------------------------------------------------*/
00232 /*----------------------------------------------------------------------------*/
00233 double visir_pfits_get_dec(const cpl_propertylist * self)
00234 {
00235     return visir_pfits_get_double("DEC");
00236 }
00237 
00238 /*----------------------------------------------------------------------------*/
00244 /*----------------------------------------------------------------------------*/
00245 double visir_pfits_get_dit(const cpl_propertylist * self)
00246 {
00247     return visir_pfits_get_double("ESO DET DIT");
00248 }
00249 
00250 /*----------------------------------------------------------------------------*/
00256 /*----------------------------------------------------------------------------*/
00257 int visir_pfits_get_expno(const cpl_propertylist * self)
00258 {
00259     return visir_pfits_get_int("ESO TPL EXPNO");
00260 }
00261 
00262 /*----------------------------------------------------------------------------*/
00268 /*----------------------------------------------------------------------------*/
00269 const char * visir_pfits_get_filter(const cpl_propertylist * self)
00270 {
00271 
00272     /* Get the instrument mode */
00273     const char * val   = visir_pfits_get_insmode(self);
00274 
00275     
00276     if (val == NULL) return NULL ;
00277 
00278     /* Imaging mode */
00279     if (!strcmp(val, "IMG"   ))
00280         return visir_pfits_get_string("ESO INS FILT1 NAME");
00281     /* Spectro mode */
00282     if (!strcmp(val, "SPC"   ))
00283         return visir_pfits_get_string("ESO INS FILT2 NAME");
00284     /* Spectro mode */
00285     if (!strcmp(val, "SPCIMG"))
00286         return visir_pfits_get_string("ESO INS FILT2 NAME");
00287 
00288     cpl_ensure(0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
00289 
00290 }
00291 
00292 /*----------------------------------------------------------------------------*/
00298 /*----------------------------------------------------------------------------*/
00299 double visir_pfits_get_focus(const cpl_propertylist * self)
00300 {
00301     return visir_pfits_get_double("ESO TEL FOCU LEN");
00302 }
00303 
00304 /*----------------------------------------------------------------------------*/
00310 /*----------------------------------------------------------------------------*/
00311 double visir_pfits_get_exptime(const cpl_propertylist * self)
00312 {
00313     return visir_pfits_get_double("EXPTIME");
00314 }
00315 
00316 /*----------------------------------------------------------------------------*/
00322 /*----------------------------------------------------------------------------*/
00323 const char * visir_pfits_get_frame_type(const cpl_propertylist * self)
00324 {
00325     return visir_pfits_get_string("ESO DET FRAM TYPE");
00326 }
00327 
00328 /*----------------------------------------------------------------------------*/
00334 /*----------------------------------------------------------------------------*/
00335 const char * visir_pfits_get_grat1_name(const cpl_propertylist * self)
00336 {
00337     return visir_pfits_get_string("ESO INS GRAT1 NAME");
00338 }
00339 
00340 /*----------------------------------------------------------------------------*/
00346 /*----------------------------------------------------------------------------*/
00347 const char * visir_pfits_get_insmode(const cpl_propertylist * self)
00348 {
00349     return visir_pfits_get_string("ESO INS MODE");
00350 }
00351 
00352 /*----------------------------------------------------------------------------*/
00358 /*----------------------------------------------------------------------------*/
00359 const char * visir_pfits_get_instrument(const cpl_propertylist * self)
00360 {
00361     return visir_pfits_get_string("INSTRUME");
00362 }
00363 
00364 /*----------------------------------------------------------------------------*/
00370 /*----------------------------------------------------------------------------*/
00371 double visir_pfits_get_mjdobs(const cpl_propertylist * self)
00372 {
00373     return visir_pfits_get_double("MJD-OBS");
00374 }
00375 
00376 /*----------------------------------------------------------------------------*/
00382 /*----------------------------------------------------------------------------*/
00383 const char * visir_pfits_get_mode(const cpl_propertylist * self)
00384 {
00385     return visir_pfits_get_string("ESO DET MODE NAME");
00386 }
00387 
00388 /*----------------------------------------------------------------------------*/
00394 /*----------------------------------------------------------------------------*/
00395 double visir_pfits_get_monoc_pos(const cpl_propertylist * self)
00396 {
00397     return visir_pfits_get_double("ESO INS MONOC1 POS");
00398 }
00399 
00400 /*----------------------------------------------------------------------------*/
00406 /*----------------------------------------------------------------------------*/
00407 int visir_pfits_get_ndit(const cpl_propertylist * self)
00408 {   
00409     return visir_pfits_get_int("ESO DET NDIT");
00410 }
00411 
00412 /*----------------------------------------------------------------------------*/
00418 /*----------------------------------------------------------------------------*/
00419 int visir_pfits_get_naxis3(const cpl_propertylist * self)
00420 {
00421     return visir_pfits_get_int("NAXIS3");
00422 }
00423 
00424 /*----------------------------------------------------------------------------*/
00430 /*----------------------------------------------------------------------------*/
00431 int visir_pfits_get_numbexp(const cpl_propertylist * self) 
00432 {
00433     return visir_pfits_get_int("ESO TPL NEXP");
00434 }
00435 
00436 /*----------------------------------------------------------------------------*/
00442 /*----------------------------------------------------------------------------*/
00443 int visir_pfits_get_obs_id(const cpl_propertylist * self)
00444 {
00445     return visir_pfits_get_int("ESO OBS ID");
00446 }
00447 
00448 /*----------------------------------------------------------------------------*/
00454 /*----------------------------------------------------------------------------*/
00455 const char * visir_pfits_get_nodpos(const cpl_propertylist * self)
00456 {
00457     return visir_pfits_get_string("ESO SEQ NODPOS");
00458 }
00459 
00460 /*----------------------------------------------------------------------------*/
00466 /*----------------------------------------------------------------------------*/
00467 const char *  visir_pfits_get_pixscale(const cpl_propertylist * self)
00468 {
00469     return visir_pfits_get_string("ESO INS PFOV");
00470 }
00471 
00472 /*----------------------------------------------------------------------------*/
00478 /*----------------------------------------------------------------------------*/
00479 double visir_pfits_get_pixspace(const cpl_propertylist * self)
00480 {
00481     return visir_pfits_get_double("ESO DET CHIP PXSPACE");
00482 }
00483 
00484 /*----------------------------------------------------------------------------*/
00490 /*----------------------------------------------------------------------------*/
00491 double visir_pfits_get_ra(const cpl_propertylist * self)
00492 {
00493     return visir_pfits_get_double("RA");
00494 }
00495 
00496 /*----------------------------------------------------------------------------*/
00502 /*----------------------------------------------------------------------------*/
00503 double visir_pfits_get_slitwidth(const cpl_propertylist * self)
00504 {
00505     const char * slitname = visir_pfits_get_slitname(self);
00506     double slitwidth = visir_pfits_get_slitwidth_raw(self);
00507 
00508 
00509     if (!cpl_error_get_code()) {
00510 
00511         static const char * slit_name[] = {"CU_0.12", "CU_0.14", "CU_0.16",
00512                                            "CU_0.20", "CU_0.25", "CU_0.30",
00513                                            "CU_0.40", "CU_0.50", "CU_0.60",
00514                                            "CU_0.70", "CU_0.80", "CU_1.00",
00515                                            "CU_1.20", "CU_1.60", "ST_0.14",
00516                                            "ST_0.16", "ST_0.20", "ST_0.30",
00517                                            "ST_0.40", "ST_0.50", "ST_0.60"};
00518 
00519         static double slit_width[] = {0.12, 0.14, 0.16,
00520                                       0.20, 0.25, 0.30,
00521                                       0.40, 0.50, 0.60,
00522                                       0.70, 0.80, 1.00,
00523                                       1.20, 1.60, 0.14,
00524                                       0.16, 0.20, 0.30,
00525                                       0.40, 0.50, 0.60};
00526 
00527         static const int slit_nums = (int)(sizeof(slit_width)/sizeof(double));
00528 
00529         int i;
00530 
00531         for (i=0; i < slit_nums; i++)
00532             if (strstr(slitname, slit_name[i])) break;
00533 
00534         if (i < slit_nums && fabs(slit_width[i] - slitwidth) < 0.001) {
00535             /* The Slit width is supposed to be in Arcseconds - as written in
00536                the comment of the FITS card.
00537                However, if the Slit width matches the Slit name then the Slit
00538                width is actually in unit millimeter and is converted */
00539 
00540             cpl_msg_warning(cpl_func,"The Width of slit %s is written in the "
00541                             "FITS card in units mm. Converting to ArcSecs: "
00542                             "%g => %g", slitname, slitwidth, slitwidth * 2.5);
00543             slitwidth *= 2.5;
00544         }
00545     }
00546 
00547     return slitwidth;
00548 }
00549 
00550 /*----------------------------------------------------------------------------*/
00556 /*----------------------------------------------------------------------------*/
00557 const char * visir_pfits_get_starname(const cpl_propertylist * self)
00558 {
00559     return visir_pfits_get_string("ESO OBS TARG NAME");
00560 }
00561 
00562 /*----------------------------------------------------------------------------*/
00568 /*----------------------------------------------------------------------------*/
00569 const char * visir_pfits_get_resol(const cpl_propertylist * self)
00570 {
00571     return visir_pfits_get_string("ESO INS RESOL");
00572 }
00573 
00574 /*----------------------------------------------------------------------------*/
00580 /*----------------------------------------------------------------------------*/
00581 double visir_pfits_get_temp(const cpl_propertylist * self)
00582 {
00583     return visir_pfits_get_double("ESO TEL TH M1 TEMP");
00584 }
00585 
00586 /*----------------------------------------------------------------------------*/
00592 /*----------------------------------------------------------------------------*/
00593 double visir_pfits_get_volt1dcta9(const cpl_propertylist * self)
00594 {
00595     return visir_pfits_get_double("ESO DET VOLT1 DCTA9");
00596 }
00597 
00598 /*----------------------------------------------------------------------------*/
00604 /*----------------------------------------------------------------------------*/
00605 double visir_pfits_get_volt1dctb9(const cpl_propertylist * self)
00606 {
00607     return visir_pfits_get_double("ESO DET VOLT1 DCTB9");
00608 }
00609 
00610 /*----------------------------------------------------------------------------*/
00616 /*----------------------------------------------------------------------------*/
00617 double visir_pfits_get_volt2dcta9(const cpl_propertylist * self)
00618 {
00619     return visir_pfits_get_double("ESO DET VOLT2 DCTA9");
00620 }
00621 
00622 /*----------------------------------------------------------------------------*/
00628 /*----------------------------------------------------------------------------*/
00629 double visir_pfits_get_volt2dctb9(const cpl_propertylist * self)
00630 {
00631     return visir_pfits_get_double("ESO DET VOLT2 DCTB9");
00632 }
00633 
00634 /*----------------------------------------------------------------------------*/
00640 /*----------------------------------------------------------------------------*/
00641 double visir_pfits_get_wlen(const cpl_propertylist * self)
00642 {
00643     return visir_pfits_get_double("ESO INS GRAT1 WLEN");
00644 }
00645 
00648 /*----------------------------------------------------------------------------*/
00655 /*----------------------------------------------------------------------------*/
00656 static double visir_pfits_get_slitwidth_raw(const cpl_propertylist * self)
00657 {
00658     return visir_pfits_get_double("ESO INS SLIT1 WID");
00659 }
00660 
00661 /*----------------------------------------------------------------------------*/
00667 /*----------------------------------------------------------------------------*/
00668 static const char * visir_pfits_get_slitname(const cpl_propertylist * self)
00669 {
00670     return visir_pfits_get_string("ESO INS SLIT1 NAME");
00671 }

Generated on Mon Feb 6 15:23:49 2012 for VISIR Pipeline Reference Manual by  doxygen 1.5.8