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 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032
00033
00034
00035 #include <string.h>
00036
00037
00038 #include <cpl.h>
00039
00040 #include <irplib_utils.h>
00041
00042 #include <sinfo_tpl_utils.h>
00043 #include <sinfo_pfits.h>
00044 #include <sinfo_tpl_dfs.h>
00045 #include <sinfo_utl_cube_arith.h>
00046 #include <sinfo_msg.h>
00047
00048
00049
00050
00051
00052 static int sinfo_utl_cube_arith_create(cpl_plugin *) ;
00053 static int sinfo_utl_cube_arith_exec(cpl_plugin *) ;
00054 static int sinfo_utl_cube_arith_destroy(cpl_plugin *) ;
00055
00056
00057
00058
00059
00060 static char sinfo_utl_cube_arith_description1[] =
00061 "This recipe perform cube arithmetics.\n"
00062 "If parameter value is specified the input frame is a cube \n"
00063 "in a sof file with tag CUBE\n"
00064 "Else the input files are a cube and an images or a spectrum\n"
00065 "their associated tags should be respectively CUBE, IMA or SPECTRUM.\n"
00066 "The output is a cube with tag PRO_CUBE resulting from the operation \n"
00067 "CUBE op IMA or \n"
00068 "CUBE op SPECTRUM or\n"
00069 "CUBE op value where op indicates\n"
00070 "the operation to be performed\n";
00071
00072
00073 static char sinfo_utl_cube_arith_description2[] =
00074 "Information on relevant parameters can be found with\n"
00075 "esorex --params sinfo_utl_cube_arith\n"
00076 "esorex --help sinfo_utl_cube_arith\n"
00077 "\n";
00078
00079 static char sinfo_utl_cube_arith_description[600];
00080
00081
00082
00083
00084
00085
00086
00090
00092
00100
00101 int cpl_plugin_get_info(cpl_pluginlist * list)
00102 {
00103 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00104 cpl_plugin * plugin = &recipe->interface ;
00105
00106 strcpy(sinfo_utl_cube_arith_description,sinfo_utl_cube_arith_description1);
00107 strcat(sinfo_utl_cube_arith_description,sinfo_utl_cube_arith_description2);
00108
00109 cpl_plugin_init(plugin,
00110 CPL_PLUGIN_API,
00111 SINFONI_BINARY_VERSION,
00112 CPL_PLUGIN_TYPE_RECIPE,
00113 "sinfo_utl_cube_arith",
00114 "Cube arithmetics",
00115 sinfo_utl_cube_arith_description,
00116 "Andrea Modigliani",
00117 "Andrea.Modigliani@eso.org",
00118 sinfo_get_license(),
00119 sinfo_utl_cube_arith_create,
00120 sinfo_utl_cube_arith_exec,
00121 sinfo_utl_cube_arith_destroy) ;
00122
00123 cpl_pluginlist_append(list, plugin) ;
00124
00125 return 0;
00126 }
00127
00128
00137
00138 static int sinfo_utl_cube_arith_create(cpl_plugin * plugin)
00139 {
00140 cpl_recipe * recipe ;
00141 cpl_parameter * p ;
00142
00143
00144 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00145 recipe = (cpl_recipe *)plugin ;
00146 else return -1 ;
00147 cpl_error_reset();
00148 irplib_reset();
00149
00150 recipe->parameters = cpl_parameterlist_new() ;
00151
00152
00153
00154 p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_arith.op",
00155 CPL_TYPE_STRING,
00156 "A possible operation: "
00157 "`/','*','+' or `-'",
00158 "sinfoni.sinfo_utl_cube_arith","/");
00159 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00160 cpl_parameterlist_append(recipe->parameters, p) ;
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_arith.value",
00173 CPL_TYPE_DOUBLE, "A constant to add",
00174 "sinfoni.sinfo_utl_cube_arith", 99999.0) ;
00175 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "value") ;
00176 cpl_parameterlist_append(recipe->parameters, p) ;
00177
00178
00179 return 0;
00180 }
00181
00182
00188
00189 static int sinfo_utl_cube_arith_exec(cpl_plugin * plugin)
00190 {
00191 cpl_recipe * recipe ;
00192 int code=0;
00193 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00194
00195
00196 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00197 recipe = (cpl_recipe *)plugin ;
00198 else return -1 ;
00199 sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00200 SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00201
00202 code = sinfo_utl_cube_arith(recipe->parameters, recipe->frames) ;
00203
00204 if (!cpl_errorstate_is_equal(initial_errorstate)) {
00205
00206
00207 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
00208 }
00209 return code;
00210 }
00211
00212
00218
00219 static int sinfo_utl_cube_arith_destroy(cpl_plugin * plugin)
00220 {
00221 cpl_recipe * recipe ;
00222
00223
00224 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00225 recipe = (cpl_recipe *)plugin ;
00226 else return -1 ;
00227
00228 cpl_parameterlist_delete(recipe->parameters) ;
00229 return 0 ;
00230 }