sinfo_utl_cube_combine.c

00001 /* $Id: sinfo_utl_cube_combine.c,v 1.12 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.12 $
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 
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_cube_combine.h>
00047 
00048 /*-----------------------------------------------------------------------------
00049                             Functions prototypes
00050  ----------------------------------------------------------------------------*/
00051 
00052 static int sinfo_utl_cube_combine_create(cpl_plugin *) ;
00053 static int sinfo_utl_cube_combine_exec(cpl_plugin *) ;
00054 static int sinfo_utl_cube_combine_destroy(cpl_plugin *) ;
00055 
00056 /*-----------------------------------------------------------------------------
00057                             Static variables
00058  ----------------------------------------------------------------------------*/
00059 
00060 static char sinfo_utl_cube_combine_description[] =
00061 "This recipe perform cubes combination.\n"
00062 "The input files are several cubeses\n"
00063 "their associated tags should be the same that is supported by the \n"
00064 "recipe sinfo_rec_jitter: OBS_OBJ, OBS_STD, OBS_PSF.\n"
00065 "The output is a cube PRO_CUBE resulting from the input cubes accurding \n"
00066 "to the value of op, where op indicates\n"
00067 "the operation to be performed specified by the parameter \n"
00068 "sinfoni.sinfo_utl_cube_combine.op\n"
00069 " having alias 'op'\n"
00070 "Information on relevant parameters can be found with\n"
00071 "esorex --params sinfo_utl_cube_combine\n"
00072 "esorex --help sinfo_utl_cube_combine\n"
00073 "\n";
00074 
00075 /*-----------------------------------------------------------------------------
00076                                 Functions code
00077  ----------------------------------------------------------------------------*/
00078 /*---------------------------------------------------------------------------*/
00082 /*---------------------------------------------------------------------------*/
00083 
00085 /*---------------------------------------------------------------------------*/
00093 /*---------------------------------------------------------------------------*/
00094 int cpl_plugin_get_info(cpl_pluginlist * list)
00095 {
00096     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00097     cpl_plugin  *   plugin = &recipe->interface ;
00098 
00099     cpl_plugin_init(plugin,
00100                     CPL_PLUGIN_API,
00101                     SINFONI_BINARY_VERSION,
00102                     CPL_PLUGIN_TYPE_RECIPE,
00103                     "sinfo_utl_cube_combine",
00104                     "Coadd cubes in an output cube according "
00105                     "to user defined offsets",
00106                     sinfo_utl_cube_combine_description,
00107                     "Andrea Modigliani",
00108                     "Andrea.Modigliani@eso.org",
00109                     sinfo_get_license(),
00110                     sinfo_utl_cube_combine_create,
00111                     sinfo_utl_cube_combine_exec,
00112                     sinfo_utl_cube_combine_destroy) ;
00113 
00114     cpl_pluginlist_append(list, plugin) ;
00115     
00116     return 0;
00117 }
00118 
00119 /*---------------------------------------------------------------------------*/
00128 /*---------------------------------------------------------------------------*/
00129 static int sinfo_utl_cube_combine_create(cpl_plugin * plugin)
00130 {
00131     cpl_recipe      * recipe ;
00132     cpl_parameter   * p ;
00133 
00134     /* Get the recipe out of the plugin */
00135     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00136         recipe = (cpl_recipe *)plugin ;
00137     else return -1 ;
00138     cpl_error_reset();
00139     irplib_reset();
00140 
00141     /* Create the parameters list in the cpl_recipe object */
00142     recipe->parameters = cpl_parameterlist_new() ; 
00143 
00144     /* Fill the parameters list */
00145     /* --stropt */
00146     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.name_i", 
00147             CPL_TYPE_STRING, 
00148          "Input filename. This must be provided and allow the user to set X "
00149          "and Y cumulative offsets in a two column format", 
00150          "sinfoni.sinfo_utl_cube_combine","offset.list");
00151     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_i") ;
00152     cpl_parameterlist_append(recipe->parameters, p) ;
00153 
00154     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.name_o", 
00155             CPL_TYPE_STRING, "Output filename", 
00156              "sinfoni.sinfo_utl_cube_combine","out_coadd_cube.fits");
00157     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_o") ;
00158     cpl_parameterlist_append(recipe->parameters, p) ;
00159 
00160 
00161     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.ks_clip", 
00162             CPL_TYPE_BOOL, "Kappa sigma clipping", 
00163             "sinfoni.sinfo_utl_cube_combine",FALSE);
00164     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ks_clip") ;
00165     cpl_parameterlist_append(recipe->parameters, p) ;
00166 
00167     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.scale_sky", 
00168             CPL_TYPE_BOOL, "Scale spatial mean", 
00169             "sinfoni.sinfo_utl_cube_combine",FALSE);
00170     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "scale_sky") ;
00171     cpl_parameterlist_append(recipe->parameters, p) ;
00172 
00173     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.kappa", 
00174             CPL_TYPE_DOUBLE, "Kappa value for sigma clip", 
00175             "sinfoni.sinfo_utl_cube_combine",2.);
00176     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "kappa") ;
00177     cpl_parameterlist_append(recipe->parameters, p) ;
00178 
00179 
00180     /* --doubleopt */
00181     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.xsize", 
00182             CPL_TYPE_INT, "Output cube X size", 
00183             "sinfoni.sinfo_utl_cube_combine", 80) ;
00184     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xsize") ;
00185     cpl_parameterlist_append(recipe->parameters, p) ;
00186 
00187 
00188     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_combine.ysize", 
00189             CPL_TYPE_INT, "Output cube Y size", 
00190             "sinfoni.sinfo_utl_cube_combine", 80) ;
00191     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ysize") ;
00192     cpl_parameterlist_append(recipe->parameters, p) ;
00193 
00194   
00195     /* Return */
00196     return 0;
00197 }
00198 
00199 /*---------------------------------------------------------------------------*/
00205 /*---------------------------------------------------------------------------*/
00206 static int sinfo_utl_cube_combine_exec(cpl_plugin * plugin)
00207 {
00208     cpl_recipe  *   recipe ;
00209     int result=0;    
00210     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00211 
00212     /* Get the recipe out of the plugin */
00213     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00214         recipe = (cpl_recipe *)plugin ;
00215     else return -1 ;
00216        sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00217         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00218 
00219     result=sinfo_utl_cube_combine(recipe->parameters, recipe->frames) ;
00220     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00221         /* Dump the error history since recipe execution start.                
00222            At this point the recipe cannot recover from the error */           
00223         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00224     } 
00225     return result;
00226 }
00227 
00228 /*---------------------------------------------------------------------------*/
00234 /*---------------------------------------------------------------------------*/
00235 static int sinfo_utl_cube_combine_destroy(cpl_plugin * plugin)
00236 {
00237     cpl_recipe  *   recipe ;
00238     
00239     /* Get the recipe out of the plugin */
00240     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00241         recipe = (cpl_recipe *)plugin ;
00242     else return -1 ;
00243 
00244     cpl_parameterlist_delete(recipe->parameters) ; 
00245     return 0 ;
00246 }
00247 

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