VIRCAM Pipeline  1.3.4
vircam_nditcor.c
1 /* $Id: vircam_nditcor.c,v 1.4 2009-05-20 12:18:42 jim Exp $
2  *
3  * This file is part of the VIRCAM Pipeline
4  * Copyright (C) 2005 Cambridge Astronomy Survey Unit
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: jim $
23  * $Date: 2009-05-20 12:18:42 $
24  * $Revision: 1.4 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 /* Includes */
29 
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 #include <cpl.h>
35 #include "vircam_mods.h"
36 #include "vircam_utils.h"
37 #include "vircam_fits.h"
38 
41 /*---------------------------------------------------------------------------*/
81 /*---------------------------------------------------------------------------*/
82 
83 extern int vircam_nditcor(vir_fits *infile, int ndit, int *status) {
84  cpl_image *im;
85  double dnd,exptime;
86  cpl_propertylist *oplist;
87  char comment[32];
88 
89  /* Inherited status */
90 
91  if (*status != VIR_OK)
92  return(*status);
93 
94  /* Do we need to be here? */
95 
96  if (cpl_propertylist_has(vircam_fits_get_ehu(infile),"ESO DRS NDITCOR"))
97  return(*status);
98 
99  /* Get the image and the scale factor */
100 
101  im = vircam_fits_get_image(infile);
102  dnd = (float)ndit;
103 
104  /* Divide it through... */
105 
106  cpl_image_divide_scalar(im,dnd);
107 
108  /* Now put some stuff in the DRS extension and update the exposure
109  time to reflect this correction. The latter has to be done in
110  both the extension and primary headers */
111 
112  oplist = vircam_fits_get_ehu(infile);
113  if (oplist != NULL) {
114  cpl_propertylist_update_bool(oplist,"ESO DRS NDITCOR",1);
115  (void)sprintf(comment,"Corrected for ndit=%d",ndit);
116  cpl_propertylist_set_comment(oplist,"ESO DRS NDITCOR",comment);
117  exptime = cpl_propertylist_get_double(oplist,"EXPTIME");
118  exptime /= dnd;
119  cpl_propertylist_update_double(oplist,"EXPTIME",exptime);
120  cpl_propertylist_set_comment(oplist,"EXPTIME",comment);
121  }
122  oplist = vircam_fits_get_phu(infile);
123  if (oplist != NULL) {
124  (void)sprintf(comment,"Corrected for ndit=%d",ndit);
125  exptime = cpl_propertylist_get_double(oplist,"EXPTIME");
126  exptime /= dnd;
127  cpl_propertylist_update_double(oplist,"EXPTIME",exptime);
128  cpl_propertylist_set_comment(oplist,"EXPTIME",comment);
129  }
130 
131  /* Get out of here */
132 
133  GOOD_STATUS
134 }
135 
136 
139 /*
140 
141 $Log: not supported by cvs2svn $
142 Revision 1.3 2009/02/20 10:55:20 jim
143 removed unnecessary declaration
144 
145 Revision 1.2 2009/01/20 09:31:37 jim
146 Fixed typo
147 
148 Revision 1.1 2009/01/19 14:32:57 jim
149 New routine
150 
151 
152 */
cpl_image * vircam_fits_get_image(vir_fits *p)
Definition: vircam_fits.c:349
cpl_propertylist * vircam_fits_get_phu(vir_fits *p)
Definition: vircam_fits.c:416
int vircam_nditcor(vir_fits *infile, int ndit, int *status)
Correct input data for dark current.
cpl_propertylist * vircam_fits_get_ehu(vir_fits *p)
Definition: vircam_fits.c:457