VIRCAM Pipeline  1.3.3
vircam/vircam_flatcor.c
1 /* $Id: vircam_flatcor.c,v 1.19 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.19 $
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 "vircam_mods.h"
35 #include "vircam_utils.h"
36 #include "vircam_fits.h"
37 
40 /*---------------------------------------------------------------------------*/
77 /*---------------------------------------------------------------------------*/
78 
79 extern int vircam_flatcor(vir_fits *infile, vir_fits *flatsrc, int *status) {
80  cpl_error_code cpl_retval;
81  cpl_image *i,*f;
82  cpl_propertylist *oplist;
83  const char *fctid = "vircam_flatcor";
84 
85  /* Inherited status */
86 
87  if (*status != VIR_OK)
88  return(*status);
89 
90  /* Do we even need to be here */
91 
92  oplist = vircam_fits_get_ehu(infile);
93  if (cpl_propertylist_has(oplist,"ESO DRS FLATCOR"))
94  return(*status);
95 
96  /* Get the images and check the dimensions of each */
97 
98  i = vircam_fits_get_image(infile);
99  f = vircam_fits_get_image(flatsrc);
100  if (vircam_compare_dims(i,f) != VIR_OK) {
101  cpl_msg_error(fctid,"Object and flat data array dimensions don't match");
102  FATAL_ERROR
103  }
104 
105  /* Use the cpl image routine to do the arithmetic */
106 
107  cpl_retval = cpl_image_divide(i,f);
108  switch (cpl_retval) {
109  case CPL_ERROR_NONE:
110  break;
111  case CPL_ERROR_DIVISION_BY_ZERO:
112  WARN_CONTINUE
113  break;
114  default:
115  FATAL_ERROR
116  }
117 
118  /* Now put some stuff in the DRS extension... */
119 
120  oplist = vircam_fits_get_ehu(infile);
121  if (oplist != NULL) {
122  cpl_propertylist_update_string(oplist,"ESO DRS FLATCOR",
123  vircam_fits_get_fullname(flatsrc));
124  cpl_propertylist_set_comment(oplist,"ESO DRS FLATCOR",
125  "Image used in flat correction");
126  } else
127  WARN_CONTINUE
128 
129  /* Get out of here */
130 
131  GOOD_STATUS
132 }
133 
134 
137 /*
138 
139 $Log: not supported by cvs2svn $
140 Revision 1.18 2007/10/25 17:34:00 jim
141 Modified to remove lint warnings
142 
143 Revision 1.17 2007/03/29 12:19:39 jim
144 Little changes to improve documentation
145 
146 Revision 1.16 2007/03/01 12:42:41 jim
147 Modified slightly after code checking
148 
149 Revision 1.15 2006/04/20 11:18:23 jim
150 Now adds an extension name to the error messages rather than an extension number
151 
152 Revision 1.14 2006/03/23 21:18:47 jim
153 Minor changes mainly to comment headers
154 
155 Revision 1.13 2006/03/22 13:36:50 jim
156 cosmetic changes to keep lint happy
157 
158 Revision 1.12 2006/03/22 11:39:23 jim
159 fixed stupid bug
160 
161 Revision 1.11 2006/03/17 13:55:19 jim
162 Added comments to DRS keywords
163 
164 Revision 1.10 2006/03/15 10:43:41 jim
165 Fixed a few things
166 
167 Revision 1.9 2006/03/08 14:32:21 jim
168 Lots of little modifications
169 
170 Revision 1.8 2006/03/06 13:49:08 jim
171 Modified so that the DRS keywords are written directly to the extension header
172 for the input image
173 
174 Revision 1.7 2006/03/01 10:31:28 jim
175 Now uses new vir_fits objects
176 
177 Revision 1.6 2006/01/23 10:30:49 jim
178 Mainly documentation mods
179 
180 Revision 1.5 2006/01/03 10:30:04 jim
181 Given inherited status
182 
183 Revision 1.4 2006/01/03 10:11:28 jim
184 Modified to be slightly higher level than originally written. Now write
185 info to an output property list
186 
187 Revision 1.3 2005/12/14 22:17:33 jim
188 Updated docs
189 
190 Revision 1.2 2005/11/25 09:56:14 jim
191 Tidied up some more documentation
192 
193 Revision 1.1 2005/09/13 13:33:58 jim
194 Forgot to add these
195 
196 
197 */