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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #ifdef HAVE_CONFIG_H
00092 # include <config.h>
00093 #endif
00094
00095
00101
00102
00103
00104
00105
00106
00107 #include <uves_reduce_mflat.h>
00108 #include <uves_reduce_scired.h>
00109 #include <uves_parameters.h>
00110 #include <uves_utils_wrappers.h>
00111 #include <uves_dfs.h>
00112 #include <uves_recipe.h>
00113 #include <uves.h>
00114 #include <uves_error.h>
00115 #include <uves_msg.h>
00116
00117 #include <cpl.h>
00118
00119
00120
00121
00122 static int
00123 uves_tflat_define_parameters(cpl_parameterlist *parameters);
00124
00125
00126
00127
00128 #define cpl_plugin_get_info uves_tflat_get_info
00129 UVES_RECIPE_DEFINE(
00130 UVES_TFLAT_ID, UVES_TFLAT_DOM, uves_tflat_define_parameters,
00131 "Jonas M. Larsen", "cpl@eso.org",
00132 "Reduces a TFLAT frame",
00133 "This recipe reduces a TFLAT_xxx frame (xxx = BLUE,RED). This is\n"
00134 "achieved by\n"
00135 "1) combining all provided TFLAT frames to a MASTER_TFLAT frame, then\n"
00136 "2) doing a normal science reduction on the first input TFLAT frame\n"
00137 "Input frames are raw TFLAT_xxx frames, and: \n"
00138 "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
00139 "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
00140 "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n");
00141
00143
00144
00145
00146
00152
00153 static int
00154 uves_tflat_define_parameters(cpl_parameterlist *parameters)
00155 {
00156
00157
00158
00159
00160
00161 if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
00162 {
00163 return -1;
00164 }
00165
00166 if (uves_corr_traps_define_parameters(parameters,"uves_cal_tflat")
00167 != CPL_ERROR_NONE)
00168 {
00169 return -1;
00170 }
00171
00172
00173
00174
00175
00176
00177
00178 if (uves_propagate_parameters_step(UVES_BACKSUB_ID, parameters,
00179 make_str(UVES_TFLAT_ID), NULL) != 0)
00180 {
00181 return -1;
00182 }
00183
00184
00185
00186
00187 if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
00188 make_str(UVES_TFLAT_ID), NULL) != 0)
00189 {
00190 return -1;
00191 }
00192
00193
00194 {
00195 const char *param = "average";
00196 bool bool_param;
00197
00198 if (uves_set_parameter_default(parameters,
00199 make_str(UVES_TFLAT_ID), "reduce.extract.method",
00200 CPL_TYPE_STRING, ¶m) != CPL_ERROR_NONE)
00201 {
00202 return -1;
00203 }
00204
00205 bool_param = false;
00206 if (uves_set_parameter_default(parameters,
00207 make_str(UVES_TFLAT_ID), "reduce.skysub",
00208 CPL_TYPE_BOOL, &bool_param) != CPL_ERROR_NONE)
00209 {
00210 return -1;
00211 }
00212 }
00213
00214 return (cpl_error_get_code() != CPL_ERROR_NONE);
00215 }
00216
00217
00224
00225 static void
00226 UVES_CONCAT2X(UVES_TFLAT_ID,exe)(cpl_frameset *frames,
00227 const cpl_parameterlist *parameters,
00228 const char *starttime)
00229 {
00230 uves_msg("Creating master tflat");
00231 check_nomsg( uves_mflat_exe_body(frames, parameters,
00232 starttime,
00233 make_str(UVES_TFLAT_ID)) );
00234
00235 uves_msg("Reducing first raw tflat");
00236 check_nomsg( uves_reduce_scired(frames, parameters, make_str(UVES_TFLAT_ID), starttime) );
00237
00238
00239
00240 {
00241 enum uves_chip chip;
00242 int blue;
00243 const char* PROCESS_CHIP=NULL;
00244 check( uves_get_parameter(parameters, NULL, "uves", "process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
00245 "Could not read parameter");
00246 uves_string_toupper((char*)PROCESS_CHIP);
00247
00248
00249 for (blue = 0; blue <= 1; blue++)
00250 {
00251 for (chip = uves_chip_get_first(blue);
00252 chip != UVES_CHIP_INVALID;
00253 chip = uves_chip_get_next(chip))
00254 {
00255
00256 if(strcmp(PROCESS_CHIP,"REDU") == 0) {
00257 chip = uves_chip_get_next(chip);
00258 }
00259
00260 cpl_frame *f = cpl_frameset_find(frames, UVES_MASTER_TFLAT(chip));
00261 if (f != NULL)
00262 {
00263 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00264 }
00265
00266 f = cpl_frameset_find(frames, UVES_BKG_FLAT(chip));
00267 if (f != NULL)
00268 {
00269 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00270 }
00271 }
00272
00273 if(strcmp(PROCESS_CHIP,"REDL") == 0) {
00274 chip = uves_chip_get_next(chip);
00275 }
00276
00277 }
00278 }
00279
00280 cleanup:
00281 return;
00282 }
00283