VIRCAM Pipeline 2.3.15
casu_flatcor.c
1/* $Id: casu_flatcor.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 "casu_mods.h"
35#include "catalogue/casu_utils.h"
36#include "catalogue/casu_fits.h"
37
40/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79extern int casu_flatcor(casu_fits *infile, casu_fits *flatsrc, int *status) {
80 cpl_error_code cpl_retval;
81 cpl_image *i,*f;
82 cpl_propertylist *oplist;
83 const char *fctid = "casu_flatcor";
84
85 /* Inherited status */
86
87 if (*status != CASU_OK)
88 return(*status);
89
90 /* Do we even need to be here */
91
92 oplist = casu_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 = casu_fits_get_image(infile);
99 f = casu_fits_get_image(flatsrc);
100 if (casu_compare_dims(i,f) != CASU_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 cpl_error_reset();
113 WARN_CONTINUE
114 break;
115 default:
116 FATAL_ERROR
117 }
118
119 /* Now put some stuff in the DRS extension... */
120
121 oplist = casu_fits_get_ehu(infile);
122 if (oplist != NULL) {
123 if (casu_fits_get_fullname(flatsrc) != NULL) {
124 cpl_propertylist_update_string(oplist,"ESO DRS FLATCOR",
125 casu_fits_get_fullname(flatsrc));
126 cpl_propertylist_set_comment(oplist,"ESO DRS FLATCOR",
127 "Image used in flat correction");
128 } else {
129 cpl_propertylist_update_string(oplist,"ESO DRS FLATCOR",
130 "Memory File");
131 }
132 } else
133 WARN_CONTINUE
134
135 /* Get out of here */
136
137 return(*status);
138}
139
140
143/*
144
145$Log: casu_flatcor.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.5 2015/01/29 11:48:15 jim
153modified comments
154
155Revision 1.4 2014/04/09 09:09:51 jim
156Detabbed
157
158Revision 1.3 2014/03/26 15:39:19 jim
159Fixed so that input flat could be a memory file
160
161Revision 1.2 2013/11/21 09:38:13 jim
162detabbed
163
164Revision 1.1.1.1 2013-08-27 12:07:48 jim
165Imported
166
167
168*/
cpl_image * casu_fits_get_image(casu_fits *p)
Definition: casu_fits.c:436
char * casu_fits_get_fullname(casu_fits *p)
Definition: casu_fits.c:680
cpl_propertylist * casu_fits_get_ehu(casu_fits *p)
Definition: casu_fits.c:576
int casu_flatcor(casu_fits *infile, casu_fits *flatsrc, int *status)
Correct input data for flat field response.
Definition: casu_flatcor.c:79
int casu_compare_dims(cpl_image *im1, cpl_image *im2)
Compare dimensions of two 2d images.
Definition: casu_utils.c:713