SINFONI Pipeline Reference Manual  2.6.0
recipes/sinfo_utl_cube2ima.c
1 /* $Id: sinfo_utl_cube2ima.c,v 1.10 2007-10-26 09:40:28 amodigli Exp $
2  *
3  * This file is part of the SINFONI Pipeline
4  * Copyright (C) 2002,2003 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 /*
22  * $Author: amodigli $
23  * $Date: 2007-10-26 09:40:28 $
24  * $Revision: 1.10 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  ----------------------------------------------------------------------------*/
35 /* cpl */
36 #include <cpl.h>
37 
38 /* irplib */
39 #include <irplib_utils.h>
40 #include <sinfo_msg.h>
41 #include <sinfo_tpl_utils.h>
42 #include <sinfo_pfits.h>
43 #include <sinfo_tpl_dfs.h>
44 #include <sinfo_utl_cube2ima.h>
45 /*-----------------------------------------------------------------------------
46  Functions prototypes
47  ----------------------------------------------------------------------------*/
48 
49 static int sinfo_utl_cube2ima_create(cpl_plugin *) ;
50 static int sinfo_utl_cube2ima_exec(cpl_plugin *) ;
51 static int sinfo_utl_cube2ima_destroy(cpl_plugin *) ;
52 
53 /*-----------------------------------------------------------------------------
54  Static variables
55  ----------------------------------------------------------------------------*/
56 
57 static char sinfo_utl_cube2ima_description[] =
58  "This recipe performs cube to image comversion.\n"
59  "The input file is a cube which is contained in the sof file\n"
60  "Its tag should be CUBE.\n"
61  "The output is an image resulting from the average of the \n"
62  "cube over a wavelength rage which can be set by parameters \n"
63  "sinfoni.sinfo_utl_cube2ima.ws sinfoni.sinfo_utl_cube2ima.we\n"
64  "having aliases 'ws' 'we'\n"
65  "\n";
66 
67 /*-----------------------------------------------------------------------------
68  Functions code
69  ----------------------------------------------------------------------------*/
70 /*---------------------------------------------------------------------------*/
74 /*---------------------------------------------------------------------------*/
76 /*---------------------------------------------------------------------------*/
84 /*---------------------------------------------------------------------------*/
85 int cpl_plugin_get_info(cpl_pluginlist * list)
86 {
87  cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
88  cpl_plugin * plugin = &recipe->interface ;
89 
90  cpl_plugin_init(plugin,
91  CPL_PLUGIN_API,
92  SINFONI_BINARY_VERSION,
93  CPL_PLUGIN_TYPE_RECIPE,
94  "sinfo_utl_cube2ima",
95  "Cube to image conversion",
96  sinfo_utl_cube2ima_description,
97  "Andrea Modigliani",
98  "Andrea.Modigliani@eso.org",
99  sinfo_get_license(),
100  sinfo_utl_cube2ima_create,
101  sinfo_utl_cube2ima_exec,
102  sinfo_utl_cube2ima_destroy) ;
103 
104  cpl_pluginlist_append(list, plugin) ;
105 
106  return 0;
107 }
108 
109 /*---------------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------------*/
119 static int sinfo_utl_cube2ima_create(cpl_plugin * plugin)
120 {
121  cpl_recipe * recipe ;
122  cpl_parameter * p ;
123 
124  /* Get the recipe out of the plugin */
125  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
126  recipe = (cpl_recipe *)plugin ;
127  else return -1 ;
128  cpl_error_reset();
129  irplib_reset();
130 
131  /* Create the parameters list in the cpl_recipe object */
132  recipe->parameters = cpl_parameterlist_new() ;
133 
134  /* Fill the parameters list */
135  /* --stropt */
136 
137  /* --doubleopt */
138  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2ima.ws",
139  CPL_TYPE_DOUBLE,
140  "starting wavelength",
141  "sinfoni.sinfo_utl_cube2ima",
142  0.9999) ;
143  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ws") ;
144  cpl_parameterlist_append(recipe->parameters, p) ;
145 
146 
147  /* --doubleopt */
148  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube2ima.we",
149  CPL_TYPE_DOUBLE,
150  "starting wavelength",
151  "sinfoni.sinfo_utl_cube2ima",
152  2.999) ;
153  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "we") ;
154  cpl_parameterlist_append(recipe->parameters, p) ;
155 
156  /* Return */
157  return 0;
158 }
159 
160 /*---------------------------------------------------------------------------*/
166 /*---------------------------------------------------------------------------*/
167 static int sinfo_utl_cube2ima_exec(cpl_plugin * plugin)
168 {
169  cpl_recipe * recipe ;
170  int result=0;
171  cpl_errorstate initial_errorstate = cpl_errorstate_get();
172 
173  /* Get the recipe out of the plugin */
174  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
175  recipe = (cpl_recipe *)plugin ;
176  else return -1 ;
177 
178  sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
179  SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
180 
181  result=sinfo_utl_cube2ima(recipe->parameters, recipe->frames) ;
182 
183  if (!cpl_errorstate_is_equal(initial_errorstate)) {
184  /* Dump the error history since recipe execution start.
185  At this point the recipe cannot recover from the error */
186  cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
187  }
188 
189  return result ;
190 }
191 
192 /*---------------------------------------------------------------------------*/
198 /*---------------------------------------------------------------------------*/
199 static int sinfo_utl_cube2ima_destroy(cpl_plugin * plugin)
200 {
201  cpl_recipe * recipe ;
202 
203  /* Get the recipe out of the plugin */
204  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
205  recipe = (cpl_recipe *)plugin ;
206  else return -1 ;
207 
208  cpl_parameterlist_delete(recipe->parameters) ;
209  return 0 ;
210 }
211 
void irplib_reset(void)
Reset IRPLIB state.
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.