si_utl_spectrum_arith.c

00001 /* $Id: si_utl_spectrum_arith.c,v 1.7 2005/10/14 13:08:33 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 13:08:33 $
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 #include <cpl.h>
00037  
00038 
00039 #include "sinfoni_tpl_utils.h"
00040 #include "sinfoni_pfits.h"
00041 #include "sinfoni_tpl_dfs.h"
00042 #include <utl_spectrum_arith.h>
00043 #include <sinfoni_memory.h>
00044 /*-----------------------------------------------------------------------------
00045                             Functions prototypes
00046  -----------------------------------------------------------------------------*/
00047 
00048 static int si_utl_spectrum_arith_create(cpl_plugin *) ;
00049 static int si_utl_spectrum_arith_exec(cpl_plugin *) ;
00050 static int si_utl_spectrum_arith_destroy(cpl_plugin *) ;
00051 
00052 /*-----------------------------------------------------------------------------
00053                             Static variables
00054  -----------------------------------------------------------------------------*/
00055 
00056 static char si_utl_spectrum_arith_description1[] =
00057 "This recipe perform spectrum arithmetics: \n"
00058 "division by a black body spectrum or spectrum shift\n"
00059 "according to value of the input parameter 'method'\n"
00060 "The input file is a spectrum\n"
00061 "Its associated tag should be SPECTRUM.\n"
00062 "The output is a spectrum resulting either in \n"
00063 "the division of the input spectrum by a black body spectrum \n"
00064 "of given temperature (parameter 'temp')\n"
00065 "or by a simple wavelength shift (parameter 'shift')\n";
00066 
00067 static char si_utl_spectrum_arith_description2[] =
00068 "Parameters are \n"
00069 "sinfoni.si_utl_spectrum_arith.operation\n"
00070 "sinfoni.si_utl_spectrum_arith.method\n"
00071 "sinfoni.si_utl_spectrum_arith.temperature\n"
00072 "sinfoni.si_utl_spectrum_arith.shift\n"
00073 "having aliases op 'method', 'temp', 'shift' \n"
00074 "Information on relevant parameters can be found with\n"
00075 "esorex --params si_utl_spectrum_arith\n"
00076 "esorex --help si_utl_spectrum_arith\n"
00077 "\n";
00078 
00079 static char si_utl_spectrum_arith_description[900];
00080 
00081 /*-----------------------------------------------------------------------------
00082                                 Functions code
00083  -----------------------------------------------------------------------------*/
00084 
00085 /*----------------------------------------------------------------------------*/
00093 /*----------------------------------------------------------------------------*/
00094 int cpl_plugin_get_info(cpl_pluginlist * list)
00095 {
00096     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00097     cpl_plugin  *   plugin = &recipe->interface ;
00098 
00099     strcpy(si_utl_spectrum_arith_description,si_utl_spectrum_arith_description1);
00100     strcat(si_utl_spectrum_arith_description,si_utl_spectrum_arith_description2);
00101 
00102     cpl_plugin_init(plugin,
00103                     CPL_PLUGIN_API,
00104                     SINFONI_BINARY_VERSION,
00105                     CPL_PLUGIN_TYPE_RECIPE,
00106                     "si_utl_spectrum_arith",
00107                     "Spectrum manipulation",
00108                     si_utl_spectrum_arith_description,
00109                     "Andrea Modigliani",
00110                     "Andrea.Modigliani@eso.org",
00111                     sinfoni_get_license(),
00112                     si_utl_spectrum_arith_create,
00113                     si_utl_spectrum_arith_exec,
00114                     si_utl_spectrum_arith_destroy) ;
00115 
00116     cpl_pluginlist_append(list, plugin) ;
00117     
00118     return 0;
00119 }
00120 
00121 /*----------------------------------------------------------------------------*/
00130 /*----------------------------------------------------------------------------*/
00131 static int si_utl_spectrum_arith_create(cpl_plugin * plugin)
00132 {
00133     cpl_recipe      * recipe ;
00134     cpl_parameter   * p ;
00135 
00136     /* Get the recipe out of the plugin */
00137     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00138         recipe = (cpl_recipe *)plugin ;
00139     else return -1 ;
00140 
00141     /* Create the parameters list in the cpl_recipe object */
00142     recipe->parameters = cpl_parameterlist_new() ; 
00143 
00144     /* Fill the parameters list */
00145     /* --stropt */
00146 
00147     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_arith.op", 
00148             CPL_TYPE_STRING, "A possible operation: 'division' (by a Black Body spectrum of given temperature), 'shift' (by a given wavelength).", 
00149             "sinfoni.si_utl_spectrum_arith","division");
00150     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00151     cpl_parameterlist_append(recipe->parameters, p) ;
00152 
00153 
00154     /* --stropt */
00155     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_arith.method", 
00156             CPL_TYPE_STRING, "A spectral shift method: 'S','P'", 
00157             "sinfoni.si_utl_spectrum_arith","S");
00158     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method") ;
00159     cpl_parameterlist_append(recipe->parameters, p) ;
00160 
00161 
00162     /* --doubleopt */
00163     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_arith.temperature", 
00164             CPL_TYPE_DOUBLE, "Black Body Temperature", "sinfoni.si_utl_spectrum_arith", 100000.) ;
00165     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "temp") ;
00166     cpl_parameterlist_append(recipe->parameters, p) ;
00167 
00168 
00169     /* --doubleopt */
00170     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_arith.shift", 
00171             CPL_TYPE_DOUBLE, "wavelength shift in micron", "sinfoni.si_utl_spectrum_arith", 0.1) ;
00172     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "shift") ;
00173     cpl_parameterlist_append(recipe->parameters, p) ;
00174 
00175     /* Return */
00176     return 0;
00177 }
00178 
00179 /*----------------------------------------------------------------------------*/
00185 /*----------------------------------------------------------------------------*/
00186 static int si_utl_spectrum_arith_exec(cpl_plugin * plugin)
00187 {
00188     cpl_recipe  *   recipe ;
00189     
00190     /* Get the recipe out of the plugin */
00191     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00192         recipe = (cpl_recipe *)plugin ;
00193     else return -1 ;
00194 
00195     return si_utl_spectrum_arith(recipe->parameters, recipe->frames) ;
00196 }
00197 
00198 /*----------------------------------------------------------------------------*/
00204 /*----------------------------------------------------------------------------*/
00205 static int si_utl_spectrum_arith_destroy(cpl_plugin * plugin)
00206 {
00207     cpl_recipe  *   recipe ;
00208     
00209     /* Get the recipe out of the plugin */
00210     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00211         recipe = (cpl_recipe *)plugin ;
00212     else return -1 ;
00213 
00214     cpl_parameterlist_delete(recipe->parameters) ; 
00215     return 0 ;
00216 }
00217 

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