00001 /* * 00002 * This file is part of the ESO UVES Pipeline * 00003 * Copyright (C) 2004,2005 European Southern Observatory * 00004 * * 00005 * This library is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the Free Software * 00017 * Foundation, 51 Franklin St, Fifth Floor, Boston MA 02110-1301 USA * 00018 */ 00019 00020 /* 00021 * $Author: jmlarsen $ 00022 * $Date: 2007/08/21 13:08:26 $ 00023 * $Revision: 1.6 $ 00024 * $Name: uves-3_4_5 $ 00025 * $Log: uves_cal_mkmaster_impl.c,v $ 00026 * Revision 1.6 2007/08/21 13:08:26 jmlarsen 00027 * Removed irplib_access module, largely deprecated by CPL-4 00028 * 00029 * Revision 1.5 2007/06/11 13:28:26 jmlarsen 00030 * Changed recipe contact address to cpl at eso.org 00031 * 00032 * Revision 1.4 2007/06/08 13:06:16 jmlarsen 00033 * Send bug reports to Andrea 00034 * 00035 * Revision 1.3 2007/06/06 08:17:33 amodigli 00036 * replace tab with 4 spaces 00037 * 00038 * Revision 1.2 2007/05/14 08:09:48 amodigli 00039 * updated input frames and tag description in recipe man page 00040 * 00041 * Revision 1.1 2007/02/09 13:34:25 jmlarsen 00042 * Added mkmaster+spatred recipes 00043 * 00044 * Revision 1.37 2006/12/08 07:41:43 jmlarsen 00045 * Minor doc. change 00046 * 00047 * Revision 1.36 2006/11/15 15:02:14 jmlarsen 00048 * Implemented const safe workarounds for CPL functions 00049 * 00050 * Revision 1.34 2006/11/15 14:04:08 jmlarsen 00051 * Removed non-const version of parameterlist_get_first/last/next which is already 00052 * in CPL, added const-safe wrapper, unwrapper and deallocator functions 00053 * 00054 * Revision 1.33 2006/11/15 08:57:32 amodigli 00055 * clearer message on slit FF encoder positions 00056 * 00057 * Revision 1.32 2006/11/13 12:45:32 jmlarsen 00058 * Count SFLAT sets from 1 rather than 0 00059 * 00060 * Revision 1.31 2006/11/06 15:19:41 jmlarsen 00061 * Removed unused include directives 00062 * 00063 * Revision 1.30 2006/11/03 14:57:44 jmlarsen 00064 * Changed message 00065 * 00066 * Revision 1.29 2006/10/17 12:33:02 jmlarsen 00067 * Added semicolon at UVES_RECIPE_DEFINE invocation 00068 * 00069 * Revision 1.28 2006/10/09 13:01:13 jmlarsen 00070 * Use macro to define recipe interface functions 00071 * 00072 * Revision 1.27 2006/09/27 13:20:51 jmlarsen 00073 * Factored out flat reduction 00074 * 00075 * Revision 1.26 2006/09/19 14:31:20 jmlarsen 00076 * uves_insert_frame(): use bitmap to specify which image statistics keywords must be computed 00077 * 00078 * Revision 1.25 2006/09/19 06:55:58 jmlarsen 00079 * Changed interface of uves_frameset to optionally write image statistics kewwords 00080 * 00081 * Revision 1.24 2006/09/14 08:46:51 jmlarsen 00082 * Added support for TFLAT, SCREEN_FLAT frames 00083 * 00084 * Revision 1.23 2006/08/24 11:36:37 jmlarsen 00085 * Write recipe start/stop time to header 00086 * 00087 * Revision 1.22 2006/08/17 13:56:53 jmlarsen 00088 * Reduced max line length 00089 * 00090 * Revision 1.21 2006/08/11 14:56:05 amodigli 00091 * removed Doxygen warnings 00092 * 00093 * Revision 1.20 2006/07/14 12:19:28 jmlarsen 00094 * Support multiple QC tests per product 00095 * 00096 * Revision 1.19 2006/07/03 13:09:24 amodigli 00097 * adjusted description display layout 00098 * 00099 * Revision 1.18 2006/07/03 13:02:18 jmlarsen 00100 * Threshold to zero after bias subtraction 00101 * 00102 * Revision 1.17 2006/06/16 08:25:45 jmlarsen 00103 * Manually propagate ESO.DET. keywords from 1st/2nd input header 00104 * 00105 * Revision 1.16 2006/06/13 11:57:02 jmlarsen 00106 * Check that calibration frames are from the same chip ID 00107 * 00108 * Revision 1.15 2006/06/01 14:21:27 amodigli 00109 * frm --> frm_tmp, dup --> frm_dup 00110 * 00111 * Revision 1.14 2006/06/01 12:02:56 jmlarsen 00112 * Return proper error_code in the function uves_mflat 00113 * 00114 * Revision 1.13 2006/05/22 10:01:04 amodigli 00115 * fixed some bug in msflat generation 00116 * 00117 * Revision 1.12 2006/05/22 06:47:15 amodigli 00118 * fixed some bugs on msflat 00119 * 00120 * Revision 1.10 2006/05/19 13:07:52 amodigli 00121 * modified to support SFLATs 00122 * 00123 * Revision 1.9 2006/05/17 09:58:25 amodigli 00124 * fixed warning 00125 * 00126 * Revision 1.8 2006/05/17 09:56:36 amodigli 00127 * fixed syntax bug 00128 * 00129 * Revision 1.7 2006/05/17 09:54:55 amodigli 00130 * added supposr SFLATs 00131 * 00132 * Revision 1.6 2006/05/09 07:42:18 amodigli 00133 * added QC-LOG 00134 * 00135 * Revision 1.5 2006/04/06 12:57:43 jmlarsen 00136 * Added support for IFLAT, DFLAT -> MASTER_IFLAT, MASTER_DFLAT frames 00137 * 00138 * Revision 1.4 2006/04/06 09:48:15 amodigli 00139 * changed uves_frameset_insert interface to have QC log 00140 * 00141 * Revision 1.3 2006/04/06 08:37:48 jmlarsen 00142 * Support reading MASTER_PDARK 00143 * 00144 * Revision 1.2 2006/03/24 14:15:18 jmlarsen 00145 * Save intermediate result to disk 00146 * 00147 * Revision 1.1 2006/02/03 07:46:30 jmlarsen 00148 * Moved recipe implementations to ./uves directory 00149 * 00150 * Revision 1.39 2006/01/19 08:47:24 jmlarsen 00151 * Inserted missing doxygen end tag 00152 * 00153 * Revision 1.38 2005/12/19 16:17:55 jmlarsen 00154 * Replaced bool -> int 00155 * 00156 */ 00157 00158 #ifdef HAVE_CONFIG_H 00159 # include <config.h> 00160 #endif 00161 00162 /*----------------------------------------------------------------------------*/ 00169 /*----------------------------------------------------------------------------*/ 00170 00171 /*----------------------------------------------------------------------------- 00172 Includes 00173 -----------------------------------------------------------------------------*/ 00174 00175 #include <uves_reduce_mflat.h> 00176 #include <uves_mbias_impl.h> 00177 #include <uves_mdark_impl.h> 00178 #include <uves_dfs.h> 00179 #include <uves_parameters.h> 00180 #include <uves_recipe.h> 00181 #include <uves.h> 00182 #include <uves_error.h> 00183 00184 #include <cpl.h> 00185 00186 /*----------------------------------------------------------------------------- 00187 Functions prototypes 00188 -----------------------------------------------------------------------------*/ 00189 00190 static int uves_cal_mkmaster_define_parameters(cpl_parameterlist *parameters); 00191 00192 /*----------------------------------------------------------------------------- 00193 Recipe standard code 00194 -----------------------------------------------------------------------------*/ 00195 #define cpl_plugin_get_info uves_cal_mkmaster_get_info 00196 UVES_RECIPE_DEFINE( 00197 UVES_MKMASTER_ID, UVES_MKMASTER_DOM, uves_cal_mkmaster_define_parameters, 00198 "Jonas M. Larsen", "cpl@eso.org", 00199 "Creates the master bias/dark/flat frame", 00200 "This recipe calls " make_str(UVES_MBIAS_ID) " if any raw BIAS frame is provided\n" 00201 "otherwise " make_str(UVES_MDARK_ID) " if any raw DARK frame is provided, otherwise\n" 00202 "it calls " make_str(UVES_MFLAT_ID) " Pls refer to those recipes for more details\n"); 00203 00205 /*----------------------------------------------------------------------------- 00206 Functions code 00207 -----------------------------------------------------------------------------*/ 00208 /*----------------------------------------------------------------------------*/ 00214 /*----------------------------------------------------------------------------*/ 00215 static int 00216 uves_cal_mkmaster_define_parameters(cpl_parameterlist *parameters) 00217 { 00218 return uves_mflat_define_parameters_body(parameters, 00219 make_str(UVES_MKMASTER_ID)); 00220 /* Warning: If parameters are added to mbias/mdark recipes, they need to 00221 be propagated to here. Now, just copy the parameters from mflat */ 00222 } 00223 00224 /*----------------------------------------------------------------------------*/ 00233 /*----------------------------------------------------------------------------*/ 00234 static void 00235 IRPLIB_CONCAT2X(UVES_MKMASTER_ID,exe)(cpl_frameset *frames, 00236 const cpl_parameterlist *parameters, 00237 const char *starttime) 00238 { 00239 int blue; 00240 bool found_bias = false; 00241 bool found_dark = false; 00242 bool found_flat = false; 00243 00244 assure( frames != NULL, CPL_ERROR_NULL_INPUT, "Null frameset given!"); 00245 00246 for (blue = 0; blue <= 1; blue++) 00247 { 00248 found_bias = found_bias || cpl_frameset_find(frames, UVES_BIAS(blue)); 00249 found_dark = found_dark || cpl_frameset_find(frames, UVES_DARK(blue)); 00250 found_dark = found_dark || cpl_frameset_find(frames, UVES_PDARK(blue)); 00251 found_flat = found_flat || cpl_frameset_find(frames, UVES_FLAT(blue)); 00252 found_flat = found_flat || cpl_frameset_find(frames, UVES_IFLAT(blue)); 00253 found_flat = found_flat || cpl_frameset_find(frames, UVES_DFLAT(blue)); 00254 found_flat = found_flat || cpl_frameset_find(frames, UVES_SFLAT(blue)); 00255 found_flat = found_flat || cpl_frameset_find(frames, UVES_TFLAT(blue)); 00256 found_flat = found_flat || cpl_frameset_find(frames, UVES_SCREEN_FLAT(blue)); 00257 } 00258 00259 if (found_bias) 00260 { 00261 uves_msg("Bias frame(s) provided"); 00262 } 00263 00264 if (found_dark) 00265 { 00266 uves_msg("Dark frame(s) provided"); 00267 } 00268 00269 if (found_flat) 00270 { 00271 uves_msg("Flat frame(s) provided"); 00272 } 00273 00274 assure( found_bias || found_dark || found_flat, 00275 CPL_ERROR_DATA_NOT_FOUND, 00276 "Missing raw bias, dark or flat-field frames"); 00277 00278 if (found_bias && found_dark) 00279 { 00280 uves_msg_warning("Both bias and dark frames provided. Creating only master bias"); 00281 } 00282 else if (found_bias && found_flat) 00283 { 00284 uves_msg_warning("Both bias and flat frames provided. Creating only master bias"); 00285 } 00286 else if (found_dark && found_flat) 00287 { 00288 uves_msg_warning("Both dark and flat frames provided. Creating only master dark"); 00289 } 00290 00291 if (found_bias) 00292 { 00293 uves_mbias_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00294 } 00295 else if (found_dark) 00296 { 00297 uves_mdark_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00298 } 00299 else if (found_flat) 00300 { 00301 uves_mflat_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00302 } 00303 else 00304 { 00305 /* Impossible */ 00306 passure( false, "%d %d %d", found_bias, found_dark, found_flat); 00307 } 00308 00309 cleanup: 00310 return; 00311 } 00312
1.5.1