sinfo_utl_spectrum_divide_by_blackbody.c

00001 /* $Id: sinfo_utl_spectrum_divide_by_blackbody.c,v 1.10 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.10 $
00025  * $Name: HEAD $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  ----------------------------------------------------------------------------*/
00035 
00036 /* cpl */
00037 #include <cpl.h>
00038  
00039 /* irplib */
00040 #include <irplib_utils.h>
00041 #include <string.h>
00042 #include <sinfo_tpl_utils.h>
00043 #include <sinfo_pfits.h>
00044 #include <sinfo_tpl_dfs.h>
00045 #include <sinfo_msg.h>
00046 #include <sinfo_utl_spectrum_divide_by_blackbody.h>
00047 /*-----------------------------------------------------------------------------
00048                             Functions prototypes
00049  ----------------------------------------------------------------------------*/
00050 
00051 static int sinfo_utl_spectrum_divide_by_blackbody_create(cpl_plugin *) ;
00052 static int sinfo_utl_spectrum_divide_by_blackbody_exec(cpl_plugin *) ;
00053 static int sinfo_utl_spectrum_divide_by_blackbody_destroy(cpl_plugin *) ;
00054 
00055 /*-----------------------------------------------------------------------------
00056                             Static variables
00057  ----------------------------------------------------------------------------*/
00058 
00059 static char sinfo_utl_spectrum_divide_by_blackbody_description1[] =
00060 "This recipe divides a spectrum by a black body "
00061 "spectrum of given temperature.\n"
00062 "The input file is a spectrum. Its associated tag must be SPECTRUM.\n"
00063 "The output is a spectrum\n";
00064 
00065 
00066 static char sinfo_utl_spectrum_divide_by_blackbody_description2[] =
00067 "Parameter is \n"
00068 "sinfoni.sinfo_utl_spectrum_divide_by_blackbody.temperature\n"
00069 "having aliases 'temp' \n"
00070 "Information on relevant parameters can be found with\n"
00071 "esorex --params sinfo_utl_spectrum_divide_by_blackbody\n"
00072 "esorex --help sinfo_utl_spectrum_divide_by_blackbody\n"
00073 "\n";
00074 
00075 static char sinfo_utl_spectrum_divide_by_blackbody_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_divide_by_blackbody_description,
00103            sinfo_utl_spectrum_divide_by_blackbody_description1);
00104     strcat(sinfo_utl_spectrum_divide_by_blackbody_description,
00105            sinfo_utl_spectrum_divide_by_blackbody_description2);
00106 
00107     cpl_plugin_init(plugin,
00108                     CPL_PLUGIN_API,
00109                     SINFONI_BINARY_VERSION,
00110                     CPL_PLUGIN_TYPE_RECIPE,
00111                     "sinfo_utl_spectrum_divide_by_blackbody",
00112                     "Spectrum normalization by a blackbody",
00113                     sinfo_utl_spectrum_divide_by_blackbody_description,
00114                     "Andrea Modigliani",
00115                     "Andrea.Modigliani@eso.org",
00116                     sinfo_get_license(),
00117                     sinfo_utl_spectrum_divide_by_blackbody_create,
00118                     sinfo_utl_spectrum_divide_by_blackbody_exec,
00119                     sinfo_utl_spectrum_divide_by_blackbody_destroy) ;
00120 
00121     cpl_pluginlist_append(list, plugin) ;
00122     
00123     return 0;
00124 }
00125 
00126 /*---------------------------------------------------------------------------*/
00135 /*---------------------------------------------------------------------------*/
00136 static int sinfo_utl_spectrum_divide_by_blackbody_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 
00146     cpl_error_reset();
00147     irplib_reset();
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     /* --doubleopt */
00154     p = cpl_parameter_new_value("sinfoni.sinfo_utl_spectrum_divide_by_blackbody.temperature", 
00155             CPL_TYPE_DOUBLE, "Black Body Temperature", 
00156             "sinfoni.sinfo_utl_spectrum_divide_by_blackbody", 100000.) ;
00157     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "temp") ;
00158     cpl_parameterlist_append(recipe->parameters, p) ;
00159 
00160     /* Return */
00161     return 0;
00162 }
00163 
00164 /*---------------------------------------------------------------------------*/
00170 /*---------------------------------------------------------------------------*/
00171 static int sinfo_utl_spectrum_divide_by_blackbody_exec(cpl_plugin * plugin)
00172 {
00173     cpl_recipe  *   recipe ;
00174     int code=0;
00175 
00176     /* Get the recipe out of the plugin */
00177     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00178         recipe = (cpl_recipe *)plugin ;
00179     else return -1 ;
00180  
00181        sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00182         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00183     code=sinfo_utl_spectrum_divide_by_blackbody(recipe->parameters, 
00184                                                   recipe->frames) ;
00185     return code;
00186 }
00187 
00188 /*---------------------------------------------------------------------------*/
00194 /*---------------------------------------------------------------------------*/
00195 static int sinfo_utl_spectrum_divide_by_blackbody_destroy(cpl_plugin * plugin)
00196 {
00197     cpl_recipe  *   recipe ;
00198     
00199     /* Get the recipe out of the plugin */
00200     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00201         recipe = (cpl_recipe *)plugin ;
00202     else return -1 ;
00203 
00204     cpl_parameterlist_delete(recipe->parameters) ; 
00205     return 0 ;
00206 }
00207 

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