FORS Pipeline Reference Manual 4.9.20
|
00001 /* $Id: fors_detlin.c,v 1.13 2011/10/24 13:11:17 cgarcia Exp $ 00002 * 00003 * This file is part of the FORS Data Reduction Pipeline 00004 * Copyright (C) 2002-2010 European Southern Observatory 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 /* 00022 * $Author: cgarcia $ 00023 * $Date: 2011/10/24 13:11:17 $ 00024 * $Revision: 1.13 $ 00025 * $Name: fors-4_9_20 $ 00026 */ 00027 #ifdef HAVE_CONFIG_H 00028 #include <config.h> 00029 #endif 00030 00031 /*---------------------------------------------------------------------------- 00032 Includes 00033 ----------------------------------------------------------------------------*/ 00034 00035 #include <cpl.h> 00036 00037 #include "irplib_detmon.h" 00038 #include "irplib_detmon_lg.h" 00039 #include <fors_dfs.h> 00040 00041 /* Define here the DO.CATG keywords */ 00042 #define DETMON_OPT_LG_ON_RAW "DETECTOR_CHECK_FLAT" 00043 #define DETMON_OPT_LG_OFF_RAW "DETECTOR_CHECK_BIAS" 00044 00045 #define RECIPE_NAME "fors_detlin" 00046 00047 #define OPT FALSE 00048 00049 /*---------------------------------------------------------------------------- 00050 Functions prototypes 00051 ----------------------------------------------------------------------------*/ 00052 00053 static cpl_error_code 00054 fors_detlin_fill_parlist(cpl_parameterlist *); 00055 00056 CPL_RECIPE_DEFINE(fors_detlin, FORS_BINARY_VERSION, 00057 fors_detlin_fill_parlist(recipe->parameters), 00058 "Lander de Bilbao", "lbilbao@eso.org", "2008", 00059 "Linearity/Gain recipe for the optical domain", 00060 irplib_detmon_lg_get_description("fors_detlin", 00061 PACKAGE_TARNAME, 00062 DETMON_OPT_LG_ON_RAW, 00063 DETMON_OPT_LG_OFF_RAW)); 00064 00065 /*---------------------------------------------------------------------------*/ 00066 /* 00067 @brief Interpret the command line options and execute the data processing 00068 @param frameset the frames list 00069 @param parlist the parameters list 00070 @return 0 if everything is ok 00071 */ 00072 /*---------------------------------------------------------------------------*/ 00073 00074 static int fors_detlin(cpl_frameset *frameset, 00075 const cpl_parameterlist *parlist) 00076 { 00077 cpl_propertylist * lintbl = 00078 irplib_detmon_fill_prolist("DET_LIN_INFO", NULL, NULL, CPL_FALSE); 00079 00080 cpl_propertylist * gaintbl = 00081 irplib_detmon_fill_prolist("GAIN_INFO", NULL, NULL, CPL_FALSE); 00082 00083 cpl_propertylist * coeffscube = 00084 irplib_detmon_fill_prolist("COEFFS_CUBE", NULL, NULL, CPL_FALSE); 00085 00086 cpl_propertylist * bpm = 00087 irplib_detmon_fill_prolist("BP_MAP_NL", NULL, NULL, CPL_FALSE); 00088 00089 cpl_propertylist * corr = 00090 irplib_detmon_fill_prolist("AUTOCORR", NULL, NULL, CPL_FALSE); 00091 00092 cpl_propertylist * diff_flat = 00093 irplib_detmon_fill_prolist("DIFF_FLAT", NULL, NULL, CPL_FALSE); 00094 00095 const cpl_error_code error = irplib_detmon_lg(frameset, 00096 parlist, 00097 DETMON_OPT_LG_ON_RAW, 00098 DETMON_OPT_LG_OFF_RAW, 00099 RECIPE_NAME, 00100 PACKAGE_TARNAME, 00101 REGEXP, 00102 lintbl, gaintbl, coeffscube, 00103 bpm, corr, diff_flat, 00104 PACKAGE "/" PACKAGE_VERSION, 00105 NULL, NULL, OPT); 00106 00107 cpl_propertylist_delete(lintbl); 00108 cpl_propertylist_delete(gaintbl); 00109 cpl_propertylist_delete(coeffscube); 00110 cpl_propertylist_delete(bpm); 00111 cpl_propertylist_delete(corr); 00112 cpl_propertylist_delete(diff_flat); 00113 00114 { 00115 /* 00116 * This part is added until ticket DFS05711 is fixed. 00117 */ 00118 00119 cpl_image *chipmap; 00120 cpl_image *badpixmap; 00121 int llx = dfs_get_parameter_int_const(parlist, 00122 PACKAGE_TARNAME "." RECIPE_NAME ".llx"); 00123 int lly = dfs_get_parameter_int_const(parlist, 00124 PACKAGE_TARNAME "." RECIPE_NAME ".lly"); 00125 00126 badpixmap = dfs_load_image(frameset, "BP_MAP_NL", CPL_TYPE_FLOAT, 0, 1); 00127 chipmap = cpl_image_new(2048, 1024, CPL_TYPE_FLOAT); 00128 cpl_image_copy(chipmap, badpixmap, llx, lly - 5); 00129 cpl_image_delete(badpixmap); 00130 dfs_save_image(frameset, chipmap, "BP_MAP_NL_FULL", NULL, parlist, 00131 RECIPE_NAME, PACKAGE "/" PACKAGE_VERSION); 00132 cpl_image_delete(chipmap); 00133 } 00134 00135 /* Propagate the error, if any */ 00136 cpl_ensure_code(!error, error); 00137 00138 return CPL_ERROR_NONE; 00139 } 00140 00141 static cpl_error_code 00142 fors_detlin_fill_parlist(cpl_parameterlist * parlist) 00143 { 00144 cpl_error_code error; 00145 cpl_parameter * p; 00146 00147 error = irplib_detmon_lg_fill_parlist_opt_default(parlist, 00148 "fors_detlin", PACKAGE_TARNAME); 00149 00150 cpl_ensure_code(!error, error); 00151 00152 00153 p = cpl_parameterlist_find(parlist, 00154 PACKAGE_TARNAME "." RECIPE_NAME ".tolerance"); 00155 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00156 error = cpl_parameter_set_default_double(p, 0.1); 00157 cpl_ensure_code(!error, error); 00158 00159 p = cpl_parameterlist_find(parlist, 00160 PACKAGE_TARNAME "." RECIPE_NAME ".pix2pix"); 00161 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00162 error = cpl_parameter_set_default_bool(p, 1); 00163 cpl_ensure_code(!error, error); 00164 00165 p = cpl_parameterlist_find(parlist, 00166 PACKAGE_TARNAME "." RECIPE_NAME ".order"); 00167 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00168 error = cpl_parameter_set_default_int(p, 2); 00169 cpl_ensure_code(!error, error); 00170 00171 p = cpl_parameterlist_find(parlist, 00172 PACKAGE_TARNAME "." RECIPE_NAME ".kappa"); 00173 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00174 error = cpl_parameter_set_default_double(p, 4.0); 00175 cpl_ensure_code(!error, error); 00176 00177 00178 p = cpl_parameterlist_find(parlist, 00179 PACKAGE_TARNAME "." RECIPE_NAME ".llx"); 00180 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00181 error = cpl_parameter_set_default_int(p, 1); 00182 cpl_ensure_code(!error, error); 00183 00184 p = cpl_parameterlist_find(parlist, 00185 PACKAGE_TARNAME "." RECIPE_NAME ".urx"); 00186 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00187 error = cpl_parameter_set_default_int(p, 2048); 00188 cpl_ensure_code(!error, error); 00189 00190 00191 p = cpl_parameterlist_find(parlist, 00192 PACKAGE_TARNAME "." RECIPE_NAME ".lly"); 00193 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00194 error = cpl_parameter_set_default_int(p, 6); 00195 cpl_ensure_code(!error, error); 00196 00197 p = cpl_parameterlist_find(parlist, 00198 PACKAGE_TARNAME "." RECIPE_NAME ".ury"); 00199 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00200 error = cpl_parameter_set_default_int(p, 1029); 00201 cpl_ensure_code(!error, error); 00202 00203 /* 00204 p = cpl_parameterlist_find(parlist, 00205 PACKAGE_TARNAME "." RECIPE_NAME ".method"); 00206 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND); 00207 error = cpl_parameter_set_default_string(p, "MED"); 00208 cpl_ensure_code(!error, error); 00209 */ 00210 00211 return error; 00212 00213 }