sinfo_utl_cube2ima.c

00001 /* $Id: sinfo_utl_cube2ima.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: sinfo-2_2_5 $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  ----------------------------------------------------------------------------*/
00035 /* cpl */
00036 #include <cpl.h>
00037  
00038 /* irplib */
00039 #include <irplib_utils.h>
00040 #include <sinfo_msg.h>
00041 #include <sinfo_tpl_utils.h>
00042 #include <sinfo_pfits.h>
00043 #include <sinfo_tpl_dfs.h>
00044 #include <sinfo_utl_cube2ima.h>
00045 /*-----------------------------------------------------------------------------
00046                             Functions prototypes
00047  ----------------------------------------------------------------------------*/
00048 
00049 static int sinfo_utl_cube2ima_create(cpl_plugin *) ;
00050 static int sinfo_utl_cube2ima_exec(cpl_plugin *) ;
00051 static int sinfo_utl_cube2ima_destroy(cpl_plugin *) ;
00052 
00053 /*-----------------------------------------------------------------------------
00054                             Static variables
00055  ----------------------------------------------------------------------------*/
00056 
00057 static char sinfo_utl_cube2ima_description[] =
00058 "This recipe performs cube to image comversion.\n"
00059 "The input file is a cube which is contained in the sof file\n"
00060 "Its tag should be CUBE.\n"
00061 "The output is an image resulting from the average of the \n"
00062 "cube over a  wavelength rage which can be set by parameters \n"
00063 "sinfoni.sinfo_utl_cube2ima.ws sinfoni.sinfo_utl_cube2ima.we\n"
00064 "having aliases 'ws' 'we'\n"
00065 "Information on relevant parameters can be found with\n"
00066 "esorex --params sinfo_utl_cube2ima\n"
00067 "esorex --help sinfo_utl_cube2ima\n"
00068 "\n";
00069 
00070 /*-----------------------------------------------------------------------------
00071                                 Functions code
00072  ----------------------------------------------------------------------------*/
00073 /*---------------------------------------------------------------------------*/
00077 /*---------------------------------------------------------------------------*/
00079 /*---------------------------------------------------------------------------*/
00087 /*---------------------------------------------------------------------------*/
00088 int cpl_plugin_get_info(cpl_pluginlist * list)
00089 {
00090     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00091     cpl_plugin  *   plugin = &recipe->interface ;
00092 
00093     cpl_plugin_init(plugin,
00094                     CPL_PLUGIN_API,
00095                     SINFONI_BINARY_VERSION,
00096                     CPL_PLUGIN_TYPE_RECIPE,
00097                     "sinfo_utl_cube2ima",
00098                     "Cube to image conversion",
00099                     sinfo_utl_cube2ima_description,
00100                     "Andrea Modigliani",
00101                     "Andrea.Modigliani@eso.org",
00102                     sinfo_get_license(),
00103                     sinfo_utl_cube2ima_create,
00104                     sinfo_utl_cube2ima_exec,
00105                     sinfo_utl_cube2ima_destroy) ;
00106 
00107     cpl_pluginlist_append(list, plugin) ;
00108     
00109     return 0;
00110 }
00111 
00112 /*---------------------------------------------------------------------------*/
00121 /*---------------------------------------------------------------------------*/
00122 static int sinfo_utl_cube2ima_create(cpl_plugin * plugin)
00123 {
00124     cpl_recipe      * recipe ;
00125     cpl_parameter   * p ;
00126 
00127     /* Get the recipe out of the plugin */
00128     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00129         recipe = (cpl_recipe *)plugin ;
00130     else return -1 ;
00131     cpl_error_reset();
00132     irplib_reset();
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 
00140     /* --doubleopt */
00141     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2ima.ws", 
00142                                 CPL_TYPE_DOUBLE, 
00143                                 "starting wavelength", 
00144                                 "sinfoni.sinfo_utl_cube2ima", 
00145                                 0.9999) ;
00146     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ws") ;
00147     cpl_parameterlist_append(recipe->parameters, p) ;
00148 
00149 
00150     /* --doubleopt */
00151     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2ima.we", 
00152                                 CPL_TYPE_DOUBLE, 
00153                                 "starting wavelength", 
00154                                 "sinfoni.sinfo_utl_cube2ima", 
00155                                 2.999) ;
00156     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "we") ;
00157     cpl_parameterlist_append(recipe->parameters, p) ;
00158 
00159     /* Return */
00160     return 0;
00161 }
00162 
00163 /*---------------------------------------------------------------------------*/
00169 /*---------------------------------------------------------------------------*/
00170 static int sinfo_utl_cube2ima_exec(cpl_plugin * plugin)
00171 {
00172     cpl_recipe  *   recipe ;
00173     int result=0;
00174     cpl_errorstate initial_errorstate = cpl_errorstate_get();
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 
00184     result=sinfo_utl_cube2ima(recipe->parameters, recipe->frames) ;
00185 
00186     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00187         /* Dump the error history since recipe execution start.                
00188            At this point the recipe cannot recover from the error */           
00189         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00190     } 
00191 
00192     return result ;
00193 }
00194 
00195 /*---------------------------------------------------------------------------*/
00201 /*---------------------------------------------------------------------------*/
00202 static int sinfo_utl_cube2ima_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 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1