sinfo_utl_cube2spectrum.c

00001 /* $Id: sinfo_utl_cube2spectrum.c,v 1.12 2007/10/26 08:33:11 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 08:33:11 $
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 /* 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_cube2spectrum.h>
00045 #include <sinfo_msg.h>
00046 /*-----------------------------------------------------------------------------
00047                             Functions prototypes
00048  -----------------------------------------------------------------------------*/
00049 
00050 static int sinfo_utl_cube2spectrum_create(cpl_plugin *) ;
00051 static int sinfo_utl_cube2spectrum_exec(cpl_plugin *) ;
00052 static int sinfo_utl_cube2spectrum_destroy(cpl_plugin *) ;
00053 
00054 /*-----------------------------------------------------------------------------
00055                             Static variables
00056  -----------------------------------------------------------------------------*/
00057 
00058 static char sinfo_utl_cube2spectrum_description[] =
00059 "This recipe performs cube to 1D spectrum image conversion.\n"
00060 "The input files is a cube\n"
00061 "Its associated tag should be CUBE.\n"
00062 "The output is an image resulting from the cube manipulated \n"
00063 "according to the value of op\n"
00064 "Over an aperture as specified by the parameter \n"
00065 "sinfoni.sinfo_utl_cube2spectrum.aperture having alias 'op', 'ap'"
00066 "Information on relevant parameters can be found with\n"
00067 "esorex --params sinfo_utl_cube2spectrum\n"
00068 "esorex --help sinfo_utl_cube2spectrum\n"
00069 "\n";
00070 
00071 /*-----------------------------------------------------------------------------
00072                                 Functions code
00073  ----------------------------------------------------------------------------*/
00074 /*---------------------------------------------------------------------------*/
00078 /*---------------------------------------------------------------------------*/
00079 
00081 /*---------------------------------------------------------------------------*/
00089 /*---------------------------------------------------------------------------*/
00090 int cpl_plugin_get_info(cpl_pluginlist * list)
00091 {
00092     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00093     cpl_plugin  *   plugin = &recipe->interface ;
00094 
00095     cpl_plugin_init(plugin,
00096                     CPL_PLUGIN_API,
00097                     SINFONI_BINARY_VERSION,
00098                     CPL_PLUGIN_TYPE_RECIPE,
00099                     "sinfo_utl_cube2spectrum",
00100                     "Collapse a cube to an image over an aperture",
00101                     sinfo_utl_cube2spectrum_description,
00102                     "Andrea Modigliani",
00103                     "Andrea.Modigliani@eso.org",
00104                     sinfo_get_license(),
00105                     sinfo_utl_cube2spectrum_create,
00106                     sinfo_utl_cube2spectrum_exec,
00107                     sinfo_utl_cube2spectrum_destroy) ;
00108 
00109     cpl_pluginlist_append(list, plugin) ;
00110     
00111     return 0;
00112 }
00113 
00114 /*---------------------------------------------------------------------------*/
00123 /*---------------------------------------------------------------------------*/
00124 static int sinfo_utl_cube2spectrum_create(cpl_plugin * plugin)
00125 {
00126     cpl_recipe      * recipe ;
00127     cpl_parameter   * p ;
00128 
00129     /* Get the recipe out of the plugin */
00130     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00131         recipe = (cpl_recipe *)plugin ;
00132     else return -1 ;
00133     cpl_error_reset();
00134     irplib_reset();
00135 
00136     /* Create the parameters list in the cpl_recipe object */
00137     recipe->parameters = cpl_parameterlist_new() ; 
00138 
00139     /* Fill the parameters list */
00140     /* --stropt */
00141     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.op", 
00142             CPL_TYPE_STRING, "A possible operation:"
00143             " average, clean_mean, median, sum", 
00144             "sinfoni.sinfo_utl_cube2spectrum","average");
00145     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00146     cpl_parameterlist_append(recipe->parameters, p) ;
00147 
00148 
00149      /* --stropt */
00150     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.ap", 
00151             CPL_TYPE_STRING, "A possible aperture: rectangle, circle", 
00152             "sinfoni.sinfo_utl_cube2spectrum","rectangle");
00153     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ap") ;
00154     cpl_parameterlist_append(recipe->parameters, p) ;
00155 
00156 
00157     /* --doubleopt */
00158     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.llx", 
00159                                 CPL_TYPE_INT, 
00160                                 "Lower left X rectangle coordinate", 
00161                                 "sinfoni.sinfo_utl_cube2spectrum", 2) ;
00162     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "llx") ;
00163     cpl_parameterlist_append(recipe->parameters, p) ;
00164 
00165 
00166     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.lly", 
00167                                 CPL_TYPE_INT, 
00168                                 "Lower left Y rectangle coordinate", 
00169                                 "sinfoni.sinfo_utl_cube2spectrum", 2) ;
00170     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lly") ;
00171     cpl_parameterlist_append(recipe->parameters, p) ;
00172 
00173 
00174     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.urx", 
00175             CPL_TYPE_INT, "Upper right X rectangle coordinate", 
00176                                 "sinfoni.sinfo_utl_cube2spectrum", 28) ;
00177     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "urx") ;
00178     cpl_parameterlist_append(recipe->parameters, p) ;
00179 
00180 
00181     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.ury", 
00182                                 CPL_TYPE_INT, 
00183                                 "Upper right Y rectangle coordinate", 
00184                                 "sinfoni.sinfo_utl_cube2spectrum", 28) ;
00185     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ury") ;
00186     cpl_parameterlist_append(recipe->parameters, p) ;
00187 
00188 
00189 
00190     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.lo_rej", 
00191                                 CPL_TYPE_INT, 
00192                                 "Clean mean low rejection", 
00193                                 "sinfoni.sinfo_utl_cube2spectrum", 10) ;
00194     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lo_rej") ;
00195     cpl_parameterlist_append(recipe->parameters, p) ;
00196 
00197 
00198     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.hi_rej", 
00199                                 CPL_TYPE_INT, 
00200                                 "Clean mean low rejection", 
00201                                 "sinfoni.sinfo_utl_cube2spectrum", 10) ;
00202     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "hi_rej") ;
00203     cpl_parameterlist_append(recipe->parameters, p) ;
00204 
00205 
00206 
00207     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.centerx", 
00208                                 CPL_TYPE_INT, 
00209                                 "Circle center X coordinate", 
00210                                 "sinfoni.sinfo_utl_cube2spectrum", 16) ;
00211     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "centerx") ;
00212     cpl_parameterlist_append(recipe->parameters, p) ;
00213 
00214 
00215     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.centery", 
00216                                 CPL_TYPE_INT, 
00217                                 "Circle center Y coordinate", 
00218                                 "sinfoni.sinfo_utl_cube2spectrum", 16) ;
00219     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "centery") ;
00220     cpl_parameterlist_append(recipe->parameters, p) ;
00221 
00222 
00223     p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2spectrum.radius", 
00224                                 CPL_TYPE_INT, "Circle radii", 
00225                                 "sinfoni.sinfo_utl_cube2spectrum", 5) ;
00226     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "radius") ;
00227     cpl_parameterlist_append(recipe->parameters, p) ;
00228 
00229  
00230     /* Return */
00231     return 0;
00232 }
00233 
00234 /*---------------------------------------------------------------------------*/
00240 /*---------------------------------------------------------------------------*/
00241 static int sinfo_utl_cube2spectrum_exec(cpl_plugin * plugin)
00242 {
00243     cpl_recipe  *   recipe ;
00244     int result=0;
00245     cpl_errorstate initial_errorstate = cpl_errorstate_get();
00246 
00247     /* Get the recipe out of the plugin */
00248     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00249         recipe = (cpl_recipe *)plugin ;
00250     else return -1 ;
00251 
00252     if(sinfo_dfs_set_groups(recipe->frames)) {
00253        sinfo_msg_error( "Cannot indentify RAW and CALIB frames") ;
00254        return -1;
00255     }
00256       sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
00257         SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
00258 
00259     result = sinfo_utl_cube2spectrum(recipe->parameters, recipe->frames,NULL);
00260     if (!cpl_errorstate_is_equal(initial_errorstate)) {                      
00261         /* Dump the error history since recipe execution start.                
00262            At this point the recipe cannot recover from the error */           
00263         cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);              
00264     } 
00265 
00266     return result;
00267 }
00268 
00269 /*---------------------------------------------------------------------------*/
00275 /*----------------------------------------------------------------------------*/
00276 static int sinfo_utl_cube2spectrum_destroy(cpl_plugin * plugin)
00277 {
00278     cpl_recipe  *   recipe ;
00279 
00280     /* Get the recipe out of the plugin */
00281     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00282         recipe = (cpl_recipe *)plugin ;
00283     else return -1 ;
00284 
00285     cpl_parameterlist_delete(recipe->parameters) ; 
00286     return 0 ;
00287 }
00288 

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