SINFONI Pipeline Reference Manual  2.5.2
sinfo_utl_cube_test.c
1 /* $Id: sinfo_utl_cube_test.c,v 1.8 2008-02-12 09:11:10 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: 2008-02-12 09:11:10 $
24  * $Revision: 1.8 $
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 
36 /* cpl */
37 #include <cpl.h>
38 /* irplib */
39 #include <irplib_utils.h>
40 
41 #include <sinfo_tpl_utils.h>
42 #include <sinfo_pfits.h>
43 #include <sinfo_tpl_dfs.h>
44 #include <sinfo_utl_cube_test.h>
45 
46 /*-----------------------------------------------------------------------------
47  Functions prototypes
48  ----------------------------------------------------------------------------*/
49 
50 static int sinfo_utl_cube_test_create(cpl_plugin *) ;
51 static int sinfo_utl_cube_test_exec(cpl_plugin *) ;
52 static int sinfo_utl_cube_test_destroy(cpl_plugin *) ;
53 
54 /*-----------------------------------------------------------------------------
55  Static variables
56  ----------------------------------------------------------------------------*/
57 
58 static char sinfo_utl_cube_test_description[] =
59  "This recipe perform cubes combination.\n"
60  "The input files are several cubeses\n"
61  "their associated tags should be CUBE.\n"
62  "The output is a cube PRO_CUBE resulting from the input cubes\n"
63  "accurding to the value of op where op indicates the operation to be \n"
64  "performed specified by the parameter sinfoni.sinfo_utl_cube_test.op\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_cube_test",
95  "Combines a cube list in an output cube",
96  sinfo_utl_cube_test_description,
97  "Andrea Modigliani",
98  "Andrea.Modigliani@eso.org",
99  sinfo_get_license(),
100  sinfo_utl_cube_test_create,
101  sinfo_utl_cube_test_exec,
102  sinfo_utl_cube_test_destroy) ;
103 
104  cpl_pluginlist_append(list, plugin) ;
105 
106  return 0;
107 }
108 
109 /*---------------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------------*/
119 static int sinfo_utl_cube_test_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  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_i",
137  CPL_TYPE_STRING,
138  "Output filename",
139  "sinfoni.sinfo_utl_cube_test",
140  "input.list");
141  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_i") ;
142  cpl_parameterlist_append(recipe->parameters, p) ;
143 
144 
145  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.method",
146  CPL_TYPE_STRING,
147  "Output filename",
148  "sinfoni.sinfo_utl_cube_test",
149  "sinfo_clean_mean");
150  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "method") ;
151  cpl_parameterlist_append(recipe->parameters, p) ;
152 
153  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.op",
154  CPL_TYPE_STRING,
155  "A possible operation",
156  "sinfoni.sinfo_utl_cube_test",
157  "+");
158  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "op") ;
159  cpl_parameterlist_append(recipe->parameters, p) ;
160 
161 
162  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_o",
163  CPL_TYPE_STRING,
164  "Output filename",
165  "sinfoni.sinfo_utl_cube_test",
166  "out_cube.fits");
167  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_o") ;
168  cpl_parameterlist_append(recipe->parameters, p) ;
169 
170  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.name_m",
171  CPL_TYPE_STRING,
172  "Output filename",
173  "sinfoni.sinfo_utl_cube_test",
174  "out_maskcube.fits");
175  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "name_m") ;
176  cpl_parameterlist_append(recipe->parameters, p) ;
177 
178  /* --doubleopt */
179  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.xsize",
180  CPL_TYPE_INT,
181  "Output cube X size",
182  "sinfoni.sinfo_utl_cube_test",
183  80) ;
184  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "xsize") ;
185  cpl_parameterlist_append(recipe->parameters, p) ;
186 
187 
188  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.ysize",
189  CPL_TYPE_INT,
190  "Output cube Y size",
191  "sinfoni.sinfo_utl_cube_test",
192  80) ;
193  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "ysize") ;
194  cpl_parameterlist_append(recipe->parameters, p) ;
195 
196 
197  p = cpl_parameter_new_value("sinfoni.sinfo_utl_cube_test.sigma",
198  CPL_TYPE_DOUBLE,
199  "Output cube Y size",
200  "sinfoni.sinfo_utl_cube_test",
201  5.) ;
202  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "sigma") ;
203  cpl_parameterlist_append(recipe->parameters, p) ;
204 
205 
206  p = cpl_parameter_new_value("sinfoni.objnod.kappa",
207  CPL_TYPE_DOUBLE,
208  "kappa value for kappa-sigma clipping "
209  "of coadded cube",
210  "sinfoni.objnod",
211  2.0);
212 
213  cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI,"sinfo_objnod-kappa");
214  cpl_parameterlist_append(recipe->parameters, p);
215 
216 
217  /* Return */
218  return 0;
219 }
220 
221 /*---------------------------------------------------------------------------*/
227 /*---------------------------------------------------------------------------*/
228 static int sinfo_utl_cube_test_exec(cpl_plugin * plugin)
229 {
230  cpl_recipe * recipe ;
231  cpl_errorstate initial_errorstate = cpl_errorstate_get();
232  int code=0;
233  /* Get the recipe out of the plugin */
234  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
235  recipe = (cpl_recipe *)plugin ;
236  else return -1 ;
237 
238  code=sinfo_utl_cube_test(recipe->parameters, recipe->frames) ;
239  if (!cpl_errorstate_is_equal(initial_errorstate)) {
240  /* Dump the error history since recipe execution start.
241  At this point the recipe cannot recover from the error */
242  cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
243  }
244 
245  return code;
246 }
247 
248 /*---------------------------------------------------------------------------*/
254 /*---------------------------------------------------------------------------*/
255 static int sinfo_utl_cube_test_destroy(cpl_plugin * plugin)
256 {
257  cpl_recipe * recipe ;
258 
259  /* Get the recipe out of the plugin */
260  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
261  recipe = (cpl_recipe *)plugin ;
262  else return -1 ;
263 
264  cpl_parameterlist_delete(recipe->parameters) ;
265  return 0 ;
266 }
267