vircam_nditcor.c

00001 /* $Id: vircam_nditcor.c,v 1.4 2009/05/20 12:18:42 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: 2009/05/20 12:18:42 $
00024  * $Revision: 1.4 $
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 "vircam_mods.h"
00036 #include "vircam_utils.h"
00037 #include "vircam_fits.h"
00038 
00041 /*---------------------------------------------------------------------------*/
00081 /*---------------------------------------------------------------------------*/
00082 
00083 extern int vircam_nditcor(vir_fits *infile, int ndit, int *status) {
00084     cpl_image *im;
00085     double dnd,exptime;
00086     cpl_propertylist *oplist;
00087     char comment[32];
00088 
00089     /* Inherited status */
00090 
00091     if (*status != VIR_OK)
00092         return(*status);
00093 
00094     /* Do we need to be here? */
00095 
00096     if (cpl_propertylist_has(vircam_fits_get_ehu(infile),"ESO DRS NDITCOR"))
00097         return(*status);
00098 
00099     /* Get the image and the scale factor */
00100     
00101     im = vircam_fits_get_image(infile);
00102     dnd = (float)ndit;
00103     
00104     /* Divide it through... */
00105 
00106     cpl_image_divide_scalar(im,dnd);
00107 
00108     /* Now put some stuff in the DRS extension and update the exposure
00109        time to reflect this correction. The latter has to be done in
00110        both the extension and primary headers */
00111 
00112     oplist = vircam_fits_get_ehu(infile);
00113     if (oplist != NULL) {
00114         cpl_propertylist_update_bool(oplist,"ESO DRS NDITCOR",1);
00115         (void)sprintf(comment,"Corrected for ndit=%d",ndit);
00116         cpl_propertylist_set_comment(oplist,"ESO DRS NDITCOR",comment);
00117         exptime = cpl_propertylist_get_double(oplist,"EXPTIME");
00118         exptime /= dnd;
00119         cpl_propertylist_update_double(oplist,"EXPTIME",exptime);
00120         cpl_propertylist_set_comment(oplist,"EXPTIME",comment);
00121     } 
00122     oplist = vircam_fits_get_phu(infile);
00123     if (oplist != NULL) {
00124         (void)sprintf(comment,"Corrected for ndit=%d",ndit);
00125         exptime = cpl_propertylist_get_double(oplist,"EXPTIME");
00126         exptime /= dnd;
00127         cpl_propertylist_update_double(oplist,"EXPTIME",exptime);
00128         cpl_propertylist_set_comment(oplist,"EXPTIME",comment);
00129     } 
00130 
00131     /* Get out of here */
00132 
00133     GOOD_STATUS
00134 }
00135 
00136 
00139 /*
00140 
00141 $Log: vircam_nditcor.c,v $
00142 Revision 1.4  2009/05/20 12:18:42  jim
00143 Modified so that if the operation is already done, then it just returns
00144 
00145 Revision 1.3  2009/02/20 10:55:20  jim
00146 removed unnecessary declaration
00147 
00148 Revision 1.2  2009/01/20 09:31:37  jim
00149 Fixed typo
00150 
00151 Revision 1.1  2009/01/19 14:32:57  jim
00152 New routine
00153 
00154 
00155 */

Generated on 15 Mar 2012 for VIRCAM Pipeline by  doxygen 1.6.1