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