recipes/sinfo_utl_spectrum_wavelength_shift.c

00001 /* $Id: sinfo_utl_spectrum_wavelength_shift.c,v 1.8 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.8 $
00025  * $Name:  $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  -----------------------------------------------------------------------------*/
00035 /* irplib */
00036 #include <cpl.h>
00037  
00038 /* irplib */
00039 #include <irplib_utils.h>
00040 #include <sinfo_msg.h>
00041 
00042 #include <sinfo_tpl_utils.h>
00043 #include <sinfo_pfits.h>
00044 #include <sinfo_tpl_dfs.h>
00045 #include <sinfo_utl_spectrum_wavelength_shift.h>
00046 /*-----------------------------------------------------------------------------
00047                             Functions prototypes
00048  ----------------------------------------------------------------------------*/
00049 
00050 static int sinfo_utl_spectrum_wavelength_shift_create(cpl_plugin *) ;
00051 static int sinfo_utl_spectrum_wavelength_shift_exec(cpl_plugin *) ;
00052 static int sinfo_utl_spectrum_wavelength_shift_destroy(cpl_plugin *) ;
00053 
00054 /*-----------------------------------------------------------------------------
00055                             Static variables
00056  ----------------------------------------------------------------------------*/
00057 
00058 static char sinfo_utl_spectrum_wavelength_shift_description1[] =
00059 "This recipe shifts a spectrum in wavelength using a given \n"
00060 "interpolation method. The input file is a spectrum.\n"
00061 "Its associated tag should be SPECTRUM.\n"
00062 "The output is a spectrum shifted by a given amount. \n";
00063 
00064 static char sinfo_utl_spectrum_wavelength_shift_description2[] =
00065 "Parameters are \n"
00066 "sinfoni.sinfo_utl_spectrum_arith.method\n"
00067 "sinfoni.sinfo_utl_spectrum_wavelength_shift.shift\n"
00068 "having aliases 'method' and 'shift' \n"
00069 "Information on relevant parameters can be found with\n"
00070 "esorex --params sinfo_utl_spectrum_wavelength_shift\n"
00071 "esorex --help sinfo_utl_spectrum_wavelength_shift\n"
00072 "\n";
00073 
00074 static char sinfo_utl_spectrum_wavelength_shift_description[900];
00075 
00076 /*-----------------------------------------------------------------------------
00077                                 Functions code
00078  ----------------------------------------------------------------------------*/
00079 /*---------------------------------------------------------------------------*/
00084 /*---------------------------------------------------------------------------*/
00087 /*---------------------------------------------------------------------------*/
00095 /*---------------------------------------------------------------------------*/
00096 int cpl_plugin_get_info(cpl_pluginlist * list)
00097 {
00098     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00099     cpl_plugin  *   plugin = &recipe->interface ;
00100 
00101     strcpy(sinfo_utl_spectrum_wavelength_shift_description,
00102            sinfo_utl_spectrum_wavelength_shift_description1);
00103     strcat(sinfo_utl_spectrum_wavelength_shift_description,
00104            sinfo_utl_spectrum_wavelength_shift_description2);
00105 
00106     cpl_plugin_init(plugin,
00107                     CPL_PLUGIN_API,
00108                     SINFONI_BINARY_VERSION,
00109                     CPL_PLUGIN_TYPE_RECIPE,
00110                     "sinfo_utl_spectrum_wavelength_shift",
00111                     "Spectrum wavelength shift",
00112                     sinfo_utl_spectrum_wavelength_shift_description,
00113                     "Andrea Modigliani",
00114                     "Andrea.Modigliani@eso.org",
00115                     sinfo_get_license(),
00116                     sinfo_utl_spectrum_wavelength_shift_create,
00117                     sinfo_utl_spectrum_wavelength_shift_exec,
00118                     sinfo_utl_spectrum_wavelength_shift_destroy) ;
00119 
00120     cpl_pluginlist_append(list, plugin) ;
00121     
00122     return 0;
00123 }
00124 
00125 /*---------------------------------------------------------------------------*/
00134 /*---------------------------------------------------------------------------*/
00135 static int sinfo_utl_spectrum_wavelength_shift_create(cpl_plugin * plugin)
00136 {
00137     cpl_recipe      * recipe ;
00138     cpl_parameter   * p ;
00139 
00140     /* Get the recipe out of the plugin */
00141     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00142         recipe = (cpl_recipe *)plugin ;
00143     else return -1 ;
00144     cpl_error_reset();
00145     irplib_reset();
00146 
00147     /* Create the parameters list in the cpl_recipe object */
00148     recipe->parameters = cpl_parameterlist_new() ; 
00149 
00150     /* Fill the parameters list */
00151      /* --stropt */
00152     p = cpl_parameter_new_value("sinfoni.sinfo_utl_spectrum_arith.method", 
00153                                 CPL_TYPE_STRING, 
00154                                 "A spectral shift method: "
00155                                 "'S' (Spline),'P' (Polynomial)", 
00156                                 "sinfoni.sinfo_utl_spectrum_arith","S");
00157     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method") ;
00158     cpl_parameterlist_append(recipe->parameters, p) ;
00159 
00160     /* --doubleopt */
00161     p = cpl_parameter_new_value("sinfoni.sinfo_utl_spectrum_wavelength_shift.shift", 
00162                                 CPL_TYPE_DOUBLE, 
00163                                 "wavelength shift in micron", 
00164                                 "sinfoni.sinfo_utl_spectrum_wavelength_shift", 
00165                                 0.1) ;
00166     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "shift") ;
00167     cpl_parameterlist_append(recipe->parameters, p) ;
00168 
00169     /* Return */
00170     return 0;
00171 }
00172 
00173 /*---------------------------------------------------------------------------*/
00179 /*---------------------------------------------------------------------------*/
00180 static int sinfo_utl_spectrum_wavelength_shift_exec(cpl_plugin * plugin)
00181 {
00182     cpl_recipe  *   recipe ;
00183     
00184     /* Get the recipe out of the plugin */
00185     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00186         recipe = (cpl_recipe *)plugin ;
00187     else return -1 ;
00188       sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00189        SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00190 
00191     return sinfo_utl_spectrum_wavelength_shift(recipe->parameters, 
00192                                                recipe->frames) ;
00193 }
00194 
00195 /*---------------------------------------------------------------------------*/
00201 /*---------------------------------------------------------------------------*/
00202 static int sinfo_utl_spectrum_wavelength_shift_destroy(cpl_plugin * plugin)
00203 {
00204     cpl_recipe  *   recipe ;
00205     
00206     /* Get the recipe out of the plugin */
00207     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00208         recipe = (cpl_recipe *)plugin ;
00209     else return -1 ;
00210 
00211     cpl_parameterlist_delete(recipe->parameters) ; 
00212     return 0 ;
00213 }
00214 

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