sinfo_utl_cube_test.c

00001 /* $Id: sinfo_utl_cube_test.c,v 1.8 2008/02/12 09:11:10 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: 2008/02/12 09:11:10 $
00024  * $Revision: 1.8 $
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 
00036 /* cpl */
00037 #include <cpl.h>
00038 /* irplib */
00039 #include <irplib_utils.h>
00040 
00041 #include <sinfo_tpl_utils.h>
00042 #include <sinfo_pfits.h>
00043 #include <sinfo_tpl_dfs.h>
00044 #include <sinfo_utl_cube_test.h>
00045 
00046 /*-----------------------------------------------------------------------------
00047                             Functions prototypes
00048  ----------------------------------------------------------------------------*/
00049 
00050 static int sinfo_utl_cube_test_create(cpl_plugin *) ;
00051 static int sinfo_utl_cube_test_exec(cpl_plugin *) ;
00052 static int sinfo_utl_cube_test_destroy(cpl_plugin *) ;
00053 
00054 /*-----------------------------------------------------------------------------
00055                             Static variables
00056  ----------------------------------------------------------------------------*/
00057 
00058 static char sinfo_utl_cube_test_description[] =
00059 "This recipe perform cubes combination.\n"
00060 "The input files are several cubeses\n"
00061 "their associated tags should be CUBE.\n"
00062 "The output is a cube PRO_CUBE resulting from the input cubes\n"
00063 "accurding to the value of op where op indicates the operation to be \n"
00064 "performed specified by the parameter sinfoni.sinfo_utl_cube_test.op\n"
00065 "Information on relevant parameters can be found with\n"
00066 "esorex --params sinfo_utl_cube_test\n"
00067 "esorex --help sinfo_utl_cube_test\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_cube_test",
00098                     "Combines a cube list in an output cube",
00099                     sinfo_utl_cube_test_description,
00100                     "Andrea Modigliani",
00101                     "Andrea.Modigliani@eso.org",
00102                     sinfo_get_license(),
00103                     sinfo_utl_cube_test_create,
00104                     sinfo_utl_cube_test_exec,
00105                     sinfo_utl_cube_test_destroy) ;
00106 
00107     cpl_pluginlist_append(list, plugin) ;
00108     
00109     return 0;
00110 }
00111 
00112 /*---------------------------------------------------------------------------*/
00121 /*---------------------------------------------------------------------------*/
00122 static int sinfo_utl_cube_test_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     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_i", 
00140                                 CPL_TYPE_STRING, 
00141                                 "Output filename", 
00142                                 "sinfoni.sinfo_utl_cube_test",
00143                                 "input.list");
00144     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_i") ;
00145     cpl_parameterlist_append(recipe->parameters, p) ;
00146 
00147 
00148     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.method", 
00149                                 CPL_TYPE_STRING, 
00150                                 "Output filename", 
00151                                 "sinfoni.sinfo_utl_cube_test",
00152                                 "sinfo_clean_mean");
00153     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method") ;
00154     cpl_parameterlist_append(recipe->parameters, p) ;
00155 
00156     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.op", 
00157                                 CPL_TYPE_STRING, 
00158                                 "A possible operation", 
00159                                 "sinfoni.sinfo_utl_cube_test",
00160                                 "+");
00161     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00162     cpl_parameterlist_append(recipe->parameters, p) ;
00163 
00164 
00165     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_o", 
00166                                 CPL_TYPE_STRING, 
00167                                 "Output filename", 
00168                                 "sinfoni.sinfo_utl_cube_test",
00169                                 "out_cube.fits");
00170     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_o") ;
00171     cpl_parameterlist_append(recipe->parameters, p) ;
00172 
00173     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_m", 
00174                                 CPL_TYPE_STRING, 
00175                                 "Output filename", 
00176                                 "sinfoni.sinfo_utl_cube_test",
00177                                 "out_maskcube.fits");
00178     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_m") ;
00179     cpl_parameterlist_append(recipe->parameters, p) ;
00180 
00181     /* --doubleopt */
00182     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.xsize", 
00183                                 CPL_TYPE_INT, 
00184                                 "Output cube X size", 
00185                                 "sinfoni.sinfo_utl_cube_test", 
00186                                 80) ;
00187     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xsize") ;
00188     cpl_parameterlist_append(recipe->parameters, p) ;
00189 
00190 
00191     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.ysize", 
00192                                 CPL_TYPE_INT, 
00193                                 "Output cube Y size", 
00194                                 "sinfoni.sinfo_utl_cube_test", 
00195                                 80) ;
00196     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ysize") ;
00197     cpl_parameterlist_append(recipe->parameters, p) ;
00198 
00199 
00200     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.sigma", 
00201                                 CPL_TYPE_DOUBLE, 
00202                                 "Output cube Y size", 
00203                                 "sinfoni.sinfo_utl_cube_test", 
00204                                 5.) ;
00205     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sigma") ;
00206     cpl_parameterlist_append(recipe->parameters, p) ;
00207  
00208 
00209   p = cpl_parameter_new_value("sinfoni.objnod.kappa",
00210                   CPL_TYPE_DOUBLE,
00211                               "kappa value for kappa-sigma clipping "
00212                               "of coadded cube",
00213                               "sinfoni.objnod",
00214                               2.0);
00215 
00216   cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,"sinfo_objnod-kappa");
00217   cpl_parameterlist_append(recipe->parameters, p);
00218 
00219 
00220     /* Return */
00221     return 0;
00222 }
00223 
00224 /*---------------------------------------------------------------------------*/
00230 /*---------------------------------------------------------------------------*/
00231 static int sinfo_utl_cube_test_exec(cpl_plugin * plugin)
00232 {
00233     cpl_recipe  *   recipe ;
00234     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00235     int code=0;
00236     /* Get the recipe out of the plugin */
00237     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00238         recipe = (cpl_recipe *)plugin ;
00239     else return -1 ;
00240 
00241     code=sinfo_utl_cube_test(recipe->parameters, recipe->frames) ;
00242     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00243         /* Dump the error history since recipe execution start.                
00244            At this point the recipe cannot recover from the error */           
00245         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00246     } 
00247 
00248     return code;
00249 }
00250 
00251 /*---------------------------------------------------------------------------*/
00257 /*---------------------------------------------------------------------------*/
00258 static int sinfo_utl_cube_test_destroy(cpl_plugin * plugin)
00259 {
00260     cpl_recipe  *   recipe ;
00261     
00262     /* Get the recipe out of the plugin */
00263     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00264         recipe = (cpl_recipe *)plugin ;
00265     else return -1 ;
00266 
00267     cpl_parameterlist_delete(recipe->parameters) ; 
00268     return 0 ;
00269 }
00270 

Generated on 8 Mar 2011 for SINFONI Pipeline Reference Manual by  doxygen 1.6.1