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 #ifdef HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030
00031
00032
00033
00034 #include <stdbool.h>
00035
00036 #include <cpl.h>
00037
00038 #include "irplib_detmon.h"
00039 #include "uves_plugin.h"
00040
00041
00042 #include "uves_msg.h"
00043 #include "uves_error.h"
00044 #include "uves_utils.h"
00045 #include "uves_utils_wrappers.h"
00046
00047 #define REGEXP "ARCFILE|MJD-OBS|ESO TPL ID|DATE-OBS|ESO DET DIT|ESO DET NDIT"
00048 #define RECIPE_NAME "uves_cal_ronbias"
00049 #define UVES_RONBIAS_RAW(it) ((it) == 0 ? "BIAS_RED" : \
00050 (it) == 1 ? "BIAS_BLUE" : \
00051 "???")
00052
00053 #define UVES_RONBIAS_MASTER_BIAS(it) ((it) == 0 ? "MASTER_BIAS_RED" : \
00054 (it) == 1 ? "MASTER_BIAS_BLUE" : "???")
00055
00056 #define UVES_RONBIAS_INT_XSTRUCT(it) ((it) == 0 ? "INT_XSTRUCT_RED" : \
00057 (it) == 1 ? "INT_XSTRUCT_BLUE" : "???")
00058
00059
00060 #define UVES_RONBIAS_INT_YSTRUCT(it) ((it) == 0 ? "INT_YSTRUCT_RED" : \
00061 (it) == 1 ? "INT_YSTRUCT_BLUE" : "???")
00062
00063
00064 #define UVES_RONBIAS_SYNTH(it) ((it) == 0 ? "SYNTH_RED" : \
00065 (it) == 1 ? "SYNTH_BLUE" : "???")
00066
00067
00068 #define UVES_RONBIAS_BP_MAP_HP(it) ((it) == 0 ? "BP_MAP_HP_RED" : \
00069 (it) == 1 ? "BP_MAP_HP_BLUE" : "???")
00070
00071
00072 #define UVES_RONBIAS_BP_MAP_CP(it) ((it) == 0 ? "BP_MAP_CP_RED" : \
00073 (it) == 1 ? "BP_MAP_CP_BLUE" : "???")
00074
00075
00076 #define UVES_RONBIAS_BP_MAP_DP(it) ((it) == 0 ? "BP_MAP_DP_RED" : \
00077 (it) == 1 ? "BP_MAP_DP_BLUE" : "???")
00078
00079
00080
00081 #define UVES_PIX2PIX CPL_TRUE
00082 #define UVES_EXTS_RED -1
00083
00084
00085
00086
00087 UVES_IRPLIB_RECIPE_DEFINE(uves_cal_ronbias,
00088 UVES_BINARY_VERSION,
00089 irplib_detmon_ronbias_fill_parlist_default(recipe->parameters,
00090 RECIPE_NAME,
00091 PACKAGE_TARNAME),
00092 "Lander de Bilbao", PACKAGE_BUGREPORT, "2008",
00093 "RON/Bias recipe",
00094 irplib_detmon_ronbias_get_description(RECIPE_NAME,"UVES",
00095 "BIAS_BLUE or BIAS_RED"));
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 static int uves_cal_ronbias(cpl_frameset * frameset,
00107 const cpl_parameterlist * parlist)
00108 {
00109
00110
00111 int red;
00112 bool found_bias = false;
00113 int nbias = 0;
00114
00115 cpl_error_code error=0;
00116 int processed=0;
00117 cpl_parameter* p=NULL;
00118 cpl_parameterlist* plist=NULL;
00119 cpl_frameset* bset=NULL;
00120
00121 check_nomsg(plist=uves_parameterlist_duplicate(parlist));
00122
00123 for (red = 0; red <= 1; red++){
00124
00125 found_bias = cpl_frameset_find(frameset, UVES_RONBIAS_RAW(red));
00126 if(found_bias) {
00127 check_nomsg(bset=uves_frameset_extract(frameset,UVES_RONBIAS_RAW(red)));
00128 check_nomsg(nbias=cpl_frameset_get_size(bset));
00129 uves_msg("found %d biases",nbias);
00130 if(nbias>1) {
00131 if(red == 0) {
00132
00133
00134
00135 uves_msg("Update exts param for RED ARM data");
00136 check_nomsg(p=cpl_parameterlist_find(plist,PACKAGE "." RECIPE_NAME ".exts"));
00137
00138 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
00139 check_nomsg(error = cpl_parameter_set_int(p, UVES_EXTS_RED));
00140 cpl_ensure_code(!error, error);
00141
00142
00143
00144 }
00145 processed++;
00146
00147 cpl_propertylist * master =
00148 irplib_detmon_fill_prolist(UVES_RONBIAS_MASTER_BIAS(red),
00149 "TYPE", "TECH", CPL_TRUE);
00150
00151 cpl_propertylist * synth =
00152 irplib_detmon_fill_prolist(UVES_RONBIAS_SYNTH(red),
00153 "TYPE", "TECH", CPL_TRUE);
00154
00155 cpl_propertylist * bpmhot =
00156 irplib_detmon_fill_prolist(UVES_RONBIAS_BP_MAP_HP(red),
00157 "TYPE", "TECH", CPL_TRUE);
00158
00159 cpl_propertylist * bpmcold =
00160 irplib_detmon_fill_prolist(UVES_RONBIAS_BP_MAP_CP(red),
00161 "TYPE", "TECH", CPL_TRUE);
00162
00163 cpl_propertylist * bpmdev =
00164 irplib_detmon_fill_prolist(UVES_RONBIAS_BP_MAP_DP(red),
00165 "TYPE", "TECH", CPL_TRUE);
00166
00167 check_nomsg(error=
00168 irplib_detmon_ronbias(frameset,
00169 parlist,
00170 UVES_RONBIAS_RAW(red),
00171 RECIPE_NAME,
00172 PACKAGE_TARNAME,
00173 REGEXP,
00174 master,
00175 NULL,
00176 NULL,
00177 synth,
00178 bpmhot,
00179 bpmcold,
00180 bpmdev,
00181 PACKAGE "/" PACKAGE_VERSION,
00182 NULL,OPT));
00183
00184
00185 cpl_propertylist_delete(master);
00186 cpl_propertylist_delete(synth);
00187 cpl_propertylist_delete(bpmhot);
00188 cpl_propertylist_delete(bpmcold);
00189 cpl_propertylist_delete(bpmdev);
00190
00191
00192 } else {
00193
00194 uves_msg("You must provide at least 2 frames tagged as %s",
00195 UVES_RONBIAS_RAW(red));
00196
00197 }
00198 uves_free_frameset(&bset);
00199
00200 } else {
00201 uves_msg("You provided no frame tagged as %s",UVES_RONBIAS_RAW(red));
00202 }
00203 }
00204
00205
00206 cleanup:
00207 uves_free_frameset(&bset);
00208
00209 if(processed>0) {
00210
00211 cpl_ensure_code(!error, error);
00212 } else {
00213 uves_msg("No data has been processed.");
00214 uves_msg("Pls check if input frame set contains valid tags");
00215 }
00216
00217
00218
00219 return CPL_ERROR_NONE;
00220 }
00221
00222