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
00036 #include <cpl.h>
00037
00038 #include "sinfoni_tpl_utils.h"
00039 #include "sinfoni_pfits.h"
00040 #include "sinfoni_tpl_dfs.h"
00041 #include <utl_cube_arith.h>
00042 #include <sinfoni_memory.h>
00043
00044
00045
00046
00047
00048 static int si_utl_cube_arith_create(cpl_plugin *) ;
00049 static int si_utl_cube_arith_exec(cpl_plugin *) ;
00050 static int si_utl_cube_arith_destroy(cpl_plugin *) ;
00051
00052
00053
00054
00055
00056 static char si_utl_cube_arith_description1[] =
00057 "This recipe perform cube arithmetics.\n"
00058 "If parameter value is specified the input frame is a cube in sof file with tag CUBE\n"
00059 "Else the input files are a cube and an images or a spectrum\n"
00060 "their associated tags should be respectively CUBE, IMA or SPECTRUM.\n"
00061 "The output is a cube with tag PRO_CUBE resulting from the operation \n"
00062 "CUBE op IMA or \n"
00063 "CUBE op SPECTRUM or\n"
00064 "CUBE op value where op indicates\n"
00065 "the operation to be performed\n";
00066
00067
00068 static char si_utl_cube_arith_description2[] =
00069 "Information on relevant parameters can be found with\n"
00070 "esorex --params si_utl_cube_arith\n"
00071 "esorex --help si_utl_cube_arith\n"
00072 "\n";
00073
00074 static char si_utl_cube_arith_description[600];
00075
00076
00077
00078
00079
00080
00081
00082
00090
00091 int cpl_plugin_get_info(cpl_pluginlist * list)
00092 {
00093 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
00094 cpl_plugin * plugin = &recipe->interface ;
00095
00096 strcpy(si_utl_cube_arith_description,si_utl_cube_arith_description1);
00097 strcat(si_utl_cube_arith_description,si_utl_cube_arith_description2);
00098
00099 cpl_plugin_init(plugin,
00100 CPL_PLUGIN_API,
00101 SINFONI_BINARY_VERSION,
00102 CPL_PLUGIN_TYPE_RECIPE,
00103 "si_utl_cube_arith",
00104 "Cube arithmetics",
00105 si_utl_cube_arith_description,
00106 "Andrea Modigliani",
00107 "Andrea.Modigliani@eso.org",
00108 sinfoni_get_license(),
00109 si_utl_cube_arith_create,
00110 si_utl_cube_arith_exec,
00111 si_utl_cube_arith_destroy) ;
00112
00113 cpl_pluginlist_append(list, plugin) ;
00114
00115 return 0;
00116 }
00117
00118
00127
00128 static int si_utl_cube_arith_create(cpl_plugin * plugin)
00129 {
00130 cpl_recipe * recipe ;
00131 cpl_parameter * p ;
00132
00133
00134 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00135 recipe = (cpl_recipe *)plugin ;
00136 else return -1 ;
00137
00138
00139 recipe->parameters = cpl_parameterlist_new() ;
00140
00141
00142
00143 p = cpl_parameter_new_value("sinfoni.si_utl_cube_arith.op",
00144 CPL_TYPE_STRING, "A possible operation: `/','*','+' or `-'", "sinfoni.si_utl_cube_arith","/");
00145 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00146 cpl_parameterlist_append(recipe->parameters, p) ;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 p = cpl_parameter_new_value("sinfoni.si_utl_cube_arith.value",
00158 CPL_TYPE_DOUBLE, "A constant to add", "sinfoni.si_utl_cube_arith", 99999.0) ;
00159 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "value") ;
00160 cpl_parameterlist_append(recipe->parameters, p) ;
00161
00162
00163 return 0;
00164 }
00165
00166
00172
00173 static int si_utl_cube_arith_exec(cpl_plugin * plugin)
00174 {
00175 cpl_recipe * recipe ;
00176 int code=0;
00177
00178 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00179 recipe = (cpl_recipe *)plugin ;
00180 else return -1 ;
00181 code = si_utl_cube_arith(recipe->parameters, recipe->frames) ;
00182 sinfoni_memory_status();
00183 return code;
00184 }
00185
00186
00192
00193 static int si_utl_cube_arith_destroy(cpl_plugin * plugin)
00194 {
00195 cpl_recipe * recipe ;
00196
00197
00198 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
00199 recipe = (cpl_recipe *)plugin ;
00200 else return -1 ;
00201
00202 cpl_parameterlist_delete(recipe->parameters) ;
00203 return 0 ;
00204 }
00205