si_utl_cube_arith.c

00001 /* $Id: si_utl_cube_arith.c,v 1.12 2005/10/14 14:40:59 amodigli Exp $
00002  *
00003  * This file is part of the IIINSTRUMENT 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: 2005/10/14 14:40:59 $
00024  * $Revision: 1.12 $
00025  * $Name:  $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
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                             Functions prototypes
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                             Static variables
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                                 Functions code
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     /* Get the recipe out of the plugin */
00134     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00135         recipe = (cpl_recipe *)plugin ;
00136     else return -1 ;
00137 
00138     /* Create the parameters list in the cpl_recipe object */
00139     recipe->parameters = cpl_parameterlist_new() ; 
00140 
00141     /* Fill the parameters list */
00142     /* --stropt */
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     /* --doubleopt */
00150     /*
00151     p = cpl_parameter_new_value("sinfoni.si_utl_cube_arith.temperature", 
00152             CPL_TYPE_DOUBLE, "Black Body Temperature", "sinfoni.si_utl_cube_arith", 100000.) ;
00153     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "temp") ;
00154     cpl_parameterlist_append(recipe->parameters, p) ;
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     /* Return */
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     /* Get the recipe out of the plugin */
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     /* Get the recipe out of the plugin */
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 

Generated on Wed Oct 26 13:08:54 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001