00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035 #include <stdbool.h>
00036 #include <cpl.h>
00037
00038 #include "irplib_detmon_lg.h"
00039 #include "irplib_detmon.h"
00040
00041 #include "uves_plugin.h"
00042
00043 #include "uves_dfs.h"
00044 #include "uves_msg.h"
00045 #include "uves_error.h"
00046 #include "uves_utils.h"
00047 #include "uves_utils_wrappers.h"
00048
00049
00050
00051 #define UVES_LINGAIN_ON_RAW(it) ((it) == 0 ? "SCREEN_FLAT_DETCHAR_RED" : \
00052 (it) == 1 ? "SCREEN_FLAT_DETCHAR_BLUE" : \
00053 "???")
00054
00055 #define UVES_LINGAIN_OFF_RAW(it) ((it) == 0 ? "BIAS_DETCHAR_RED" : \
00056 (it) == 1 ? "BIAS_DETCHAR_BLUE" : "???")
00057
00058 #define UVES_LINGAIN_DET_LIN_INFO(it) ((it) == 0 ? "DET_LIN_INFO_RED" : \
00059 (it) == 1 ? "DET_LIN_INFO_BLUE" : "???")
00060
00061 #define UVES_LINGAIN_GAIN_INFO(it) ((it) == 0 ? "GAIN_INFO_RED" : \
00062 (it) == 1 ? "GAIN_INFO_BLUE" : "???")
00063
00064 #define UVES_LINGAIN_COEFFS_CUBE(it) ((it) == 0 ? "COEFFS_CUBE_RED" : \
00065 (it) == 1 ? "COEFFS_CUBE_BLUE" : "???")
00066
00067 #define UVES_LINGAIN_BP_MAP_NL(it) ((it) == 0 ? "BP_MAP_NL_RED" : \
00068 (it) == 1 ? "BP_MAP_NL_BLUE" : "???")
00069
00070 #define UVES_LINGAIN_AUTOCORR(it) ((it) == 0 ? "AUTOCORR_RED" : \
00071 (it) == 1 ? "AUTOCORR_BLUE" : "???")
00072
00073 #define UVES_LINGAIN_DIFF_FLAT(it) ((it) == 0 ? "DIFF_FLAT_RED" : \
00074 (it) == 1 ? "DIFF_FLAT_BLUE" : "???")
00075
00076
00077 #define RECIPE_NAME "uves_cal_lingain"
00078
00079
00080 #define INSTREGEXP "ESO INS SETUP ID"
00081
00082 #define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
00083 #define UVES_TAG_ON "SCREEN_FLAT_DETCHAR_RED/BLUE"
00084 #define UVES_TAG_OFF "BIAS_DETCHAR_RED/BLUE"
00085
00086 #define OPT FALSE
00087 #define UVES_PIX2PIX CPL_TRUE
00088 #define UVES_EXTS_RED -1
00089
00090
00091
00092
00093 cpl_error_code
00094 uves_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist);
00095
00096 UVES_IRPLIB_RECIPE_DEFINE(uves_cal_lingain, UVES_BINARY_VERSION,
00097
00098
00099 uves_cal_lingain_fill_parlist_default(recipe->parameters),
00100
00101
00102 "Lander de Bilbao", PACKAGE_BUGREPORT, "2008",
00103 "Linearity/Gain recipe for the optical domain",
00104 irplib_detmon_lg_get_description(RECIPE_NAME, "UVES",
00105 UVES_TAG_ON,
00106 UVES_TAG_OFF));
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 static int
00119 uves_cal_lingain(cpl_frameset * frameset,
00120 const cpl_parameterlist * parlist)
00121 {
00122
00123
00124 int red;
00125 bool found_bias = false;
00126 bool found_flat = false;
00127 cpl_error_code error=0;
00128 int processed=0;
00129 cpl_parameter* p=NULL;
00130 cpl_parameterlist* plist=NULL;
00131
00132 check_nomsg(plist=uves_parameterlist_duplicate(parlist));
00133
00134 for (red = 0; red <= 1; red++){
00135
00136 check_nomsg(found_bias = cpl_frameset_find(frameset,UVES_LINGAIN_ON_RAW(red)));
00137 check_nomsg(found_flat = cpl_frameset_find(frameset,UVES_LINGAIN_OFF_RAW(red)));
00138
00139 if((found_bias) && (found_flat)) {
00140
00141 if(red == 0) {
00142 uves_msg("Update exts param for RED ARM data");
00143
00144 check_nomsg(p=cpl_parameterlist_find(plist,PACKAGE "." RECIPE_NAME ".exts"));
00145
00146 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00147 check_nomsg(error = cpl_parameter_set_int(p, UVES_EXTS_RED));
00148 cpl_ensure_code(!error, error);
00149
00150
00151
00152
00153 }
00154 processed++;
00155
00156 cpl_propertylist * lintbl =
00157 irplib_detmon_fill_prolist(UVES_LINGAIN_DET_LIN_INFO(red), "TYPE", "TECH", CPL_TRUE);
00158
00159 cpl_propertylist * gaintbl =
00160 irplib_detmon_fill_prolist(UVES_LINGAIN_GAIN_INFO(red), "TYPE", "TECH", CPL_TRUE);
00161
00162 cpl_propertylist * coeffscube =
00163 irplib_detmon_fill_prolist(UVES_LINGAIN_COEFFS_CUBE(red), "TYPE", "TECH", CPL_TRUE);
00164
00165 cpl_propertylist * bpm =
00166 irplib_detmon_fill_prolist(UVES_LINGAIN_BP_MAP_NL(red), "TYPE", "TECH", CPL_TRUE);
00167
00168 cpl_propertylist * corr =
00169 irplib_detmon_fill_prolist(UVES_LINGAIN_AUTOCORR(red), "TYPE", "TECH", CPL_TRUE);
00170
00171 cpl_propertylist * diff_flat =
00172 irplib_detmon_fill_prolist(UVES_LINGAIN_DIFF_FLAT(red), "TYPE", "TECH", CPL_TRUE);
00173
00174 error = irplib_detmon_lg(frameset,
00175 plist,
00176 UVES_LINGAIN_ON_RAW(red),
00177 UVES_LINGAIN_OFF_RAW(red),
00178 RECIPE_NAME,
00179 "uves",
00180 PAFREGEXP,
00181 lintbl,
00182 gaintbl,
00183 coeffscube,
00184 bpm,
00185 corr,
00186 diff_flat,
00187 PACKAGE "/" PACKAGE_VERSION,
00188 NULL, NULL, OPT);
00189
00190 cpl_propertylist_delete(lintbl);
00191 cpl_propertylist_delete(gaintbl);
00192 cpl_propertylist_delete(coeffscube);
00193 cpl_propertylist_delete(bpm);
00194 cpl_propertylist_delete(corr);
00195 cpl_propertylist_delete(diff_flat);
00196 lintbl = 0;
00197 gaintbl = 0;
00198 coeffscube = 0;
00199 bpm = 0;
00200 corr = 0;
00201 diff_flat = 0;
00202 check_nomsg(error);
00203 }
00204 }
00205 if(processed>0) {
00206
00207 cpl_ensure_code(!error, error);
00208 } else {
00209 uves_msg("No data has been processed.");
00210 uves_msg("Pls check if input frame set contains valid tags");
00211 }
00212
00213
00214
00215 cleanup:
00216
00217 return error;
00218 }
00219
00220 cpl_error_code
00221 uves_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist)
00222 {
00223
00224 cpl_error_code error =
00225 irplib_detmon_lg_fill_parlist_opt_default(parlist, RECIPE_NAME, PACKAGE);
00226 cpl_parameter * p;
00227
00228 cpl_ensure_code(!error, error);
00229
00230
00231
00232 p = cpl_parameterlist_find(parlist, PACKAGE "." RECIPE_NAME ".pix2pix");
00233
00234 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00235
00236 error = cpl_parameter_set_default_bool(p, UVES_PIX2PIX);
00237
00238
00239 cpl_ensure_code(!error, error);
00240
00241 return CPL_ERROR_NONE;
00242 }
00243
00244