X-shooter Pipeline Reference Manual 3.8.15
xsh_util_bpmap_nl_raw2pre.c
Go to the documentation of this file.
1/* $Id: xsh_util_bpmap_nl_raw2pre.c,v 1.3 2012-04-26 14:07:30 amodigli Exp $
2 *
3 * This file is part of the XSHOOTER 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: 2012-04-26 14:07:30 $
24 * $Revision: 1.3 $
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#include <string.h>
36
37/* cpl */
38#include <cpl.h>
39
40/* irplib */
41#include <xsh_dfs.h>
42//#include <xsh_data_pre.h>
43#include <xsh_parameters.h>
44#include <xsh_utils.h>
45#include <xsh_drl.h>
46#include <xsh_msg.h>
47#include <xsh_pfits.h>
48#include <xsh_error.h>
49
50
51/*-----------------------------------------------------------------------------
52 Defines
53 ----------------------------------------------------------------------------*/
54
55#define RECIPE_ID "xsh_util_bpmap_nl_raw2pre"
56#define RECIPE_AUTHOR "A.Modigliani"
57#define RECIPE_CONTACT "Andrea.Modigliani@eso.org"
58#define PRO_IMA "PRO_IMA"
59#define KEY_VALUE_HPRO_DID "PRO-1.15"
60/*-----------------------------------------------------------------------------
61 Functions prototypes
62 ----------------------------------------------------------------------------*/
63
64static int xsh_util_bpmap_nl_raw2pre_create(cpl_plugin *) ;
65static int xsh_util_bpmap_nl_raw2pre_exec(cpl_plugin *) ;
66static int xsh_util_bpmap_nl_raw2pre_destroy(cpl_plugin *) ;
67static int xsh_util_bpmap_nl_raw2pre(cpl_parameterlist *, cpl_frameset *) ;
68
69/*-----------------------------------------------------------------------------
70 Static variables
71 ----------------------------------------------------------------------------*/
72
73static char
74xsh_util_bpmap_nl_raw2pre_description_short[] = "Converts RAW_BP_MAP_NL to BP_MAP_NL";
76 "This recipe converts RAW_BP_MAP_NL to BP_MAP_NL.\n"
77 "Information on relevant parameters can be found with\n"
78 "esorex --params xsh_util_bpmap_nl_raw2pre\n"
79 "esorex --help xsh_util_bpmap_nl_raw2pre\n"
80 "\n";
81
82/*-----------------------------------------------------------------------------
83 Functions code
84 ----------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
93/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102int cpl_plugin_get_info(cpl_pluginlist * list)
103{
104 cpl_recipe * recipe = cpl_calloc(1, sizeof *recipe ) ;
105 cpl_plugin * plugin = &recipe->interface ;
106
107 cpl_plugin_init(plugin,
108 CPL_PLUGIN_API,
109 XSH_BINARY_VERSION,
110 CPL_PLUGIN_TYPE_RECIPE,
111 RECIPE_ID,
120
121 cpl_pluginlist_append(list, plugin) ;
122
123 return 0;
124}
125
126/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136static int xsh_util_bpmap_nl_raw2pre_create(cpl_plugin * plugin)
137{
138 cpl_recipe * recipe ;
139 //cpl_parameter * p ;
140
141 /* Reset library state */
142 xsh_init();
143
144 /* Get the recipe out of the plugin */
145 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
146 recipe = (cpl_recipe *)plugin ;
147 else return -1 ;
148 cpl_error_reset();
149
150
151 /* Create the parameters list in the cpl_recipe object */
152 recipe->parameters = cpl_parameterlist_new() ;
153
154 /* Set generic parameters (common to all recipes) */
155 check( xsh_parameters_generic( RECIPE_ID, recipe->parameters ) ) ;
156 xsh_parameters_decode_bp(RECIPE_ID,recipe->parameters,-1);
157 cleanup:
158
159 /* Return */
160 return 0;
161}
162
163/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170static int xsh_util_bpmap_nl_raw2pre_exec(cpl_plugin * plugin)
171{
172 cpl_recipe * recipe ;
173 int code=0;
174 cpl_errorstate initial_errorstate = cpl_errorstate_get();
175
176 /* Get the recipe out of the plugin */
177 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
178 recipe = (cpl_recipe *)plugin ;
179 else return -1 ;
180 cpl_error_reset();
181
182 code = xsh_util_bpmap_nl_raw2pre(recipe->parameters, recipe->frames) ;
183
184
185 if (!cpl_errorstate_is_equal(initial_errorstate)) {
186 /* Dump the error history since recipe execution start.
187 At this point the recipe cannot recover from the error */
188 cpl_errorstate_dump(initial_errorstate, CPL_FALSE, NULL);
189 }
190
191 return code ;
192}
193
194/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201static int xsh_util_bpmap_nl_raw2pre_destroy(cpl_plugin * plugin)
202{
203 cpl_recipe * recipe ;
204
205 /* Get the recipe out of the plugin */
206 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE)
207 recipe = (cpl_recipe *)plugin ;
208 else return -1 ;
209
210 cpl_parameterlist_delete(recipe->parameters) ;
211 return 0 ;
212}
213
214/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222static int
223xsh_util_bpmap_nl_raw2pre( cpl_parameterlist * parlist,
224 cpl_frameset * framelist)
225{
227
228
229 cpl_frame* bpmap_nl=NULL;
230 xsh_pre* pre_bp_nl = NULL;
231 cpl_frame* bp_nl_frame=NULL;
232 char* bp_nl_tag=NULL;
233 char* bp_nl_name=NULL;
234 const char* pro_catg=NULL;
235 const char* recipe_tags[1] = {XSH_RAW_BP_MAP_NL};
236 int recipe_tags_size = 1;
237 cpl_frameset* raws=NULL;
238 cpl_frameset* calib=NULL;
239
240
241 xsh_msg("Welcome to XSHOOTER Pipeline release %d.%d.%d",
242 XSH_MAJOR_VERSION,XSH_MINOR_VERSION,XSH_MICRO_VERSION);
243
244 check( xsh_begin( framelist, parlist, &instrument, &raws, &calib,
245 recipe_tags, recipe_tags_size,
246 RECIPE_ID, XSH_BINARY_VERSION,
248
250 check( pre_bp_nl = xsh_pre_create(bpmap_nl , NULL, NULL, instrument,0));
251 bp_nl_tag=cpl_sprintf("%s_%s",XSH_BP_MAP_NL,
253
254 bp_nl_name=cpl_sprintf("%s.fits",bp_nl_tag);
255 check( bp_nl_frame = xsh_pre_save( pre_bp_nl, bp_nl_name,bp_nl_tag,1 ));
256 cpl_frameset_insert(framelist, bp_nl_frame);
258
259 check( xsh_add_product_bpmap(bp_nl_frame, framelist, parlist,
260 RECIPE_ID, instrument, pro_catg ));
261
262
263 cleanup:
264
265 //xsh_free_frame(&bpmap_nl);
266 //xsh_free_frame(&bp_nl_frame);
267 xsh_pre_free(&pre_bp_nl);
268 xsh_free(bp_nl_name);
269 xsh_free(bp_nl_tag);
270 xsh_free_frameset(&raws);
271 xsh_free_frameset(&calib);
272
273
275
276 if (cpl_error_get_code()) {
277 return -1 ;
278 } else {
279 return 0 ;
280 }
281}
static xsh_instrument * instrument
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
xsh_pre * xsh_pre_create(cpl_frame *raw, cpl_frame *bpmap, cpl_image *bias_data, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
Create a XSH_PRE from a raw frame.
Definition: xsh_data_pre.c:450
cpl_frame * xsh_pre_save(const xsh_pre *pre, const char *filename, const char *tag, int temp)
Save PRE on disk.
#define check(COMMAND)
Definition: xsh_error.h:71
const char * xsh_instrument_arm_tostring(xsh_instrument *i)
Get the string associated with an arm.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
static int xsh_util_bpmap_nl_raw2pre_exec(cpl_plugin *)
Execute the plugin instance given by the interface.
int cpl_plugin_get_info(cpl_pluginlist *list)
Build the list of available plugins, for this module.
static int xsh_util_bpmap_nl_raw2pre(cpl_parameterlist *, cpl_frameset *)
Get the command line options and execute the data reduction.
static int xsh_util_bpmap_nl_raw2pre_destroy(cpl_plugin *)
Destroy what has been created by the 'create' function.
static int xsh_util_bpmap_nl_raw2pre_create(cpl_plugin *)
Setup the recipe options
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
const char * xsh_get_license(void)
Get the pipeline copyright and license.
Definition: xsh_utils.c:1193
void xsh_init(void)
Reset library state.
Definition: xsh_utils.c:1160
cpl_error_code xsh_begin(cpl_frameset *frames, const cpl_parameterlist *parameters, xsh_instrument **instrument, cpl_frameset **raws, cpl_frameset **calib, const char *tag_list[], int tag_list_size, const char *recipe_id, unsigned int binary_version, const char *short_descr)
Recipe initialization.
Definition: xsh_utils.c:1244
void xsh_free(const void *mem)
Deallocate memory.
Definition: xsh_utils.c:2102
void xsh_add_product_bpmap(cpl_frame *frame, cpl_frameset *frameset, const cpl_parameterlist *parameters, const char *recipe_id, xsh_instrument *instrument, const char *final_prefix)
Definition: xsh_dfs.c:2716
cpl_frame * xsh_find_frame_with_tag(cpl_frameset *frames, const char *tag, xsh_instrument *instr)
Find frame with a given tag.
Definition: xsh_dfs.c:3347
#define XSH_MASTER_BP_MAP
Definition: xsh_dfs.h:643
#define XSH_GET_TAG_FROM_ARM(TAG, instr)
Definition: xsh_dfs.h:1548
#define XSH_RAW_BP_MAP_NL
Definition: xsh_dfs.h:365
#define XSH_BP_MAP_NL
Definition: xsh_dfs.h:360
cpl_error_code xsh_parameters_decode_bp(const char *recipe_id, cpl_parameterlist *plist, const int ival)
void xsh_parameters_generic(const char *recipe_id, cpl_parameterlist *plist)
#define RECIPE_CONTACT
static char xsh_util_bpmap_nl_raw2pre_description[]
static char xsh_util_bpmap_nl_raw2pre_description_short[]
#define RECIPE_ID
#define RECIPE_AUTHOR