vircam_pfits.c

00001 /* $Id: vircam_pfits.c,v 1.33 2010/09/09 12:11:09 jim Exp $
00002  *
00003  * This file is part of the VIRCAM Pipeline
00004  * Copyright (C) 2005 Cambridge Astronomy Survey Unit
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: jim $
00023  * $Date: 2010/09/09 12:11:09 $
00024  * $Revision: 1.33 $
00025  * $Name: vcam-1_3_0 $
00026  */
00027 
00028 /* Includes */
00029 
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033 
00034 #include <cpl.h>
00035 #include <string.h>
00036 
00037 #include "vircam_utils.h"
00038 #include "vircam_pfits.h"
00039 
00040 static int vircam_pfits_get_float(const cpl_propertylist *plist, 
00041                                   const char *key, float *fval);
00042 static int vircam_pfits_get_double(const cpl_propertylist *plist, 
00043                                    const char *key, double *fval);
00044 
00058 /*---------------------------------------------------------------------------*/
00066 /*---------------------------------------------------------------------------*/
00067 
00068 extern int vircam_pfits_get_crval1(const cpl_propertylist *plist, 
00069                                    double *crval1) {
00070 
00071     return(vircam_pfits_get_double(plist,"CRVAL1",crval1));
00072 
00073 }
00074 
00075 /*---------------------------------------------------------------------------*/
00083 /*---------------------------------------------------------------------------*/
00084 
00085 extern int vircam_pfits_get_crpix1(const cpl_propertylist *plist, 
00086                                    double *crpix1) {
00087 
00088     return(vircam_pfits_get_double(plist,"CRPIX1",crpix1));
00089 
00090 }
00091 
00092 /*---------------------------------------------------------------------------*/
00100 /*---------------------------------------------------------------------------*/
00101 
00102 extern int vircam_pfits_get_crval2(const cpl_propertylist *plist, 
00103                                    double *crval2) {
00104 
00105     return(vircam_pfits_get_double(plist,"CRVAL2",crval2));
00106 
00107 }
00108 
00109 /*---------------------------------------------------------------------------*/
00117 /*---------------------------------------------------------------------------*/
00118 
00119 extern int vircam_pfits_get_crpix2(const cpl_propertylist *plist, 
00120                                    double *crpix2) {
00121 
00122     return(vircam_pfits_get_double(plist,"CRPIX2",crpix2));
00123 }
00124 
00125 /*---------------------------------------------------------------------------*/
00133 /*---------------------------------------------------------------------------*/
00134 
00135 extern int vircam_pfits_get_cd11(const cpl_propertylist *plist, double *cd11) {
00136 
00137     return(vircam_pfits_get_double(plist,"CD1_1",cd11));
00138 }
00139 
00140 /*---------------------------------------------------------------------------*/
00148 /*---------------------------------------------------------------------------*/
00149 
00150 extern int vircam_pfits_get_cd12(const cpl_propertylist *plist, double *cd12) {
00151 
00152     return(vircam_pfits_get_double(plist,"CD1_2",cd12));
00153 
00154 }
00155 
00156 /*---------------------------------------------------------------------------*/
00164 /*---------------------------------------------------------------------------*/
00165 
00166 extern int vircam_pfits_get_cd21(const cpl_propertylist *plist, double *cd21) {
00167 
00168     return(vircam_pfits_get_double(plist,"CD2_1",cd21));
00169 }
00170 
00171 /*---------------------------------------------------------------------------*/
00179 /*---------------------------------------------------------------------------*/
00180 
00181 extern int vircam_pfits_get_cd22(const cpl_propertylist *plist, double *cd22) {
00182 
00183     return(vircam_pfits_get_double(plist,"CD2_2",cd22));
00184 
00185 }
00186 
00187 /*---------------------------------------------------------------------------*/
00195 /*---------------------------------------------------------------------------*/
00196 
00197 extern int vircam_pfits_get_pv21(const cpl_propertylist *plist, double *pv21) {
00198 
00199     return(vircam_pfits_get_double(plist,"PV2_1",pv21));
00200 
00201 }
00202 
00203 /*---------------------------------------------------------------------------*/
00211 /*---------------------------------------------------------------------------*/
00212 
00213 extern int vircam_pfits_get_pv23(const cpl_propertylist *plist, double *pv23) {
00214 
00215     return(vircam_pfits_get_double(plist,"PV2_3",pv23));
00216 
00217 }
00218 
00219 /*---------------------------------------------------------------------------*/
00227 /*---------------------------------------------------------------------------*/
00228 
00229 extern int vircam_pfits_get_pv25(const cpl_propertylist *plist, double *pv25) {
00230 
00231     return(vircam_pfits_get_double(plist,"PV2_5",pv25));
00232 
00233 }
00234 
00235 /*---------------------------------------------------------------------------*/
00243 /*---------------------------------------------------------------------------*/
00244 
00245 extern int vircam_pfits_get_exptime(const cpl_propertylist *plist, 
00246                                     float *exptime) {
00247 
00248     return(vircam_pfits_get_float(plist,"EXPTIME",exptime));
00249 
00250 }
00251 
00252 /*---------------------------------------------------------------------------*/
00260 /*---------------------------------------------------------------------------*/
00261 
00262 extern int vircam_pfits_get_mindit(const cpl_propertylist *plist, 
00263                                    float *mindit) {
00264 
00265     return(vircam_pfits_get_float(plist,"ESO DET MINDIT",mindit));
00266 
00267 }
00268 
00269 /*---------------------------------------------------------------------------*/
00277 /*---------------------------------------------------------------------------*/
00278 
00279 extern int vircam_pfits_get_ditdelay(const cpl_propertylist *plist, 
00280                                      float *ditdelay) {
00281 
00282     return(vircam_pfits_get_float(plist,"ESO DET DITDELAY",ditdelay));
00283 
00284 }
00285 
00286 /*---------------------------------------------------------------------------*/
00294 /*---------------------------------------------------------------------------*/
00295 
00296 extern int vircam_pfits_get_naxis1(const cpl_propertylist *plist, 
00297                                    long *naxis1) {
00298     int val;
00299 
00300     val = cpl_propertylist_get_int(plist,"NAXIS1");
00301     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00302         *naxis1 = (long)val;
00303         return(VIR_OK);
00304     } else {
00305         cpl_error_reset();
00306         *naxis1 = 0;
00307         return(VIR_FATAL);
00308     }
00309 }
00310 
00311 /*---------------------------------------------------------------------------*/
00319 /*---------------------------------------------------------------------------*/
00320 
00321 extern int vircam_pfits_get_naxis2(const cpl_propertylist *plist, 
00322                                    long *naxis2) {
00323     int val;
00324 
00325     val = cpl_propertylist_get_int(plist,"NAXIS2");
00326     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00327         *naxis2 = (long)val;
00328         return(VIR_OK);
00329     } else {
00330         cpl_error_reset();
00331         *naxis2 = 0;
00332         return(VIR_FATAL);
00333     }
00334 }
00335 
00336 /*---------------------------------------------------------------------------*/
00344 /*---------------------------------------------------------------------------*/
00345 
00346 extern int vircam_pfits_get_chipno(const cpl_propertylist *plist, 
00347                                    int *chipno) {
00348     int val;
00349 
00350     val = cpl_propertylist_get_int(plist,"ESO DET CHIP NO");
00351     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00352         *chipno = val;
00353         return(VIR_OK);
00354     } else {
00355         cpl_error_reset();
00356         *chipno = 0;
00357         return(VIR_FATAL);
00358     }
00359 }
00360 
00361 /*---------------------------------------------------------------------------*/
00369 /*---------------------------------------------------------------------------*/
00370 
00371 extern int vircam_pfits_get_jxoff(const cpl_propertylist *plist, 
00372                                   float *xoff) {
00373 
00374     return(vircam_pfits_get_float(plist,"ESO DRS XOFFDITHER",xoff));
00375 
00376 }
00377 
00378 /*---------------------------------------------------------------------------*/
00386 /*---------------------------------------------------------------------------*/
00387 
00388 extern int vircam_pfits_get_jyoff(const cpl_propertylist *plist, 
00389                                   float *yoff) {
00390 
00391     return(vircam_pfits_get_float(plist,"ESO DRS YOFFDITHER",yoff));
00392 
00393 }
00394 
00395 /*---------------------------------------------------------------------------*/
00403 /*---------------------------------------------------------------------------*/
00404 
00405 extern int vircam_pfits_get_airmass(const cpl_propertylist *plist, 
00406                                     float *airmass) {
00407 
00408     return(vircam_pfits_get_float(plist,"ESO TEL AIRM START",airmass));
00409 
00410 }
00411 
00412 /*---------------------------------------------------------------------------*/
00420 /*---------------------------------------------------------------------------*/
00421 
00422 extern int vircam_pfits_get_nusteps(const cpl_propertylist *plist, 
00423                                     int *nusteps) {
00424     int val;
00425 
00426     val = cpl_propertylist_get_int(plist,"NUSTEP");
00427     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00428         *nusteps = val;
00429         return(VIR_OK);
00430     } else {
00431         cpl_error_reset();
00432         *nusteps = 0;
00433         return(VIR_FATAL);
00434     }
00435 
00436 }
00437 
00438 /*---------------------------------------------------------------------------*/
00447 /*---------------------------------------------------------------------------*/
00448 
00449 extern int vircam_pfits_get_ustepnum(const cpl_propertylist *plist, 
00450                                      int *ustepnum) {
00451     int val;
00452 
00453     val = cpl_propertylist_get_int(plist,"USTEPNUM");
00454     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00455         *ustepnum = val;
00456         return(VIR_OK);
00457     } else {
00458         cpl_error_reset();
00459         *ustepnum = 0;
00460         return(VIR_FATAL);
00461     }
00462 
00463 }
00464 
00465 /*---------------------------------------------------------------------------*/
00474 /*---------------------------------------------------------------------------*/
00475 
00476 extern int vircam_pfits_get_njsteps(const cpl_propertylist *plist, 
00477                                     int *njsteps) {
00478     int val;
00479 
00480     val = cpl_propertylist_get_int(plist,"NJITTER");
00481     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00482         *njsteps = val;
00483         return(VIR_OK);
00484     } else {
00485         cpl_error_reset();
00486         *njsteps = 0;
00487         return(VIR_FATAL);
00488     }
00489 
00490 }
00491 
00492 /*---------------------------------------------------------------------------*/
00501 /*---------------------------------------------------------------------------*/
00502 
00503 extern int vircam_pfits_get_jitternum(const cpl_propertylist *plist, 
00504                                       int *jitternum) {
00505     int val;
00506 
00507     val = cpl_propertylist_get_int(plist,"JITTRNUM");
00508     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00509         *jitternum = val;
00510         return(VIR_OK);
00511     } else {
00512         cpl_error_reset();
00513         *jitternum = 0;
00514         return(VIR_FATAL);
00515     }
00516 
00517 }
00518 
00519 /*---------------------------------------------------------------------------*/
00528 /*---------------------------------------------------------------------------*/
00529 
00530 extern int vircam_pfits_get_jitteri(const cpl_propertylist *plist, 
00531                                     int *jitteri) {
00532     int val;
00533 
00534     val = cpl_propertylist_get_int(plist,"JITTER_I");
00535     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00536         *jitteri = val;
00537         return(VIR_OK);
00538     } else {
00539         cpl_error_reset();
00540         *jitteri = 0;
00541         return(VIR_FATAL);
00542     }
00543 
00544 }
00545 
00546 /*---------------------------------------------------------------------------*/
00554 /*---------------------------------------------------------------------------*/
00555 
00556 extern int vircam_pfits_get_ndit(const cpl_propertylist *plist, 
00557                                  int *ndit) {
00558     int val;
00559 
00560     val = cpl_propertylist_get_int(plist,"ESO DET NDIT");
00561     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00562         *ndit = val;
00563         return(VIR_OK);
00564     } else {
00565         cpl_error_reset();
00566         *ndit = 1;
00567         return(VIR_FATAL);
00568     }
00569 }
00570 
00571 /*---------------------------------------------------------------------------*/
00579 /*---------------------------------------------------------------------------*/
00580 
00581 extern int vircam_pfits_get_detlive(const cpl_propertylist *plist, 
00582                                     int *detlive) {
00583     int val;
00584 
00585     val = cpl_propertylist_get_bool(plist,"ESO DET CHIP LIVE");
00586     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00587         *detlive = val;
00588         return(VIR_OK);
00589     } else {
00590         cpl_error_reset();
00591         *detlive = 1;
00592         return(VIR_FATAL);
00593     }
00594 }
00595 
00596 /*---------------------------------------------------------------------------*/
00604 /*---------------------------------------------------------------------------*/
00605 
00606 extern int vircam_pfits_get_filter(const cpl_propertylist *plist, char *filt) {
00607 
00608     strcpy(filt,cpl_propertylist_get_string(plist,"ESO INS FILT1 NAME"));
00609     if (cpl_error_get_code() == CPL_ERROR_NONE) {
00610         return(VIR_OK);
00611     } else {
00612         cpl_error_reset();
00613         return(VIR_FATAL);
00614     }
00615 }
00616 
00617 /*---------------------------------------------------------------------------*/
00625 /*---------------------------------------------------------------------------*/
00626 
00627 extern int vircam_pfits_get_saturation(const cpl_propertylist *plist, 
00628                                        float *saturation) {
00629 
00630     return(vircam_pfits_get_float(plist,"ESO DET SATURATION",saturation));
00631 
00632 }
00633 
00634 /*---------------------------------------------------------------------------*/
00642 /*---------------------------------------------------------------------------*/
00643 
00644 extern int vircam_pfits_get_gain(const cpl_propertylist *plist, float *gain) {
00645 
00646     return(vircam_pfits_get_float(plist,"GAIN",gain));
00647 
00648 }
00649 
00650 /*---------------------------------------------------------------------------*/
00658 /*---------------------------------------------------------------------------*/
00659 
00660 extern int vircam_pfits_get_mjd(const cpl_propertylist *plist, double *mjd) {
00661 
00662     return(vircam_pfits_get_double(plist,"MJD-OBS",mjd));
00663 
00664 }
00665 
00666 /*---------------------------------------------------------------------------*/
00674 /*---------------------------------------------------------------------------*/
00675 
00676 extern int vircam_pfits_get_ra(const cpl_propertylist *plist, double *ra) {
00677 
00678     return(vircam_pfits_get_double(plist,"RA",ra));
00679 
00680 }
00681 
00682 /*---------------------------------------------------------------------------*/
00690 /*---------------------------------------------------------------------------*/
00691 
00692 extern int vircam_pfits_get_dec(const cpl_propertylist *plist, double *dec) {
00693 
00694     return(vircam_pfits_get_double(plist,"DEC",dec));
00695 
00696 }
00697 
00698 /*---------------------------------------------------------------------------*/
00707 /*---------------------------------------------------------------------------*/
00708 
00709 static int vircam_pfits_get_float(const cpl_propertylist *plist, 
00710                                   const char *key, float *fval) {
00711     cpl_type type;
00712     const char *fctid = "vircam_pfits_get_float";
00713 
00714     /* Get the type of this keyword */
00715 
00716     type = cpl_propertylist_get_type(plist,key);
00717     if (cpl_error_get_code() != CPL_ERROR_NONE) {
00718         *fval = 0.0;
00719         cpl_error_reset();
00720         return(VIR_FATAL);
00721     }
00722 
00723     /* Switch of the property type */
00724 
00725     switch (type) {
00726     case CPL_TYPE_FLOAT:
00727         *fval = cpl_propertylist_get_float(plist,key);
00728         break;
00729     case CPL_TYPE_DOUBLE:
00730         *fval = (float)cpl_propertylist_get_double(plist,key);
00731         break;
00732     default:
00733         *fval = 0.0;
00734         cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00735         return(VIR_FATAL);
00736     }
00737     return(VIR_OK);
00738 }
00739 
00740 /*---------------------------------------------------------------------------*/
00749 /*---------------------------------------------------------------------------*/
00750 
00751 static int vircam_pfits_get_double(const cpl_propertylist *plist, 
00752                                    const char *key, double *fval) {
00753     cpl_type type;
00754     const char *fctid = "vircam_pfits_get_float";
00755 
00756     /* Get the type of this keyword */
00757 
00758     type = cpl_propertylist_get_type(plist,key);
00759     if (cpl_error_get_code() != CPL_ERROR_NONE) {
00760         *fval = 0.0;
00761         cpl_error_reset();
00762         return(VIR_FATAL);
00763     }
00764 
00765     /* Switch of the property type */
00766 
00767     switch (type) {
00768     case CPL_TYPE_FLOAT:
00769         *fval = (double)cpl_propertylist_get_float(plist,key);
00770         break;
00771     case CPL_TYPE_DOUBLE:
00772         *fval = cpl_propertylist_get_double(plist,key);
00773         break;
00774     default:
00775         *fval = 0.0;
00776         cpl_msg_error(fctid,"Keyword %s is not floating point in header",key);
00777         return(VIR_FATAL);
00778     }
00779     return(VIR_OK);
00780 }
00781 
00784 /* 
00785 
00786 $Log: vircam_pfits.c,v $
00787 Revision 1.33  2010/09/09 12:11:09  jim
00788 Fixed problems with docs that make doxygen barf
00789 
00790 Revision 1.32  2010/03/09 16:48:14  jim
00791 Restored get_gain but with different keyword
00792 
00793 Revision 1.31  2010/03/09 14:30:45  jim
00794 Removed redundant routine
00795 
00796 Revision 1.30  2009/02/20 10:58:14  jim
00797 Added vircam_pfits_get_njsteps and vircam_pfits_get_jitteri. Tidied up some
00798 comments
00799 
00800 Revision 1.29  2008/12/08 06:41:56  jim
00801 Added vircam_pfits_get_ra and vircam_pfits_get_dec
00802 
00803 Revision 1.28  2008/11/21 10:11:48  jim
00804 Added vircam_pfits_get_pv25
00805 
00806 Revision 1.27  2008/10/21 08:41:34  jim
00807 Saturation is now floating point
00808 
00809 Revision 1.26  2007/11/22 12:35:33  jim
00810 Modified vircam_pfits_get_saturation so that the value of the
00811 saturation is read as an integer, but passed back as a float
00812 
00813 Revision 1.25  2007/11/20 09:39:39  jim
00814 added vircam_pfits_get_mjd
00815 
00816 Revision 1.24  2007/11/14 10:45:23  jim
00817 Added vircam_pfits_get_saturation
00818 
00819 Revision 1.23  2007/10/25 17:34:01  jim
00820 Modified to remove lint warnings
00821 
00822 Revision 1.22  2007/10/19 09:25:10  jim
00823 Fixed problems with missing includes
00824 
00825 Revision 1.21  2007/03/23 10:53:22  jim
00826 Fixed little documentation errors
00827 
00828 Revision 1.20  2007/03/01 12:42:42  jim
00829 Modified slightly after code checking
00830 
00831 Revision 1.19  2006/07/17 09:33:00  jim
00832 Changed keyword for detlive routine
00833 
00834 Revision 1.18  2006/07/11 14:52:13  jim
00835 Added vircam_pfits_get_detlive
00836 
00837 Revision 1.17  2006/06/20 19:00:06  jim
00838 Added vircam_pfits_get_ndit
00839 
00840 Revision 1.16  2006/06/13 14:08:12  jim
00841 Added vircam_pfits_get_gain
00842 
00843 Revision 1.15  2006/06/09 11:26:26  jim
00844 Small changes to keep lint happy
00845 
00846 Revision 1.14  2006/05/24 13:35:23  jim
00847 Added _get_nusteps, _get_ustepnum, _get_jitternum and _get_filter
00848 
00849 Revision 1.13  2006/05/17 12:05:48  jim
00850 Add vircam_pfits_get_airmass
00851 
00852 Revision 1.12  2006/05/15 13:15:11  jim
00853 Added vircam_pfits_j[x,y]off
00854 
00855 Revision 1.11  2006/04/21 15:17:48  jim
00856 Added vircam_pfits_get_float and vircam_pfits_get_double static routines
00857 
00858 Revision 1.10  2006/03/01 10:59:25  jim
00859 Added vircam_pfits_get_ditdelay
00860 
00861 Revision 1.9  2006/02/18 11:48:03  jim
00862 added routines to get mindit and chip number
00863 
00864 Revision 1.8  2006/01/23 10:30:49  jim
00865 Mainly documentation mods
00866 
00867 Revision 1.7  2005/12/14 22:17:33  jim
00868 Updated docs
00869 
00870 Revision 1.6  2005/11/25 15:33:22  jim
00871 Some code fixes to keep splint happy
00872 
00873 Revision 1.5  2005/11/25 09:56:15  jim
00874 Tidied up some more documentation
00875 
00876 Revision 1.4  2005/11/07 13:15:16  jim
00877 Fixed lots of bugs and added some error checking
00878 
00879 Revision 1.3  2005/11/07 11:23:41  jim
00880 fixed call to cpl_error_get_code
00881 
00882 Revision 1.2  2005/11/03 13:28:50  jim
00883 All sorts of changes to tighten up error handling
00884 
00885 Revision 1.1.1.1  2005/08/05 08:29:09  jim
00886 Initial import
00887 
00888 
00889 */

Generated on 15 Mar 2012 for VIRCAM Pipeline by  doxygen 1.6.1