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 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030
00036
00037
00038
00039
00040
00041
00042 #include <uves_reduce_mflat.h>
00043 #include <uves_reduce_scired.h>
00044 #include <uves_parameters.h>
00045 #include <uves_utils_wrappers.h>
00046 #include <uves_dfs.h>
00047 #include <uves_recipe.h>
00048 #include <uves.h>
00049 #include <uves_error.h>
00050 #include <uves_msg.h>
00051
00052 #include <cpl.h>
00053 #include <string.h>
00054
00055
00056
00057 static int
00058 uves_tflat_define_parameters(cpl_parameterlist *parameters);
00059
00060
00061
00062
00063 #define cpl_plugin_get_info uves_tflat_get_info
00064 UVES_RECIPE_DEFINE(
00065 UVES_TFLAT_ID, UVES_TFLAT_DOM, uves_tflat_define_parameters,
00066 "Jonas M. Larsen", "cpl@eso.org",
00067 "Reduces a TFLAT frame",
00068 "This recipe reduces a TFLAT_xxx frame (xxx = BLUE,RED). This is\n"
00069 "achieved by\n"
00070 "1) combining all provided TFLAT frames to a MASTER_TFLAT frame, then\n"
00071 "2) doing a normal science reduction on the first input TFLAT frame\n"
00072 "Input frames are raw TFLAT_xxx frames, and: \n"
00073 "order table(s) for each chip, ORDER_TABLE_xxxx (where xxxx=BLUE, REDL, REDU),\n"
00074 "line table(s) for each chip, LINE_TABLE_xxxx, a master bias frame,\n"
00075 "MASTER_BIAS_xxxx, a master flat, MASTER_FLAT_xxxx, \n");
00076
00078
00079
00080
00081
00087
00088 static int
00089 uves_tflat_define_parameters(cpl_parameterlist *parameters)
00090 {
00091
00092 int res=0;
00093 res=uves_mflat_define_parameters_body(parameters,"uves_cal_tflat" );
00094
00095
00096
00097
00098 if (uves_propagate_parameters_step(UVES_REDUCE_ID, parameters,
00099 make_str(UVES_TFLAT_ID), NULL) != 0)
00100 {
00101 return -1;
00102 }
00103
00104
00105 {
00106 const char *param = "average";
00107 bool bool_param;
00108
00109 if (uves_set_parameter_default(parameters,
00110 make_str(UVES_TFLAT_ID), "reduce.extract.method",
00111 CPL_TYPE_STRING, ¶m) != CPL_ERROR_NONE)
00112 {
00113 return -1;
00114 }
00115
00116 bool_param = false;
00117 if (uves_set_parameter_default(parameters,
00118 make_str(UVES_TFLAT_ID), "reduce.skysub",
00119 CPL_TYPE_BOOL, &bool_param) != CPL_ERROR_NONE)
00120 {
00121 return -1;
00122 }
00123 }
00124
00125 return (cpl_error_get_code() != CPL_ERROR_NONE);
00126 }
00127
00128
00135
00136 static void
00137 UVES_CONCAT2X(UVES_TFLAT_ID,exe)(cpl_frameset *frames,
00138 const cpl_parameterlist *parameters,
00139 const char *starttime)
00140 {
00141 uves_msg("Creating master tflat");
00142 check_nomsg( uves_mflat_exe_body(frames, parameters,
00143 starttime,
00144 make_str(UVES_TFLAT_ID)) );
00145
00146 uves_msg("Reducing first raw tflat");
00147 check_nomsg( uves_reduce_scired(frames, parameters, make_str(UVES_TFLAT_ID), starttime) );
00148
00149
00150
00151 {
00152 enum uves_chip chip;
00153 int blue;
00154 const char* PROCESS_CHIP=NULL;
00155 cpl_frame *f = NULL;
00156 check( uves_get_parameter(parameters, NULL, "uves", "process_chip", CPL_TYPE_STRING, &PROCESS_CHIP),
00157 "Could not read parameter");
00158 uves_string_toupper((char*)PROCESS_CHIP);
00159
00160
00161 for (blue = 0; blue <= 1; blue++)
00162 {
00163 for (chip = uves_chip_get_first(blue);
00164 chip != UVES_CHIP_INVALID;
00165 chip = uves_chip_get_next(chip))
00166 {
00167
00168 if(strcmp(PROCESS_CHIP,"REDU") == 0) {
00169 chip = uves_chip_get_next(chip);
00170 }
00171
00172 f = cpl_frameset_find(frames, UVES_MASTER_TFLAT(chip));
00173 if (f != NULL)
00174 {
00175 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00176 }
00177
00178 f = cpl_frameset_find(frames, UVES_BKG_FLAT(chip));
00179 if (f != NULL)
00180 {
00181 cpl_frame_set_group(f, CPL_FRAME_GROUP_PRODUCT);
00182 }
00183 }
00184
00185 if(strcmp(PROCESS_CHIP,"REDL") == 0) {
00186 chip = uves_chip_get_next(chip);
00187 }
00188
00189 }
00190 }
00191
00192 cleanup:
00193 return;
00194 }
00195