VIRCAM Pipeline 2.3.12
casu_nditcor.c
1/* $Id: casu_nditcor.c,v 1.2 2015/08/07 13:06:54 jim Exp $
2 *
3 * This file is part of the CASU Pipeline utilities
4 * Copyright (C) 2015 European Southern Observatory
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: 2015/08/07 13:06:54 $
24 * $Revision: 1.2 $
25 * $Name: $
26 */
27
28/* Includes */
29
30#ifdef HAVE_CONFIG_H
31#include <config.h>
32#endif
33
34#include <cpl.h>
35#include "casu_mods.h"
36#include "catalogue/casu_utils.h"
37#include "catalogue/casu_fits.h"
38
41/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85extern int casu_nditcor(casu_fits *infile, int ndit, const char *expkey,
86 int *status) {
87 cpl_image *im;
88 double dnd,exptime;
89 cpl_propertylist *oplist;
90 char comment[32];
91
92 /* Inherited status */
93
94 if (*status != CASU_OK)
95 return(*status);
96
97 /* Do we need to be here? */
98
99 if (cpl_propertylist_has(casu_fits_get_ehu(infile),"ESO DRS NDITCOR"))
100 return(*status);
101
102 /* Get the image and the scale factor */
103
104 im = casu_fits_get_image(infile);
105 dnd = (float)ndit;
106
107 /* Divide it through... */
108
109 cpl_image_divide_scalar(im,dnd);
110
111 /* Now put some stuff in the DRS extension and update the exposure
112 time to reflect this correction. The latter has to be done in
113 both the extension and primary headers */
114
115 oplist = casu_fits_get_ehu(infile);
116 if (oplist != NULL) {
117 cpl_propertylist_update_bool(oplist,"ESO DRS NDITCOR",1);
118 (void)sprintf(comment,"Corrected for ndit=%d",ndit);
119 cpl_propertylist_set_comment(oplist,"ESO DRS NDITCOR",comment);
120 if (cpl_propertylist_has(oplist,expkey)) {
121 exptime = cpl_propertylist_get_double(oplist,expkey);
122 exptime /= dnd;
123 cpl_propertylist_update_double(oplist,expkey,exptime);
124 cpl_propertylist_set_comment(oplist,expkey,comment);
125 }
126 }
127 oplist = casu_fits_get_phu(infile);
128 if (oplist != NULL && cpl_propertylist_has(oplist,expkey)) {
129 (void)sprintf(comment,"Corrected for ndit=%d",ndit);
130 exptime = cpl_propertylist_get_double(oplist,expkey);
131 exptime /= dnd;
132 cpl_propertylist_update_double(oplist,expkey,exptime);
133 cpl_propertylist_set_comment(oplist,expkey,comment);
134 }
135
136 /* Get out of here */
137
138 GOOD_STATUS
139}
140
143/*
144
145$Log: casu_nditcor.c,v $
146Revision 1.2 2015/08/07 13:06:54 jim
147Fixed copyright to ESO
148
149Revision 1.1.1.1 2015/06/12 10:44:32 jim
150Initial import
151
152Revision 1.4 2015/06/09 18:35:34 jim
153Fixed exptime property
154
155Revision 1.3 2015/01/29 11:51:56 jim
156modified comments
157
158Revision 1.2 2013/11/21 09:38:14 jim
159detabbed
160
161Revision 1.1.1.1 2013-08-27 12:07:48 jim
162Imported
163
164*/
cpl_image * casu_fits_get_image(casu_fits *p)
Definition: casu_fits.c:436
cpl_propertylist * casu_fits_get_phu(casu_fits *p)
Definition: casu_fits.c:531
cpl_propertylist * casu_fits_get_ehu(casu_fits *p)
Definition: casu_fits.c:576
int casu_nditcor(casu_fits *infile, int ndit, const char *expkey, int *status)
Correct input data for number of dits.
Definition: casu_nditcor.c:85