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 #include <strings.h>
00031 #include <string.h>
00032 #include <stdio.h>
00033
00034
00035
00036
00037
00038 #ifdef HAVE_CONFIG_H
00039 #include <config.h>
00040 #endif
00041 #include <cxmacros.h>
00042 #include <cxtypes.h>
00043 #include <cxmessages.h>
00044 #include <cpl_memory.h>
00045
00046 #include <cpl_parameterlist.h>
00047 #include <cpl_msg.h>
00048
00049
00050 #include <cpl_recipe.h>
00051 #include <cpl_plugin.h>
00052 #include <cpl_pluginlist.h>
00053 #include <cpl_frameset.h>
00054 #include <sinfoni_pro_types.h>
00055
00056 #include <sinfoni_general_config.h>
00057 #include <sinfoni_fake_config.h>
00058 #include <sinfoni_prepare_stacked_frames_config.h>
00059 #include <sinfoni_cube_create_config.h>
00060 #include <prepare_stacked_frames.h>
00061 #include <cubecreate.h>
00062 #include <create_resampled.h>
00063 #include <sinfoni_tpl_utils.h>
00064 #include <sinfoni_tpl_dfs.h>
00065 #include <sinfoni_memory.h>
00066
00067
00068
00069
00070
00071 static cxint si_rec_scicubecreate(cpl_parameterlist *, cpl_frameset *);
00072
00073
00074 const char * sinfoni_get_licence(void);
00075 cxint si_rec_scicubecreate_create(cpl_plugin *plugin);
00076 cxint si_rec_scicubecreate_exec(cpl_plugin *plugin);
00077 cxint si_rec_scicubecreate_destroy(cpl_plugin *plugin);
00078 static cxint si_rec_scicubecreate(cpl_parameterlist *config, cpl_frameset *set);
00079 int cpl_plugin_get_info(cpl_pluginlist *list);
00080
00081
00082
00083
00084
00085 static char si_rec_scibubecreate_description[] =
00086 "This recipe performs science data reduction.\n"
00087 "The input files are science object and sky frames with tags OBJECT_NODDING and SKY_NODDING\n"
00088 "Master calibration frames:\n"
00089 "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
00090 "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
00091 "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
00092 "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
00093 "A corresponding (band) distortion table with tag DISTORTION\n"
00094 "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n"
00095 "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
00096 "A reference table with the position of the first column with tag FIRST_COLUMN\n"
00097 "Relevant outputs are:\n"
00098 "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
00099 "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
00100 "An average along Z of the reconstructed cube (PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
00101 "The bad pixel map associated to the cube (PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
00102 "Information on relevant parameters can be found with"
00103 "esorex --params si_rec_scicubecreate"
00104 "esorex --help si_rec_scicubecreate"
00105 "\n";
00106
00107
00108
00109
00110
00111 cxint
00112 si_rec_scicubecreate_create(cpl_plugin *plugin)
00113 {
00114
00115
00116
00117
00118
00119
00120 cpl_recipe *recipe = (cpl_recipe *)plugin;
00121 recipe->parameters = cpl_parameterlist_new();
00122 if(recipe->parameters == NULL) {
00123 return 1;
00124 }
00125
00126
00127
00128
00129 sinfoni_general_config_add(recipe->parameters);
00130 sinfoni_prepare_stacked_frames_config_add(recipe->parameters);
00131 sinfoni_cubecreate_config_add(recipe->parameters);
00132 sinfoni_fake_config_add(config);
00133 return 0;
00134
00135 }
00136
00137 cxint
00138 si_rec_scicubecreate_exec(cpl_plugin *plugin)
00139 {
00140
00141 cpl_recipe *recipe = (cpl_recipe *) plugin;
00142 if(recipe->parameters == NULL) {
00143 return 1;
00144 }
00145 if(recipe->frames == NULL) {
00146 return 1;
00147 }
00148 cpl_error_reset();
00149 return si_rec_scicubecreate(recipe->parameters, recipe->frames);
00150
00151 }
00152
00153 cxint
00154 si_rec_scicubecreate_destroy(cpl_plugin *plugin)
00155 {
00156 cpl_recipe *recipe = (cpl_recipe *) plugin;
00157
00158
00159
00160
00161
00162
00163 cpl_parameterlist_delete(recipe->parameters);
00164
00165 return 0;
00166
00167 }
00168
00169
00170 int
00171 cpl_plugin_get_info(cpl_pluginlist *list)
00172 {
00173
00174 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
00175 cpl_plugin *plugin = &recipe->interface;
00176
00177 cpl_plugin_init(plugin,
00178 CPL_PLUGIN_API,
00179 SINFONI_BINARY_VERSION,
00180 CPL_PLUGIN_TYPE_RECIPE,
00181 "si_rec_scicubecreate",
00182 "Science data reduction",
00183 si_rec_scicubecreate_description,
00184 "Andrea Modigliani",
00185 "Andrea.Modigliani@eso.org",
00186 sinfoni_get_licence(),
00187 si_rec_scicubecreate_create,
00188 si_rec_scicubecreate_exec,
00189 si_rec_scicubecreate_destroy);
00190
00191 cpl_pluginlist_append(list, plugin);
00192
00193 return 0;
00194
00195 }
00196
00197
00198
00199
00200
00201
00202 static cxint
00203 si_rec_scicubecreate(cpl_parameterlist *config, cpl_frameset *set)
00204 {
00205 const cxchar *_id = "si_rec_scicubecreate";
00206 char name_s [FILE_NAME_SZ];
00207 int ind =0;
00208 cpl_parameter *p;
00209
00210
00211
00212
00213 if(sinfoni_dfs_set_groups(set)) {
00214 cpl_msg_error(_id, "Cannot indentify RAW and CALIB frames") ;
00215 return -1;
00216 }
00217
00218
00219
00220
00221
00222 {
00223 cpl_msg_info (_id,"running") ;
00224 if ( -1 == (ind = prepare_stacked_frames(config, set, PRO_WAVE_LAMP_STACKED ) ) )
00225 {
00226 cpl_msg_error(_id," no: %d\n", ind) ;
00227 return -1 ;
00228 }
00229 cpl_msg_info (_id,"success") ;
00230 }
00231
00232
00233
00234
00235
00236
00237 p = cpl_parameterlist_find(config, "sinfoni.cubecreate.method");
00238 strcpy(name_s, cpl_parameter_get_string(p));
00239 cpl_msg_info(_id,"Method=%s\n",name_s);
00240
00241
00242 {
00243 if ( 0 == strcmp(name_s,"Normal") )
00244 {
00245 cpl_msg_info(_id,"Running");
00246 if ( -1 == (ind = cubecreate( config, set ) ) )
00247 {
00248 cpl_msg_error(_id,"no: %d\n", ind) ;
00249 return -1 ;
00250 }
00251 else
00252 {
00253 cpl_msg_info(_id,"success");
00254 }
00255 }
00256 else if ( 0 == strcmp (name_s, "Resampled") )
00257 {
00258 cpl_msg_info(_id,"Running");
00259 if ( -1 == (ind = create_resampled( config, set ) ) )
00260 {
00261 cpl_msg_error(_id,"no: %d\n", ind) ;
00262 return -1 ;
00263 }
00264 cpl_msg_info(_id,"success");
00265 }
00266 else
00267 {
00268 cpl_msg_error(_id,"wrong name recipe method given!\n") ;
00269 return -1 ;
00270 }
00271 }
00272 return 0 ;
00273
00274 }
00275
00276