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: amodigli $ 00022 * $Date: 2010/12/16 16:57:23 $ 00023 * $Revision: 1.11 $ 00024 * $Name: uves-4_9_1 $ 00025 * $Log: uves_cal_mkmaster_impl.c,v $ 00026 * Revision 1.11 2010/12/16 16:57:23 amodigli 00027 * fixed compiler warnings 00028 * 00029 * Revision 1.10 2010/09/24 09:32:02 amodigli 00030 * put back QFITS dependency to fix problem spot by NRI on FIBER mode (with MIDAS calibs) data 00031 * 00032 * Revision 1.8 2010/06/11 11:39:14 amodigli 00033 * added bias (stack) and qcdark parameters in input params 00034 * 00035 * Revision 1.7 2008/03/28 08:53:36 amodigli 00036 * IRPLIB_CONCAT2X-->UVES_CONCAT2X 00037 * 00038 * Revision 1.6 2007/08/21 13:08:26 jmlarsen 00039 * Removed irplib_access module, largely deprecated by CPL-4 00040 * 00041 * Revision 1.5 2007/06/11 13:28:26 jmlarsen 00042 * Changed recipe contact address to cpl at eso.org 00043 * 00044 * Revision 1.4 2007/06/08 13:06:16 jmlarsen 00045 * Send bug reports to Andrea 00046 * 00047 * Revision 1.3 2007/06/06 08:17:33 amodigli 00048 * replace tab with 4 spaces 00049 * 00050 * Revision 1.2 2007/05/14 08:09:48 amodigli 00051 * updated input frames and tag description in recipe man page 00052 * 00053 * Revision 1.1 2007/02/09 13:34:25 jmlarsen 00054 * Added mkmaster+spatred recipes 00055 * 00056 * Revision 1.37 2006/12/08 07:41:43 jmlarsen 00057 * Minor doc. change 00058 * 00059 * Revision 1.36 2006/11/15 15:02:14 jmlarsen 00060 * Implemented const safe workarounds for CPL functions 00061 * 00062 * Revision 1.34 2006/11/15 14:04:08 jmlarsen 00063 * Removed non-const version of parameterlist_get_first/last/next which is already 00064 * in CPL, added const-safe wrapper, unwrapper and deallocator functions 00065 * 00066 * Revision 1.33 2006/11/15 08:57:32 amodigli 00067 * clearer message on slit FF encoder positions 00068 * 00069 * Revision 1.32 2006/11/13 12:45:32 jmlarsen 00070 * Count SFLAT sets from 1 rather than 0 00071 * 00072 * Revision 1.31 2006/11/06 15:19:41 jmlarsen 00073 * Removed unused include directives 00074 * 00075 * Revision 1.30 2006/11/03 14:57:44 jmlarsen 00076 * Changed message 00077 * 00078 * Revision 1.29 2006/10/17 12:33:02 jmlarsen 00079 * Added semicolon at UVES_RECIPE_DEFINE invocation 00080 * 00081 * Revision 1.28 2006/10/09 13:01:13 jmlarsen 00082 * Use macro to define recipe interface functions 00083 * 00084 * Revision 1.27 2006/09/27 13:20:51 jmlarsen 00085 * Factored out flat reduction 00086 * 00087 * Revision 1.26 2006/09/19 14:31:20 jmlarsen 00088 * uves_insert_frame(): use bitmap to specify which image statistics keywords must be computed 00089 * 00090 * Revision 1.25 2006/09/19 06:55:58 jmlarsen 00091 * Changed interface of uves_frameset to optionally write image statistics kewwords 00092 * 00093 * Revision 1.24 2006/09/14 08:46:51 jmlarsen 00094 * Added support for TFLAT, SCREEN_FLAT frames 00095 * 00096 * Revision 1.23 2006/08/24 11:36:37 jmlarsen 00097 * Write recipe start/stop time to header 00098 * 00099 * Revision 1.22 2006/08/17 13:56:53 jmlarsen 00100 * Reduced max line length 00101 * 00102 * Revision 1.21 2006/08/11 14:56:05 amodigli 00103 * removed Doxygen warnings 00104 * 00105 * Revision 1.20 2006/07/14 12:19:28 jmlarsen 00106 * Support multiple QC tests per product 00107 * 00108 * Revision 1.19 2006/07/03 13:09:24 amodigli 00109 * adjusted description display layout 00110 * 00111 * Revision 1.18 2006/07/03 13:02:18 jmlarsen 00112 * Threshold to zero after bias subtraction 00113 * 00114 * Revision 1.17 2006/06/16 08:25:45 jmlarsen 00115 * Manually propagate ESO.DET. keywords from 1st/2nd input header 00116 * 00117 * Revision 1.16 2006/06/13 11:57:02 jmlarsen 00118 * Check that calibration frames are from the same chip ID 00119 * 00120 * Revision 1.15 2006/06/01 14:21:27 amodigli 00121 * frm --> frm_tmp, dup --> frm_dup 00122 * 00123 * Revision 1.14 2006/06/01 12:02:56 jmlarsen 00124 * Return proper error_code in the function uves_mflat 00125 * 00126 * Revision 1.13 2006/05/22 10:01:04 amodigli 00127 * fixed some bug in msflat generation 00128 * 00129 * Revision 1.12 2006/05/22 06:47:15 amodigli 00130 * fixed some bugs on msflat 00131 * 00132 * Revision 1.10 2006/05/19 13:07:52 amodigli 00133 * modified to support SFLATs 00134 * 00135 * Revision 1.9 2006/05/17 09:58:25 amodigli 00136 * fixed warning 00137 * 00138 * Revision 1.8 2006/05/17 09:56:36 amodigli 00139 * fixed syntax bug 00140 * 00141 * Revision 1.7 2006/05/17 09:54:55 amodigli 00142 * added supposr SFLATs 00143 * 00144 * Revision 1.6 2006/05/09 07:42:18 amodigli 00145 * added QC-LOG 00146 * 00147 * Revision 1.5 2006/04/06 12:57:43 jmlarsen 00148 * Added support for IFLAT, DFLAT -> MASTER_IFLAT, MASTER_DFLAT frames 00149 * 00150 * Revision 1.4 2006/04/06 09:48:15 amodigli 00151 * changed uves_frameset_insert interface to have QC log 00152 * 00153 * Revision 1.3 2006/04/06 08:37:48 jmlarsen 00154 * Support reading MASTER_PDARK 00155 * 00156 * Revision 1.2 2006/03/24 14:15:18 jmlarsen 00157 * Save intermediate result to disk 00158 * 00159 * Revision 1.1 2006/02/03 07:46:30 jmlarsen 00160 * Moved recipe implementations to ./uves directory 00161 * 00162 * Revision 1.39 2006/01/19 08:47:24 jmlarsen 00163 * Inserted missing doxygen end tag 00164 * 00165 * Revision 1.38 2005/12/19 16:17:55 jmlarsen 00166 * Replaced bool -> int 00167 * 00168 */ 00169 00170 #ifdef HAVE_CONFIG_H 00171 # include <config.h> 00172 #endif 00173 00174 /*----------------------------------------------------------------------------*/ 00181 /*----------------------------------------------------------------------------*/ 00182 00183 /*----------------------------------------------------------------------------- 00184 Includes 00185 -----------------------------------------------------------------------------*/ 00186 00187 #include <uves_reduce_mflat.h> 00188 #include <uves_mbias_impl.h> 00189 #include <uves_mdark_impl.h> 00190 #include <uves_dfs.h> 00191 #include <uves_parameters.h> 00192 #include <uves_recipe.h> 00193 #include <uves.h> 00194 #include <uves_error.h> 00195 00196 #include <cpl.h> 00197 00198 /*----------------------------------------------------------------------------- 00199 Functions prototypes 00200 -----------------------------------------------------------------------------*/ 00201 00202 static int uves_cal_mkmaster_define_parameters(cpl_parameterlist *parameters); 00203 00204 /*----------------------------------------------------------------------------- 00205 Recipe standard code 00206 -----------------------------------------------------------------------------*/ 00207 #define cpl_plugin_get_info uves_cal_mkmaster_get_info 00208 UVES_RECIPE_DEFINE( 00209 UVES_MKMASTER_ID, UVES_MKMASTER_DOM, uves_cal_mkmaster_define_parameters, 00210 "Jonas M. Larsen", "cpl@eso.org", 00211 "Creates the master bias/dark/flat frame", 00212 "This recipe calls " make_str(UVES_MBIAS_ID) " if any raw BIAS frame is provided\n" 00213 "otherwise " make_str(UVES_MDARK_ID) " if any raw DARK frame is provided, otherwise\n" 00214 "it calls " make_str(UVES_MFLAT_ID) " Pls refer to those recipes for more details\n"); 00215 00217 /*----------------------------------------------------------------------------- 00218 Functions code 00219 -----------------------------------------------------------------------------*/ 00220 /*----------------------------------------------------------------------------*/ 00226 /*----------------------------------------------------------------------------*/ 00227 int 00228 uves_cal_mkmaster_define_parameters(cpl_parameterlist *parameters) 00229 { 00230 00231 int result=0; 00232 if (uves_master_stack_define_parameters(parameters, 00233 make_str(UVES_MKMASTER_ID)) 00234 != CPL_ERROR_NONE) 00235 { 00236 return -1; 00237 } 00238 00239 check_nomsg(uves_qcdark_define_parameters_body(parameters, 00240 make_str(UVES_MKMASTER_ID))); 00241 result=uves_mflat_define_parameters_body(parameters, 00242 make_str(UVES_MKMASTER_ID)); 00243 cleanup: 00244 return result; 00245 /* Warning: If parameters are added to mbias/mdark recipes, they need to 00246 be propagated to here. Now, just copy the parameters from mflat */ 00247 } 00248 00249 /*----------------------------------------------------------------------------*/ 00258 /*----------------------------------------------------------------------------*/ 00259 static void 00260 UVES_CONCAT2X(UVES_MKMASTER_ID,exe)(cpl_frameset *frames, 00261 const cpl_parameterlist *parameters, 00262 const char *starttime) 00263 { 00264 int blue; 00265 bool found_bias = false; 00266 bool found_dark = false; 00267 bool found_flat = false; 00268 00269 assure( frames != NULL, CPL_ERROR_NULL_INPUT, "Null frameset given!"); 00270 00271 for (blue = 0; blue <= 1; blue++) 00272 { 00273 found_bias = found_bias || cpl_frameset_find(frames, UVES_BIAS(blue)); 00274 found_dark = found_dark || cpl_frameset_find(frames, UVES_DARK(blue)); 00275 found_dark = found_dark || cpl_frameset_find(frames, UVES_PDARK(blue)); 00276 found_flat = found_flat || cpl_frameset_find(frames, UVES_FLAT(blue)); 00277 found_flat = found_flat || cpl_frameset_find(frames, UVES_IFLAT(blue)); 00278 found_flat = found_flat || cpl_frameset_find(frames, UVES_DFLAT(blue)); 00279 found_flat = found_flat || cpl_frameset_find(frames, UVES_SFLAT(blue)); 00280 found_flat = found_flat || cpl_frameset_find(frames, UVES_TFLAT(blue)); 00281 found_flat = found_flat || cpl_frameset_find(frames, UVES_SCREEN_FLAT(blue)); 00282 } 00283 00284 if (found_bias) 00285 { 00286 uves_msg("Bias frame(s) provided"); 00287 } 00288 00289 if (found_dark) 00290 { 00291 uves_msg("Dark frame(s) provided"); 00292 } 00293 00294 if (found_flat) 00295 { 00296 uves_msg("Flat frame(s) provided"); 00297 } 00298 00299 assure( found_bias || found_dark || found_flat, 00300 CPL_ERROR_DATA_NOT_FOUND, 00301 "Missing raw bias, dark or flat-field frames"); 00302 00303 if (found_bias && found_dark) 00304 { 00305 uves_msg_warning("Both bias and dark frames provided. Creating only master bias"); 00306 } 00307 else if (found_bias && found_flat) 00308 { 00309 uves_msg_warning("Both bias and flat frames provided. Creating only master bias"); 00310 } 00311 else if (found_dark && found_flat) 00312 { 00313 uves_msg_warning("Both dark and flat frames provided. Creating only master dark"); 00314 } 00315 00316 if (found_bias) 00317 { 00318 uves_mbias_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00319 } 00320 else if (found_dark) 00321 { 00322 uves_mdark_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00323 } 00324 else if (found_flat) 00325 { 00326 uves_mflat_exe_body(frames, parameters, starttime, make_str(UVES_MKMASTER_ID)); 00327 } 00328 else 00329 { 00330 /* Impossible */ 00331 passure( false, "%d %d %d", found_bias, found_dark, found_flat); 00332 } 00333 00334 cleanup: 00335 return; 00336 } 00337