00001 /* $Id: vircam_flatcor.c,v 1.19 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.19 $ 00025 * $Name: v1-1-0 $ 00026 */ 00027 00028 /* Includes */ 00029 00030 #ifdef HAVE_CONFIG_H 00031 #include <config.h> 00032 #endif 00033 00034 #include "vircam_mods.h" 00035 #include "vircam_utils.h" 00036 #include "vircam_fits.h" 00037 00040 /*---------------------------------------------------------------------------*/ 00077 /*---------------------------------------------------------------------------*/ 00078 00079 extern int vircam_flatcor(vir_fits *infile, vir_fits *flatsrc, int *status) { 00080 cpl_error_code cpl_retval; 00081 cpl_image *i,*f; 00082 cpl_propertylist *oplist; 00083 const char *fctid = "vircam_flatcor"; 00084 00085 /* Inherited status */ 00086 00087 if (*status != VIR_OK) 00088 return(*status); 00089 00090 /* Do we even need to be here */ 00091 00092 oplist = vircam_fits_get_ehu(infile); 00093 if (cpl_propertylist_has(oplist,"ESO DRS FLATCOR")) 00094 return(*status); 00095 00096 /* Get the images and check the dimensions of each */ 00097 00098 i = vircam_fits_get_image(infile); 00099 f = vircam_fits_get_image(flatsrc); 00100 if (vircam_compare_dims(i,f) != VIR_OK) { 00101 cpl_msg_error(fctid,"Object and flat data array dimensions don't match"); 00102 FATAL_ERROR 00103 } 00104 00105 /* Use the cpl image routine to do the arithmetic */ 00106 00107 cpl_retval = cpl_image_divide(i,f); 00108 switch (cpl_retval) { 00109 case CPL_ERROR_NONE: 00110 break; 00111 case CPL_ERROR_DIVISION_BY_ZERO: 00112 WARN_CONTINUE 00113 break; 00114 default: 00115 FATAL_ERROR 00116 } 00117 00118 /* Now put some stuff in the DRS extension... */ 00119 00120 oplist = vircam_fits_get_ehu(infile); 00121 if (oplist != NULL) { 00122 cpl_propertylist_update_string(oplist,"ESO DRS FLATCOR", 00123 vircam_fits_get_fullname(flatsrc)); 00124 cpl_propertylist_set_comment(oplist,"ESO DRS FLATCOR", 00125 "Image used in flat correction"); 00126 } else 00127 WARN_CONTINUE 00128 00129 /* Get out of here */ 00130 00131 GOOD_STATUS 00132 } 00133 00134 00137 /* 00138 00139 $Log: vircam_flatcor.c,v $ 00140 Revision 1.19 2009/05/20 12:18:42 jim 00141 Modified so that if the operation is already done, then it just returns 00142 00143 Revision 1.18 2007/10/25 17:34:00 jim 00144 Modified to remove lint warnings 00145 00146 Revision 1.17 2007/03/29 12:19:39 jim 00147 Little changes to improve documentation 00148 00149 Revision 1.16 2007/03/01 12:42:41 jim 00150 Modified slightly after code checking 00151 00152 Revision 1.15 2006/04/20 11:18:23 jim 00153 Now adds an extension name to the error messages rather than an extension number 00154 00155 Revision 1.14 2006/03/23 21:18:47 jim 00156 Minor changes mainly to comment headers 00157 00158 Revision 1.13 2006/03/22 13:36:50 jim 00159 cosmetic changes to keep lint happy 00160 00161 Revision 1.12 2006/03/22 11:39:23 jim 00162 fixed stupid bug 00163 00164 Revision 1.11 2006/03/17 13:55:19 jim 00165 Added comments to DRS keywords 00166 00167 Revision 1.10 2006/03/15 10:43:41 jim 00168 Fixed a few things 00169 00170 Revision 1.9 2006/03/08 14:32:21 jim 00171 Lots of little modifications 00172 00173 Revision 1.8 2006/03/06 13:49:08 jim 00174 Modified so that the DRS keywords are written directly to the extension header 00175 for the input image 00176 00177 Revision 1.7 2006/03/01 10:31:28 jim 00178 Now uses new vir_fits objects 00179 00180 Revision 1.6 2006/01/23 10:30:49 jim 00181 Mainly documentation mods 00182 00183 Revision 1.5 2006/01/03 10:30:04 jim 00184 Given inherited status 00185 00186 Revision 1.4 2006/01/03 10:11:28 jim 00187 Modified to be slightly higher level than originally written. Now write 00188 info to an output property list 00189 00190 Revision 1.3 2005/12/14 22:17:33 jim 00191 Updated docs 00192 00193 Revision 1.2 2005/11/25 09:56:14 jim 00194 Tidied up some more documentation 00195 00196 Revision 1.1 2005/09/13 13:33:58 jim 00197 Forgot to add these 00198 00199 00200 */