si_utl_spectrum_wavelength_shift.c

00001 /* $Id: si_utl_spectrum_wavelength_shift.c,v 1.1 2005/10/14 16:13:18 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 16:13:18 $
00024  * $Revision: 1.1 $
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_wavelength_shift.h>
00043 #include <sinfoni_memory.h>
00044 /*-----------------------------------------------------------------------------
00045                             Functions prototypes
00046  -----------------------------------------------------------------------------*/
00047 
00048 static int si_utl_spectrum_wavelength_shift_create(cpl_plugin *) ;
00049 static int si_utl_spectrum_wavelength_shift_exec(cpl_plugin *) ;
00050 static int si_utl_spectrum_wavelength_shift_destroy(cpl_plugin *) ;
00051 
00052 /*-----------------------------------------------------------------------------
00053                             Static variables
00054  -----------------------------------------------------------------------------*/
00055 
00056 static char si_utl_spectrum_wavelength_shift_description1[] =
00057 "This recipe shifts a spectrum in wavelength using a given \n"
00058 "interpolation method. The input file is a spectrum.\n"
00059 "Its associated tag should be SPECTRUM.\n"
00060 "The output is a spectrum shifted by a given amount. \n";
00061 
00062 static char si_utl_spectrum_wavelength_shift_description2[] =
00063 "Parameters are \n"
00064 "sinfoni.si_utl_spectrum_arith.method\n"
00065 "sinfoni.si_utl_spectrum_wavelength_shift.shift\n"
00066 "having aliases 'method' and 'shift' \n"
00067 "Information on relevant parameters can be found with\n"
00068 "esorex --params si_utl_spectrum_wavelength_shift\n"
00069 "esorex --help si_utl_spectrum_wavelength_shift\n"
00070 "\n";
00071 
00072 static char si_utl_spectrum_wavelength_shift_description[900];
00073 
00074 /*-----------------------------------------------------------------------------
00075                                 Functions code
00076  -----------------------------------------------------------------------------*/
00077 
00078 /*----------------------------------------------------------------------------*/
00086 /*----------------------------------------------------------------------------*/
00087 int cpl_plugin_get_info(cpl_pluginlist * list)
00088 {
00089     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00090     cpl_plugin  *   plugin = &recipe->interface ;
00091 
00092     strcpy(si_utl_spectrum_wavelength_shift_description,si_utl_spectrum_wavelength_shift_description1);
00093     strcat(si_utl_spectrum_wavelength_shift_description,si_utl_spectrum_wavelength_shift_description2);
00094 
00095     cpl_plugin_init(plugin,
00096                     CPL_PLUGIN_API,
00097                     SINFONI_BINARY_VERSION,
00098                     CPL_PLUGIN_TYPE_RECIPE,
00099                     "si_utl_spectrum_wavelength_shift",
00100                     "Spectrum wavelength shift",
00101                     si_utl_spectrum_wavelength_shift_description,
00102                     "Andrea Modigliani",
00103                     "Andrea.Modigliani@eso.org",
00104                     sinfoni_get_license(),
00105                     si_utl_spectrum_wavelength_shift_create,
00106                     si_utl_spectrum_wavelength_shift_exec,
00107                     si_utl_spectrum_wavelength_shift_destroy) ;
00108 
00109     cpl_pluginlist_append(list, plugin) ;
00110     
00111     return 0;
00112 }
00113 
00114 /*----------------------------------------------------------------------------*/
00123 /*----------------------------------------------------------------------------*/
00124 static int si_utl_spectrum_wavelength_shift_create(cpl_plugin * plugin)
00125 {
00126     cpl_recipe      * recipe ;
00127     cpl_parameter   * p ;
00128 
00129     /* Get the recipe out of the plugin */
00130     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00131         recipe = (cpl_recipe *)plugin ;
00132     else return -1 ;
00133 
00134     /* Create the parameters list in the cpl_recipe object */
00135     recipe->parameters = cpl_parameterlist_new() ; 
00136 
00137     /* Fill the parameters list */
00138      /* --stropt */
00139     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_arith.method", 
00140             CPL_TYPE_STRING, "A spectral shift method: 'S' (Spline),'P' (Polynomial)", 
00141             "sinfoni.si_utl_spectrum_arith","S");
00142     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method") ;
00143     cpl_parameterlist_append(recipe->parameters, p) ;
00144 
00145     /* --doubleopt */
00146     p = cpl_parameter_new_value("sinfoni.si_utl_spectrum_wavelength_shift.shift", 
00147             CPL_TYPE_DOUBLE, "wavelength shift in micron", "sinfoni.si_utl_spectrum_wavelength_shift", 0.1) ;
00148     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "shift") ;
00149     cpl_parameterlist_append(recipe->parameters, p) ;
00150 
00151     /* Return */
00152     return 0;
00153 }
00154 
00155 /*----------------------------------------------------------------------------*/
00161 /*----------------------------------------------------------------------------*/
00162 static int si_utl_spectrum_wavelength_shift_exec(cpl_plugin * plugin)
00163 {
00164     cpl_recipe  *   recipe ;
00165     
00166     /* Get the recipe out of the plugin */
00167     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00168         recipe = (cpl_recipe *)plugin ;
00169     else return -1 ;
00170 
00171     return si_utl_spectrum_wavelength_shift(recipe->parameters, recipe->frames) ;
00172 }
00173 
00174 /*----------------------------------------------------------------------------*/
00180 /*----------------------------------------------------------------------------*/
00181 static int si_utl_spectrum_wavelength_shift_destroy(cpl_plugin * plugin)
00182 {
00183     cpl_recipe  *   recipe ;
00184     
00185     /* Get the recipe out of the plugin */
00186     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00187         recipe = (cpl_recipe *)plugin ;
00188     else return -1 ;
00189 
00190     cpl_parameterlist_delete(recipe->parameters) ; 
00191     return 0 ;
00192 }
00193 

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