si_utl_cube2spectrum.c

00001 /* $Id: si_utl_cube2spectrum.c,v 1.4 2005/10/14 14:40:40 amodigli Exp $
00002  *
00003  * This file is part of the IIINSTRUMENT 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: 2005/10/14 14:40:40 $
00024  * $Revision: 1.4 $
00025  * $Name:  $
00026  */
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031 
00032 /*-----------------------------------------------------------------------------
00033                                 Includes
00034  -----------------------------------------------------------------------------*/
00035 
00036 
00037 #include <cpl.h>
00038 
00039 #include "sinfoni_tpl_utils.h"
00040 #include "sinfoni_pfits.h"
00041 #include "sinfoni_tpl_dfs.h"
00042 #include <utl_cube2spectrum.h>
00043 #include <sinfoni_memory.h>
00044 /*-----------------------------------------------------------------------------
00045                             Functions prototypes
00046  -----------------------------------------------------------------------------*/
00047 
00048 static int si_utl_cube2spectrum_create(cpl_plugin *) ;
00049 static int si_utl_cube2spectrum_exec(cpl_plugin *) ;
00050 static int si_utl_cube2spectrum_destroy(cpl_plugin *) ;
00051 
00052 /*-----------------------------------------------------------------------------
00053                             Static variables
00054  -----------------------------------------------------------------------------*/
00055 
00056 static char si_utl_cube2spectrum_description[] =
00057 "This recipe performs cube to 1D spectrum image conversion.\n"
00058 "The input files is a cube\n"
00059 "Its associated tag should be CUBE.\n"
00060 "The output is an image resulting from the cube manipulated according to the value of op\n"
00061 "Over an aperture as specified by the parameter sinfoni.si_utl_cube2spectrum.aperture"
00062 "having alias 'op', 'ap'"
00063 "Information on relevant parameters can be found with\n"
00064 "esorex --params si_utl_cube2spectrum\n"
00065 "esorex --help si_utl_cube2spectrum\n"
00066 "\n";
00067 
00068 /*-----------------------------------------------------------------------------
00069                                 Functions code
00070  -----------------------------------------------------------------------------*/
00071 
00072 /*----------------------------------------------------------------------------*/
00080 /*----------------------------------------------------------------------------*/
00081 int cpl_plugin_get_info(cpl_pluginlist * list)
00082 {
00083     cpl_recipe  *   recipe = cpl_calloc(1, sizeof *recipe ) ;
00084     cpl_plugin  *   plugin = &recipe->interface ;
00085 
00086     cpl_plugin_init(plugin,
00087                     CPL_PLUGIN_API,
00088                     SINFONI_BINARY_VERSION,
00089                     CPL_PLUGIN_TYPE_RECIPE,
00090                     "si_utl_cube2spectrum",
00091                     "Collapse a cube to an image over an aperture",
00092                     si_utl_cube2spectrum_description,
00093                     "Andrea Modigliani",
00094                     "Andrea.Modigliani@eso.org",
00095                     sinfoni_get_license(),
00096                     si_utl_cube2spectrum_create,
00097                     si_utl_cube2spectrum_exec,
00098                     si_utl_cube2spectrum_destroy) ;
00099 
00100     cpl_pluginlist_append(list, plugin) ;
00101     
00102     return 0;
00103 }
00104 
00105 /*----------------------------------------------------------------------------*/
00114 /*----------------------------------------------------------------------------*/
00115 static int si_utl_cube2spectrum_create(cpl_plugin * plugin)
00116 {
00117     cpl_recipe      * recipe ;
00118     cpl_parameter   * p ;
00119 
00120     /* Get the recipe out of the plugin */
00121     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00122         recipe = (cpl_recipe *)plugin ;
00123     else return -1 ;
00124 
00125     /* Create the parameters list in the cpl_recipe object */
00126     recipe->parameters = cpl_parameterlist_new() ; 
00127 
00128     /* Fill the parameters list */
00129     /* --stropt */
00130     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.op", 
00131             CPL_TYPE_STRING, "A possible operation:"
00132             " average, clean_mean, median, sum", 
00133             "sinfoni.si_utl_cube2spectrum","average");
00134     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
00135     cpl_parameterlist_append(recipe->parameters, p) ;
00136 
00137 
00138      /* --stropt */
00139     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.ap", 
00140             CPL_TYPE_STRING, "A possible aperture: rectangle, circle", 
00141             "sinfoni.si_utl_cube2spectrum","rectangle");
00142     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ap") ;
00143     cpl_parameterlist_append(recipe->parameters, p) ;
00144 
00145 
00146     /* --doubleopt */
00147     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.llx", 
00148             CPL_TYPE_INT, "Lower left X rectangle coordinate", "sinfoni.si_utl_cube2spectrum", 2) ;
00149     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "llx") ;
00150     cpl_parameterlist_append(recipe->parameters, p) ;
00151 
00152 
00153     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.lly", 
00154             CPL_TYPE_INT, "Lower left Y rectangle coordinate", "sinfoni.si_utl_cube2spectrum", 2) ;
00155     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lly") ;
00156     cpl_parameterlist_append(recipe->parameters, p) ;
00157 
00158 
00159     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.urx", 
00160             CPL_TYPE_INT, "Upper right X rectangle coordinate", "sinfoni.si_utl_cube2spectrum", 28) ;
00161     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "urx") ;
00162     cpl_parameterlist_append(recipe->parameters, p) ;
00163 
00164 
00165     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.ury", 
00166             CPL_TYPE_INT, "Upper right Y rectangle coordinate", "sinfoni.si_utl_cube2spectrum", 28) ;
00167     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ury") ;
00168     cpl_parameterlist_append(recipe->parameters, p) ;
00169 
00170 
00171 
00172     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.lo_rej", 
00173             CPL_TYPE_INT, "Clean mean low rejection", "sinfoni.si_utl_cube2spectrum", 10) ;
00174     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "lo_rej") ;
00175     cpl_parameterlist_append(recipe->parameters, p) ;
00176 
00177 
00178     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.hi_rej", 
00179             CPL_TYPE_INT, "Clean mean low rejection", "sinfoni.si_utl_cube2spectrum", 10) ;
00180     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "hi_rej") ;
00181     cpl_parameterlist_append(recipe->parameters, p) ;
00182 
00183 
00184 
00185     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.centerx", 
00186             CPL_TYPE_INT, "Circle center X coordinate", "sinfoni.si_utl_cube2spectrum", 16) ;
00187     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "centerx") ;
00188     cpl_parameterlist_append(recipe->parameters, p) ;
00189 
00190 
00191     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.centery", 
00192             CPL_TYPE_INT, "Circle center Y coordinate", "sinfoni.si_utl_cube2spectrum", 16) ;
00193     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "centery") ;
00194     cpl_parameterlist_append(recipe->parameters, p) ;
00195 
00196 
00197     p = cpl_parameter_new_value("sinfoni.si_utl_cube2spectrum.radius", 
00198             CPL_TYPE_INT, "Circle radii", "sinfoni.si_utl_cube2spectrum", 5) ;
00199     cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "radius") ;
00200     cpl_parameterlist_append(recipe->parameters, p) ;
00201 
00202  
00203     /* Return */
00204     return 0;
00205 }
00206 
00207 /*----------------------------------------------------------------------------*/
00213 /*----------------------------------------------------------------------------*/
00214 static int si_utl_cube2spectrum_exec(cpl_plugin * plugin)
00215 {
00216     cpl_recipe  *   recipe ;
00217     int result=0;
00218     /* Get the recipe out of the plugin */
00219     if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) 
00220         recipe = (cpl_recipe *)plugin ;
00221     else return -1 ;
00222     
00223     result = si_utl_cube2spectrum(recipe->parameters, recipe->frames);
00224     sinfoni_memory_status();
00225     return result;
00226 }
00227 
00228 /*----------------------------------------------------------------------------*/
00234 /*----------------------------------------------------------------------------*/
00235 static int si_utl_cube2spectrum_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 Wed Oct 26 13:08:54 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001