SINFONI Pipeline Reference Manual  2.6.0
sinfo_rec_pupil.c
1 /* $Id: sinfo_rec_pupil.c,v 1.17 2008-02-12 14:56:50 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 14:56:50 $
24  * $Revision: 1.17 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 /****************************************************************
29  * Wave_Cal Frames Data Reduction *
30  ****************************************************************/
31 
32 /*-----------------------------------------------------------------------------
33  Includes
34  -----------------------------------------------------------------------------*/
35 
36 #ifdef HAVE_CONFIG_H
37 #include <config.h> /* allows the program compilation */
38 #endif
39 
40 /* std */
41 #include <strings.h>
42 #include <string.h>
43 #include <stdio.h>
44 
45 
46 /* cpl */
47 #include <cpl.h>
48 
49 /* irplib */
50 #include <irplib_utils.h>
51 
52 
53 /* sinfoni */
54 #include <sinfo_pro_types.h>
55 #include <sinfo_product_config.h>
56 #include <sinfo_prepare_stacked_frames_config.h>
57 #include <sinfo_objnod_config.h>
58 #include <sinfo_raw_types.h>
59 #include <sinfo_tpl_utils.h>
60 #include <sinfo_tpl_dfs.h>
61 #include <sinfo_hidden.h>
62 #include <sinfo_globals.h>
63 #include <sinfo_functions.h>
64 #include <sinfo_msg.h>
65 #include <sinfo_new_prepare_stacked_frames.h>
66 #include <sinfo_new_objnod.h>
67 #include <sinfo_error.h>
68 #include <sinfo_utils_wrappers.h>
69 /*-----------------------------------------------------------------------------
70  Functions prototypes
71  -----------------------------------------------------------------------------*/
72 static int sinfo_rec_pupil_create(cpl_plugin *);
73 static int sinfo_rec_pupil_exec(cpl_plugin *);
74 static int sinfo_rec_pupil_destroy(cpl_plugin *);
75 static int sinfo_rec_pupil(cpl_parameterlist *, cpl_frameset *);
76 
77 /*-----------------------------------------------------------------------------
78  Static variables
79  -----------------------------------------------------------------------------*/
80 static char sinfo_rec_pupil_description1[] =
81  "This recipe performs science data reduction.\n"
82  "The input files are science object and sky frames \n"
83  "with tags OBJECT_NODDING and SKY_NODDING\n"
84  "Master calibration frames:\n";
85 
86 
87 static char sinfo_rec_pupil_description2[] =
88  "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
89  "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
90  "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
91  "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
92  "A corresponding (band) distortion table with tag DISTORTION\n"
93  "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
94 
95 
96 static char sinfo_rec_pupil_description3[] =
97  "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
98  "A reference table with the position of the 1st column with tag FIRST_COLUMN\n"
99  "Relevant outputs are:\n"
100  "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
101  "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n"
102  "An average along Z of the reconstructed cube \n"
103  "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
104  "The bad pixel map associated to the cube \n"
105  "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
106  "\n";
107 
108 
109 static char sinfo_rec_pupil_description[1300];
110 
111 /*-----------------------------------------------------------------------------
112  Functions code
113  ----------------------------------------------------------------------------*/
114 /*---------------------------------------------------------------------------*/
118 /*---------------------------------------------------------------------------*/
120 /*---------------------------------------------------------------------------*/
129 /*---------------------------------------------------------------------------*/
130 
131 int
132 cpl_plugin_get_info(cpl_pluginlist *list)
133 {
134 
135  cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
136  cpl_plugin *plugin = &recipe->interface;
137 
138 
139  strcpy(sinfo_rec_pupil_description,sinfo_rec_pupil_description1);
140  strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description2);
141  strcat(sinfo_rec_pupil_description,sinfo_rec_pupil_description3);
142 
143  cpl_plugin_init(plugin,
144  CPL_PLUGIN_API,
145  SINFONI_BINARY_VERSION,
146  CPL_PLUGIN_TYPE_RECIPE,
147  "sinfo_rec_pupil",
148  "Pupil data reduction",
149  sinfo_rec_pupil_description,
150  "Andrea Modigliani",
151  "Andrea.Modigliani@eso.org",
152  sinfo_get_license(),
153  sinfo_rec_pupil_create,
154  sinfo_rec_pupil_exec,
155  sinfo_rec_pupil_destroy);
156 
157  cpl_pluginlist_append(list, plugin);
158 
159  return 0;
160 
161 }
162 
163 /*---------------------------------------------------------------------------*/
171 /*---------------------------------------------------------------------------*/
172 
173 static int sinfo_rec_pupil_create(cpl_plugin *plugin)
174 {
175  cpl_recipe * recipe ;
176 
177  /* Check that the plugin is part of a valid recipe */
178  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
179  recipe = (cpl_recipe *)plugin ;
180  else return -1 ;
181  cpl_error_reset();
182  irplib_reset();
183 
184  /* Create the parameters list in the cpl_recipe object */
185  recipe->parameters = cpl_parameterlist_new() ;
186 
187 
188  /*
189  * Fill the parameter list.
190  */
191 
192  sinfo_product_config_add(recipe->parameters);
193  sinfo_prepare_stacked_frames_config_add(recipe->parameters);
194  sinfo_objnod_config_add(recipe->parameters);
195  return 0;
196 
197 }
198 
199 /*---------------------------------------------------------------------------*/
205 /*---------------------------------------------------------------------------*/
206 
207 
208 static int sinfo_rec_pupil_exec(cpl_plugin *plugin)
209 {
210 
211  cpl_recipe *recipe = (cpl_recipe *) plugin;
212  /* Get the recipe out of the plugin */
213  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
214  recipe = (cpl_recipe *)plugin ;
215  else return -1 ;
216 
217  return sinfo_rec_pupil(recipe->parameters, recipe->frames);
218 
219 }
220 
221 /*---------------------------------------------------------------------------*/
227 /*---------------------------------------------------------------------------*/
228 static int sinfo_rec_pupil_destroy(cpl_plugin *plugin)
229 {
230  cpl_recipe * recipe ;
231  /* Get the recipe out of the plugin */
232  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
233  recipe = (cpl_recipe *)plugin ;
234  else return -1 ;
235 
236  cpl_parameterlist_delete(recipe->parameters);
237 
238  return 0;
239 
240 }
241 
242 /*---------------------------------------------------------------------------*/
249 /*---------------------------------------------------------------------------*/
250 /*
251  * The actual recipe actually start here.
252  */
253 
254 static int sinfo_rec_pupil(cpl_parameterlist *config, cpl_frameset *set)
255 {
256 
257  fake* fk=NULL;
258  fk=sinfo_fake_new();
259 
260  sinfo_msg("Welcome to SINFONI Pipeline release %d.%d.%d",
261  SINFONI_MAJOR_VERSION,SINFONI_MINOR_VERSION,SINFONI_MICRO_VERSION);
262 
263  ck0(sinfo_dfs_set_groups(set),"Cannot indentify RAW and CALIB frames") ;
264 
265  /* hidden parameters */
266  sinfo_msg("---------------------------------------------");
267  sinfo_msg("%s FRAME DETERMINATION", PRO_PUPIL_LAMP_STACKED);
268  sinfo_msg("---------------------------------------------");
269 
270  ck0(sinfo_new_prepare_stacked_frames(cpl_func,config, set, NULL,
271  PRO_PUPIL_LAMP_STACKED,0,fk ),
272  "Failed %s FRAME DETERMINATION", PRO_PUPIL_LAMP_STACKED);
273  sinfo_msg("%s FRAME DETERMINATION SUCCESS", PRO_PUPIL_LAMP_STACKED);
274 
275  sinfo_msg("---------------------------------------------");
276  sinfo_msg("PUPIL DATA REDUCTION");
277  sinfo_msg("---------------------------------------------");
278 
279  ck0(sinfo_new_objnod(cpl_func,config, set,PRO_COADD_PUPIL),
280  "Failed PUPIL DATA REDUCTION") ;
281  sinfo_msg("PUPIL DATA REDUCTION SUCCESS");
282 
283  cleanup:
284  sinfo_fake_delete(&fk);
285 
286  if (cpl_error_get_code() != CPL_ERROR_NONE) {
287  return -1;
288  } else {
289  return 0;
290  }
291 
292 
293 }
void irplib_reset(void)
Reset IRPLIB state.
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.