SINFONI Pipeline Reference Manual  2.6.0
sinfo_step_stdstar.c
1 /* $Id: sinfo_step_stdstar.c,v 1.8 2008-06-11 13:41:24 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-06-11 13:41:24 $
24  * $Revision: 1.8 $
25  * $Name: not supported by cvs2svn $
26  */
27 
28 /****************************************************************
29  * Standard_Star 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 /* sinfoni */
53 #include <sinfo_pro_types.h>
54 #include <sinfo_prepare_stacked_frames_config.h>
55 #include <sinfo_objnod_config.h>
56 #include <sinfo_standard_star_config.h>
57 #include <sinfo_skycor_config.h>
58 #include <sinfo_new_prepare_stacked_frames.h>
59 #include <sinfo_new_cubes_coadd.h>
60 #include <sinfo_new_stdstar.h>
61 #include <sinfo_functions.h>
62 #include <sinfo_tpl_utils.h>
63 #include <sinfo_tpl_dfs.h>
64 #include <sinfo_hidden.h>
65 #include <sinfo_globals.h>
66 #include <sinfo_msg.h>
67 #include <sinfo_rec_utils.h>
68 #include <sinfo_error.h>
69 #include <sinfo_utils_wrappers.h>
70 
71 
72 
73 /*-----------------------------------------------------------------------------
74  Functions prototypes
75  -----------------------------------------------------------------------------*/
76 static int sinfo_step_stdstar_create(cpl_plugin *) ;
77 static int sinfo_step_stdstar_exec(cpl_plugin *) ;
78 static int sinfo_step_stdstar_destroy(cpl_plugin *) ;
79 static int sinfo_step_stdstar(cpl_parameterlist *, cpl_frameset *);
80 
81 /*-----------------------------------------------------------------------------
82  Static variables
83  -----------------------------------------------------------------------------*/
84 
85 static char sinfo_step_stdstar_description1[] =
86  "This recipe performs science data reduction.\n"
87  "The input files are science object and sky frames with tags\n"
88  "STD_NODDING and SKY_STD_NODDING\n";
89 
90 
91 static char sinfo_step_stdstar_description2[] =
92  "Master calibration frames:\n"
93  "A corresponding (band,preoptics) wavelength map image with tag WAVE_MAP\n"
94  "A corresponding (band,preoptics) master flat field with tag MASTER_FLAT_LAMP\n"
95  "A corresponding (band,preoptics) master bad pixel map with tag MASTER_BP_MAP\n"
96  "A corresponding (band,preoptics) slitlets position frame with tag SLIT_POS\n"
97  "A corresponding (band) distortion table with tag DISTORTION\n"
98  "A corresponding (band) slitlet distance table with tag SLITLETS_DISTANCE\n";
99 
100 
101 static char sinfo_step_stdstar_description3[] =
102  "The output is an image resulting from the IMA1 op IMA2 where op indicates\n"
103  "A reference table with the position of the first column\n"
104  " with tag FIRST_COLUMN\n"
105  "Relevant outputs are:\n"
106  "combined cubes (PRO.CATG=x_OBS x=STD,OBJ,PSF)\n"
107  "reconstructed cube (PRO.CATG=COADD_x_OBS x=STD,OBJ,PSF)\n";
108 
109 
110 static char sinfo_step_stdstar_description4[] =
111  "An average along Z of the reconstructed cube \n"
112  "(PRO.CATG=MED_x_OBS x=STD,OBJ,PSF)\n"
113  "The bad pixel map associated to the cube \n"
114  "(PRO.CATG=BP_MAP_COADD_x_OBS x=STD,OBJ,PSF)\n"
115  "The std star spectrum image (PRO.CATG=STD_SPECTRUM)\n"
116  "The std start spectrum and efficiency spectrum table (PRO.CATG=STD_SPECTRA)\n"
117  "\n";
118 
119 
120 static char sinfo_step_stdstar_description[1300];
121 
122 /*-----------------------------------------------------------------------------
123  Functions code
124  ----------------------------------------------------------------------------*/
125 /*---------------------------------------------------------------------------*/
129 /*---------------------------------------------------------------------------*/
130 
131 /*--------------------------------------------------------------------------*/
140 /*--------------------------------------------------------------------------*/
141 
142 
143 int
144 cpl_plugin_get_info(cpl_pluginlist *list)
145 {
146 
147  cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe);
148  cpl_plugin *plugin = &recipe->interface;
149 
150  strcpy(sinfo_step_stdstar_description,sinfo_step_stdstar_description1);
151  strcat(sinfo_step_stdstar_description,sinfo_step_stdstar_description2);
152  strcat(sinfo_step_stdstar_description,sinfo_step_stdstar_description3);
153  strcat(sinfo_step_stdstar_description,sinfo_step_stdstar_description4);
154 
155 
156  cpl_plugin_init(plugin,
157  CPL_PLUGIN_API,
158  SINFONI_BINARY_VERSION,
159  CPL_PLUGIN_TYPE_RECIPE,
160  "sinfo_step_stdstar",
161  "Standard star data reduction",
162  sinfo_step_stdstar_description,
163  "Andrea Modigliani",
164  "Andrea.Modigliani@eso.org",
165  sinfo_get_license(),
166  sinfo_step_stdstar_create,
167  sinfo_step_stdstar_exec,
168  sinfo_step_stdstar_destroy);
169 
170  cpl_pluginlist_append(list, plugin);
171 
172  return 0;
173 
174 }
175 
176 
177 
178 /*---------------------------------------------------------------------------*/
186 /*---------------------------------------------------------------------------*/
187 
188 
189 static int sinfo_step_stdstar_create(cpl_plugin *plugin)
190 {
191  cpl_recipe * recipe ;
192 
193  /* Check that the plugin is part of a valid recipe */
194  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
195  recipe = (cpl_recipe *)plugin ;
196  else return -1 ;
197  cpl_error_reset();
198  irplib_reset();
199 
200  /* Create the parameters list in the cpl_recipe object */
201  recipe->parameters = cpl_parameterlist_new() ;
202 
203 
204  /*
205  * Fill the parameter list.
206  */
207  sinfo_prepare_stacked_frames_config_add(recipe->parameters);
208  sinfo_objnod_config_add(recipe->parameters);
209  sinfo_skycor_config_add(recipe->parameters);
210  sinfo_standard_star_config_add(recipe->parameters);
211 
212  return 0;
213 
214 }
215 
216 /*---------------------------------------------------------------------------*/
222 /*---------------------------------------------------------------------------*/
223 static int sinfo_step_stdstar_exec(cpl_plugin *plugin)
224 {
225  cpl_recipe * recipe ;
226 
227  /* Get the recipe out of the plugin */
228  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
229  recipe = (cpl_recipe *)plugin ;
230  else return -1 ;
231 
232  return sinfo_step_stdstar(recipe->parameters, recipe->frames);
233 
234 }
235 
236 /*---------------------------------------------------------------------------*/
242 /*---------------------------------------------------------------------------*/
243 static int sinfo_step_stdstar_destroy(cpl_plugin *plugin)
244 {
245  cpl_recipe * recipe ;
246 
247  /* Get the recipe out of the plugin */
248  if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
249  recipe = (cpl_recipe *)plugin ;
250  else return -1 ;
251 
252  cpl_parameterlist_delete(recipe->parameters);
253  return 0;
254 
255 }
256 
257 
258 /*---------------------------------------------------------------------------*/
265 /*---------------------------------------------------------------------------*/
266 
267 
268 /*
269  * The actual recipe actually start here.
270  */
271 
272 static int
273 sinfo_step_stdstar(cpl_parameterlist *config, cpl_frameset *set)
274 {
275 
276 
277  if(sinfo_dfs_set_groups(set)) {
278  sinfo_msg_error("Cannot indentify RAW and CALIB frames") ;
279  return -1;
280  }
281 
282  /* ===============================================================
283  STDSTAR
284  =============================================================== */
285  sinfo_msg("------------------------------") ;
286  sinfo_msg("STD STAR DATA REDUCTION");
287  sinfo_msg("------------------------------") ;
288 
289  ck0(sinfo_new_stdstar(cpl_func,config, set, set ),"REDUCING STD STAR DATA") ;
290  sinfo_msg("STD STAR DATA REDUCTION SUCCESS") ;
291 
292  return 0 ;
293  cleanup:
294  return -1;
295 
296 }
297 
void irplib_reset(void)
Reset IRPLIB state.
#define sinfo_msg_error(...)
Print an error message.
Definition: sinfo_msg.h:69
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.