visir_pfits.c

00001 /* $Id: visir_pfits.c,v 1.43 2007/03/14 08:19:41 llundin 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: llundin $
00023  * $Date: 2007/03/14 08:19:41 $
00024  * $Revision: 1.43 $
00025  * $Name: visir-3_3_1-public $
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("ESO SEQ CHOPNOD DIR");
00134 }
00135 
00136 /*----------------------------------------------------------------------------*/
00142 /*----------------------------------------------------------------------------*/
00143 int visir_pfits_get_chop_ncycles(const cpl_propertylist * self)
00144 {
00145     return visir_pfits_get_int("ESO DET CHOP NCYCLES");
00146 }
00147 
00148 /*----------------------------------------------------------------------------*/
00154 /*----------------------------------------------------------------------------*/
00155 double visir_pfits_get_cumoffsetx(const cpl_propertylist * self)
00156 {
00157     return visir_pfits_get_double("ESO SEQ CUMOFFSETX");
00158 }
00159 
00160 /*----------------------------------------------------------------------------*/
00166 /*----------------------------------------------------------------------------*/
00167 double visir_pfits_get_cumoffsety(const cpl_propertylist * self)
00168 {
00169     return visir_pfits_get_double("ESO SEQ CUMOFFSETY");
00170 }
00171 
00172 /*----------------------------------------------------------------------------*/
00178 /*----------------------------------------------------------------------------*/
00179 const char * visir_pfits_get_date_obs(const cpl_propertylist * self)
00180 {
00181     return visir_pfits_get_string("DATE-OBS");
00182 }
00183 
00184 /*----------------------------------------------------------------------------*/
00190 /*----------------------------------------------------------------------------*/
00191 double visir_pfits_get_delta(const cpl_propertylist * self)
00192 {
00193     return visir_pfits_get_double("ESO TEL TARG OFFSETDELTA");
00194 }
00195 
00196 /*----------------------------------------------------------------------------*/
00202 /*----------------------------------------------------------------------------*/
00203 double visir_pfits_get_dec(const cpl_propertylist * self)
00204 {
00205     return visir_pfits_get_double("DEC");
00206 }
00207 
00208 /*----------------------------------------------------------------------------*/
00214 /*----------------------------------------------------------------------------*/
00215 double visir_pfits_get_dit(const cpl_propertylist * self)
00216 {
00217     return visir_pfits_get_double("ESO DET DIT");
00218 }
00219 
00220 /*----------------------------------------------------------------------------*/
00226 /*----------------------------------------------------------------------------*/
00227 int visir_pfits_get_expno(const cpl_propertylist * self)
00228 {
00229     return visir_pfits_get_int("ESO TPL EXPNO");
00230 }
00231 
00232 /*----------------------------------------------------------------------------*/
00238 /*----------------------------------------------------------------------------*/
00239 const char * visir_pfits_get_filter(const cpl_propertylist * self)
00240 {
00241 
00242     /* Get the instrument mode */
00243     const char * val   = visir_pfits_get_insmode(self);
00244 
00245     
00246     if (val == NULL) return NULL ;
00247 
00248     /* Imaging mode */
00249     if (!strcmp(val, "IMG"   ))
00250         return visir_pfits_get_string("ESO INS FILT1 NAME");
00251     /* Spectro mode */
00252     if (!strcmp(val, "SPC"   ))
00253         return visir_pfits_get_string("ESO INS FILT2 NAME");
00254     /* Spectro mode */
00255     if (!strcmp(val, "SPCIMG"))
00256         return visir_pfits_get_string("ESO INS FILT2 NAME");
00257 
00258     cpl_ensure(0, CPL_ERROR_UNSUPPORTED_MODE, NULL);
00259 
00260 }
00261 
00262 /*----------------------------------------------------------------------------*/
00268 /*----------------------------------------------------------------------------*/
00269 double visir_pfits_get_focus(const cpl_propertylist * self)
00270 {
00271     return visir_pfits_get_double("ESO TEL FOCU LEN");
00272 }
00273 
00274 /*----------------------------------------------------------------------------*/
00280 /*----------------------------------------------------------------------------*/
00281 double visir_pfits_get_exptime(const cpl_propertylist * self)
00282 {
00283     return visir_pfits_get_double("EXPTIME");
00284 }
00285 
00286 /*----------------------------------------------------------------------------*/
00292 /*----------------------------------------------------------------------------*/
00293 const char * visir_pfits_get_frame_type(const cpl_propertylist * self)
00294 {
00295     return visir_pfits_get_string("ESO DET FRAM TYPE");
00296 }
00297 
00298 /*----------------------------------------------------------------------------*/
00304 /*----------------------------------------------------------------------------*/
00305 const char * visir_pfits_get_grat1_name(const cpl_propertylist * self)
00306 {
00307     return visir_pfits_get_string("ESO INS GRAT1 NAME");
00308 }
00309 
00310 /*----------------------------------------------------------------------------*/
00316 /*----------------------------------------------------------------------------*/
00317 const char * visir_pfits_get_insmode(const cpl_propertylist * self)
00318 {
00319     return visir_pfits_get_string("ESO INS MODE");
00320 }
00321 
00322 /*----------------------------------------------------------------------------*/
00328 /*----------------------------------------------------------------------------*/
00329 const char * visir_pfits_get_instrument(const cpl_propertylist * self)
00330 {
00331     return visir_pfits_get_string("INSTRUME");
00332 }
00333 
00334 /*----------------------------------------------------------------------------*/
00340 /*----------------------------------------------------------------------------*/
00341 double visir_pfits_get_mjdobs(const cpl_propertylist * self)
00342 {
00343     return visir_pfits_get_double("MJD-OBS");
00344 }
00345 
00346 /*----------------------------------------------------------------------------*/
00352 /*----------------------------------------------------------------------------*/
00353 const char * visir_pfits_get_mode(const cpl_propertylist * self)
00354 {
00355     return visir_pfits_get_string("ESO DET MODE NAME");
00356 }
00357 
00358 /*----------------------------------------------------------------------------*/
00364 /*----------------------------------------------------------------------------*/
00365 double visir_pfits_get_monoc_pos(const cpl_propertylist * self)
00366 {
00367     return visir_pfits_get_double("ESO INS MONOC1 POS");
00368 }
00369 
00370 /*----------------------------------------------------------------------------*/
00376 /*----------------------------------------------------------------------------*/
00377 int visir_pfits_get_ndit(const cpl_propertylist * self)
00378 {   
00379     return visir_pfits_get_int("ESO DET NDIT");
00380 }
00381 
00382 /*----------------------------------------------------------------------------*/
00388 /*----------------------------------------------------------------------------*/
00389 int visir_pfits_get_naxis3(const cpl_propertylist * self)
00390 {
00391     return visir_pfits_get_int("NAXIS3");
00392 }
00393 
00394 /*----------------------------------------------------------------------------*/
00400 /*----------------------------------------------------------------------------*/
00401 int visir_pfits_get_numbexp(const cpl_propertylist * self) 
00402 {
00403     return visir_pfits_get_int("ESO TPL NEXP");
00404 }
00405 
00406 /*----------------------------------------------------------------------------*/
00412 /*----------------------------------------------------------------------------*/
00413 int visir_pfits_get_obs_id(const cpl_propertylist * self)
00414 {
00415     return visir_pfits_get_int("ESO OBS ID");
00416 }
00417 
00418 /*----------------------------------------------------------------------------*/
00424 /*----------------------------------------------------------------------------*/
00425 const char * visir_pfits_get_nodpos(const cpl_propertylist * self)
00426 {
00427     return visir_pfits_get_string("ESO SEQ NODPOS");
00428 }
00429 
00430 /*----------------------------------------------------------------------------*/
00436 /*----------------------------------------------------------------------------*/
00437 const char *  visir_pfits_get_pixscale(const cpl_propertylist * self)
00438 {
00439     return visir_pfits_get_string("ESO INS PFOV");
00440 }
00441 
00442 /*----------------------------------------------------------------------------*/
00448 /*----------------------------------------------------------------------------*/
00449 double visir_pfits_get_pixspace(const cpl_propertylist * self)
00450 {
00451     return visir_pfits_get_double("ESO DET CHIP PXSPACE");
00452 }
00453 
00454 /*----------------------------------------------------------------------------*/
00460 /*----------------------------------------------------------------------------*/
00461 double visir_pfits_get_ra(const cpl_propertylist * self)
00462 {
00463     return visir_pfits_get_double("RA");
00464 }
00465 
00466 /*----------------------------------------------------------------------------*/
00472 /*----------------------------------------------------------------------------*/
00473 double visir_pfits_get_slitwidth(const cpl_propertylist * self)
00474 {
00475     const char * slitname = visir_pfits_get_slitname(self);
00476     double slitwidth = visir_pfits_get_slitwidth_raw(self);
00477 
00478 
00479     if (!cpl_error_get_code()) {
00480 
00481         static const char * slit_name[] = {"CU_0.12", "CU_0.14", "CU_0.16",
00482                                            "CU_0.20", "CU_0.25", "CU_0.30",
00483                                            "CU_0.40", "CU_0.50", "CU_0.60",
00484                                            "CU_0.70", "CU_0.80", "CU_1.00",
00485                                            "CU_1.20", "CU_1.60", "ST_0.14",
00486                                            "ST_0.16", "ST_0.20", "ST_0.30",
00487                                            "ST_0.40", "ST_0.50", "ST_0.60"};
00488 
00489         static double slit_width[] = {0.12, 0.14, 0.16,
00490                                       0.20, 0.25, 0.30,
00491                                       0.40, 0.50, 0.60,
00492                                       0.70, 0.80, 1.00,
00493                                       1.20, 1.60, 0.14,
00494                                       0.16, 0.20, 0.30,
00495                                       0.40, 0.50, 0.60};
00496 
00497         static const int slit_nums = (int)(sizeof(slit_width)/sizeof(double));
00498 
00499         int i;
00500 
00501         for (i=0; i < slit_nums; i++)
00502             if (strstr(slitname, slit_name[i])) break;
00503 
00504         if (i < slit_nums && fabs(slit_width[i] - slitwidth) < 0.001) {
00505             /* The Slit width is supposed to be in Arcseconds - as written in
00506                the comment of the FITS card.
00507                However, if the Slit width matches the Slit name then the Slit
00508                width is actually in unit millimeter and is converted */
00509 
00510             cpl_msg_warning(cpl_func,"The Width of slit %s is written in the "
00511                             "FITS card in units mm. Converting to ArcSecs: "
00512                             "%g => %g", slitname, slitwidth, slitwidth * 2.5);
00513             slitwidth *= 2.5;
00514         }
00515     }
00516 
00517     return slitwidth;
00518 }
00519 
00520 /*----------------------------------------------------------------------------*/
00526 /*----------------------------------------------------------------------------*/
00527 const char * visir_pfits_get_starname(const cpl_propertylist * self)
00528 {
00529     return visir_pfits_get_string("ESO OBS TARG NAME");
00530 }
00531 
00532 /*----------------------------------------------------------------------------*/
00538 /*----------------------------------------------------------------------------*/
00539 const char * visir_pfits_get_resol(const cpl_propertylist * self)
00540 {
00541     return visir_pfits_get_string("ESO INS RESOL");
00542 }
00543 
00544 /*----------------------------------------------------------------------------*/
00550 /*----------------------------------------------------------------------------*/
00551 double visir_pfits_get_temp(const cpl_propertylist * self)
00552 {
00553     return visir_pfits_get_double("ESO TEL TH M1 TEMP");
00554 }
00555 
00556 /*----------------------------------------------------------------------------*/
00562 /*----------------------------------------------------------------------------*/
00563 double visir_pfits_get_volt1dcta9(const cpl_propertylist * self)
00564 {
00565     return visir_pfits_get_double("ESO DET VOLT1 DCTA9");
00566 }
00567 
00568 /*----------------------------------------------------------------------------*/
00574 /*----------------------------------------------------------------------------*/
00575 double visir_pfits_get_volt1dctb9(const cpl_propertylist * self)
00576 {
00577     return visir_pfits_get_double("ESO DET VOLT1 DCTB9");
00578 }
00579 
00580 /*----------------------------------------------------------------------------*/
00586 /*----------------------------------------------------------------------------*/
00587 double visir_pfits_get_volt2dcta9(const cpl_propertylist * self)
00588 {
00589     return visir_pfits_get_double("ESO DET VOLT2 DCTA9");
00590 }
00591 
00592 /*----------------------------------------------------------------------------*/
00598 /*----------------------------------------------------------------------------*/
00599 double visir_pfits_get_volt2dctb9(const cpl_propertylist * self)
00600 {
00601     return visir_pfits_get_double("ESO DET VOLT2 DCTB9");
00602 }
00603 
00604 /*----------------------------------------------------------------------------*/
00610 /*----------------------------------------------------------------------------*/
00611 double visir_pfits_get_wlen(const cpl_propertylist * self)
00612 {
00613     return visir_pfits_get_double("ESO INS GRAT1 WLEN");
00614 }
00615 
00618 /*----------------------------------------------------------------------------*/
00625 /*----------------------------------------------------------------------------*/
00626 static double visir_pfits_get_slitwidth_raw(const cpl_propertylist * self)
00627 {
00628     return visir_pfits_get_double("ESO INS SLIT1 WID");
00629 }
00630 
00631 /*----------------------------------------------------------------------------*/
00637 /*----------------------------------------------------------------------------*/
00638 static const char * visir_pfits_get_slitname(const cpl_propertylist * self)
00639 {
00640     return visir_pfits_get_string("ESO INS SLIT1 NAME");
00641 }

Generated on Tue Jun 29 12:20:52 2010 for VISIR Pipeline Reference Manual by  doxygen 1.4.7