recipes/sinfo_utl_cube_arith.c

00001 /* $Id: sinfo_utl_cube_arith.c,v 1.7 2006/12/19 17:01:36 amodigli Exp $
00002  *
00003  * This file is part of the SINFONI Pipeline
00004  * Copyright (C) 2002,2003 European Southern Observatory
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 /*
00022  * $Author: amodigli $
00023  * $Date: 2006/12/19 17:01:36 $
00024  * $Revision: 1.7 $
00025  * $Name:  $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  ----------------------------------------------------------------------------*/
00035 
00036 /* cpl */
00037 #include <cpl.h>
00038 /* irplib */
00039 #include <irplib_utils.h>
00040 
00041 #include <sinfo_tpl_utils.h>
00042 #include <sinfo_pfits.h>
00043 #include <sinfo_tpl_dfs.h>
00044 #include <sinfo_utl_cube_arith.h>
00045 #include <sinfo_msg.h>
00046 
00047 /*-----------------------------------------------------------------------------
00048                             Functions prototypes
00049  ----------------------------------------------------------------------------*/
00050 
00051 static int sinfo_utl_cube_arith_create(cpl_plugin *) ;
00052 static int sinfo_utl_cube_arith_exec(cpl_plugin *) ;
00053 static int sinfo_utl_cube_arith_destroy(cpl_plugin *) ;
00054 
00055 /*-----------------------------------------------------------------------------
00056                             Static variables
00057  ----------------------------------------------------------------------------*/
00058 
00059 static char sinfo_utl_cube_arith_description1[] =
00060 "This recipe perform cube arithmetics.\n"
00061 "If parameter value is specified the input frame is a cube \n"
00062 "in a sof file with tag CUBE\n"
00063 "Else the input files are a cube and an images or a spectrum\n"
00064 "their associated tags should be respectively CUBE, IMA or SPECTRUM.\n"
00065 "The output is a cube with tag PRO_CUBE resulting from the operation \n"
00066 "CUBE op IMA or \n"
00067 "CUBE op SPECTRUM or\n"
00068 "CUBE op value where op indicates\n"
00069 "the operation to be performed\n";
00070 
00071 
00072 static char sinfo_utl_cube_arith_description2[] =
00073 "Information on relevant parameters can be found with\n"
00074 "esorex --params sinfo_utl_cube_arith\n"
00075 "esorex --help sinfo_utl_cube_arith\n"
00076 "\n";
00077 
00078 static char sinfo_utl_cube_arith_description[600];
00079 
00080 
00081 
00082 /*-----------------------------------------------------------------------------
00083                                 Functions code
00084  ----------------------------------------------------------------------------*/
00085 /*---------------------------------------------------------------------------*/
00089 /*---------------------------------------------------------------------------*/
00091 /*---------------------------------------------------------------------------*/
00099 /*---------------------------------------------------------------------------*/
00100 int cpl_plugin_get_info(cpl_pluginlist * list)
00101 {
00102     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00103     cpl_plugin  *   plugin = &recipe->interface ;
00104 
00105     strcpy(sinfo_utl_cube_arith_description,sinfo_utl_cube_arith_description1);
00106     strcat(sinfo_utl_cube_arith_description,sinfo_utl_cube_arith_description2);
00107 
00108     cpl_plugin_init(plugin,
00109                     CPL_PLUGIN_API,
00110                     SINFONI_BINARY_VERSION,
00111                     CPL_PLUGIN_TYPE_RECIPE,
00112                     "sinfo_utl_cube_arith",
00113                     "Cube arithmetics",
00114                     sinfo_utl_cube_arith_description,
00115                     "Andrea Modigliani",
00116                     "Andrea.Modigliani@eso.org",
00117                     sinfo_get_license(),
00118                     sinfo_utl_cube_arith_create,
00119                     sinfo_utl_cube_arith_exec,
00120                     sinfo_utl_cube_arith_destroy) ;
00121 
00122     cpl_pluginlist_append(list, plugin) ;
00123     
00124     return 0;
00125 }
00126 
00127 /*---------------------------------------------------------------------------*/
00136 /*---------------------------------------------------------------------------*/
00137 static int sinfo_utl_cube_arith_create(cpl_plugin * plugin)
00138 {
00139     cpl_recipe      * recipe ;
00140     cpl_parameter   * p ;
00141 
00142     /* Get the recipe out of the plugin */
00143     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00144         recipe = (cpl_recipe *)plugin ;
00145     else return -1 ;
00146     cpl_error_reset();
00147     irplib_reset();
00148     /* Create the parameters list in the cpl_recipe object */
00149     recipe->parameters = cpl_parameterlist_new() ; 
00150 
00151     /* Fill the parameters list */
00152     /* --stropt */
00153     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_arith.op", 
00154                                 CPL_TYPE_STRING, 
00155                                 "A possible operation: "
00156                                 "`/','*','+' or `-'", 
00157                                 "sinfoni.sinfo_utl_cube_arith","/");
00158     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00159     cpl_parameterlist_append(recipe->parameters, p) ;
00160 
00161 
00162     /* --doubleopt */
00163     /*
00164     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_arith.temperature", 
00165                                  CPL_TYPE_DOUBLE, "Black Body Temperature", 
00166                                  "sinfoni.sinfo_utl_cube_arith", 100000.) ;
00167     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "temp") ;
00168     cpl_parameterlist_append(recipe->parameters, p) ;
00169     */
00170 
00171     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_arith.value", 
00172                                 CPL_TYPE_DOUBLE, "A constant to add", 
00173                                 "sinfoni.sinfo_utl_cube_arith", 99999.0) ;
00174     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "value") ;
00175     cpl_parameterlist_append(recipe->parameters, p) ;
00176  
00177     /* Return */
00178     return 0;
00179 }
00180 
00181 /*---------------------------------------------------------------------------*/
00187 /*---------------------------------------------------------------------------*/
00188 static int sinfo_utl_cube_arith_exec(cpl_plugin * plugin)
00189 {
00190     cpl_recipe  *   recipe ;
00191     int code=0;
00192     /* Get the recipe out of the plugin */
00193     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00194         recipe = (cpl_recipe *)plugin ;
00195     else return -1 ;
00196       sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00197         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00198 
00199     code = sinfo_utl_cube_arith(recipe->parameters, recipe->frames) ;
00200 
00201     return code;
00202 }
00203 
00204 /*---------------------------------------------------------------------------*/
00210 /*---------------------------------------------------------------------------*/
00211 static int sinfo_utl_cube_arith_destroy(cpl_plugin * plugin)
00212 {
00213     cpl_recipe  *   recipe ;
00214 
00215     /* Get the recipe out of the plugin */
00216     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00217         recipe = (cpl_recipe *)plugin ;
00218     else return -1 ;
00219 
00220     cpl_parameterlist_delete(recipe->parameters) ; 
00221     return 0 ;
00222 }

Generated on Wed Jan 17 08:33:44 2007 for SINFONI Pipeline Reference Manual by  doxygen 1.4.4