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