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 #ifdef HAVE_CONFIG_H
00080 # include <config.h>
00081 #endif
00082
00083
00089
00090
00091
00092
00093
00094
00095 #include <uves_reduce_mflat.h>
00096 #include <uves_reduce_scired.h>
00097 #include <uves_parameters.h>
00098 #include <uves_utils_wrappers.h>
00099 #include <uves_dfs.h>
00100 #include <uves_recipe.h>
00101 #include <uves.h>
00102 #include <uves_error.h>
00103 #include <uves_msg.h>
00104
00105 #include <cpl.h>
00106
00107
00108
00109
00110 static int
00111 uves_tflat_define_parameters(cpl_parameterlist *parameters);
00112
00113
00114
00115
00116 #define cpl_plugin_get_info uves_tflat_get_info
00117 UVES_RECIPE_DEFINE(
00118 UVES_TFLAT_ID, UVES_TFLAT_DOM, uves_tflat_define_parameters,
00119 "Jonas M. Larsen", "cpl@eso.org",
00120 "Reduces a TFLAT frame",
00121 "This recipe reduces a TFLAT_xxx frame (xxx = BLUE,RED). This is\n"
00122 "achieved by\n"
00123 "1) combining all provided TFLAT frames to a MASTER_TFLAT frame, then\n"
00124 "2) doing a normal science reduction on the first input TFLAT frame\n"
00125 "Input frames are raw TFLAT_xxx frames, and: \n"
00126 "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
00127 "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
00128 "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n");
00129
00131
00132
00133
00134
00140
00141 static int
00142 uves_tflat_define_parameters(cpl_parameterlist *parameters)
00143 {
00144
00145
00146
00147 if (uves_define_global_parameters(parameters) != CPL_ERROR_NONE)
00148 {
00149 return -1;
00150 }
00151
00152
00153
00154
00155
00156 if (uves_propagate_parameters_step(UVES_BACKSUB_ID, parameters,
00157 make_str(UVES_TFLAT_ID), NULL) != 0)
00158 {
00159 return -1;
00160 }
00161
00162
00163
00164
00165 if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
00166 make_str(UVES_TFLAT_ID), NULL) != 0)
00167 {
00168 return -1;
00169 }
00170
00171
00172 {
00173 const char *param = "average";
00174 bool bool_param;
00175
00176 if (uves_set_parameter_default(parameters,
00177 make_str(UVES_TFLAT_ID), "reduce.extract.method",
00178 CPL_TYPE_STRING, ¶m) != CPL_ERROR_NONE)
00179 {
00180 return -1;
00181 }
00182
00183 bool_param = false;
00184 if (uves_set_parameter_default(parameters,
00185 make_str(UVES_TFLAT_ID), "reduce.skysub",
00186 CPL_TYPE_BOOL, &bool_param) != CPL_ERROR_NONE)
00187 {
00188 return -1;
00189 }
00190 }
00191
00192 return (cpl_error_get_code() != CPL_ERROR_NONE);
00193 }
00194
00195
00202
00203 static void
00204 IRPLIB_CONCAT2X(UVES_TFLAT_ID,exe)(cpl_frameset *frames,
00205 const cpl_parameterlist *parameters,
00206 const char *starttime)
00207 {
00208 uves_msg("Creating master tflat");
00209 check_nomsg( uves_mflat_exe_body(frames, parameters,
00210 starttime,
00211 make_str(UVES_TFLAT_ID)) );
00212
00213 uves_msg("Reducing first raw tflat");
00214 check_nomsg( uves_reduce_scired(frames, parameters, make_str(UVES_TFLAT_ID), starttime) );
00215
00216
00217
00218 {
00219 enum uves_chip chip;
00220 int blue;
00221 const char* PROCESS_CHIP=NULL;
00222 check( uves_get_parameter(parameters, NULL, "uves", "process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
00223 "Could not read parameter");
00224
00225
00226 for (blue = 0; blue <= 1; blue++)
00227 {
00228 for (chip = uves_chip_get_first(blue);
00229 chip != UVES_CHIP_INVALID;
00230 chip = uves_chip_get_next(chip))
00231 {
00232
00233 if(strcmp(PROCESS_CHIP,"redu") == 0) {
00234 chip = uves_chip_get_next(chip);
00235 }
00236
00237 cpl_frame *f = cpl_frameset_find(frames, UVES_MASTER_TFLAT(chip));
00238 if (f != NULL)
00239 {
00240 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00241 }
00242
00243 f = cpl_frameset_find(frames, UVES_BKG_FLAT(chip));
00244 if (f != NULL)
00245 {
00246 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00247 }
00248 }
00249
00250 if(strcmp(PROCESS_CHIP,"redl") == 0) {
00251 chip = uves_chip_get_next(chip);
00252 }
00253
00254 }
00255 }
00256
00257 cleanup:
00258 return;
00259 }
00260