sinfo_utl_spectrum_wavelength_shift.c

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

Generated on 3 Mar 2013 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1