X-shooter Pipeline Reference Manual 3.8.15
test-xsh_prepare.c
Go to the documentation of this file.
1/* *
2 * This file is part of the ESO X-shooter Pipeline *
3 * Copyright (C) 2006 European Southern Observatory *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18 * */
19
20/*
21 * $Author: amodigli $
22 * $Date: 2012-04-26 14:10:08 $
23 * $Revision: 1.10 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
36/*--------------------------------------------------------------------------*/
39/*---------------------------------------------------------------------------
40 Includes
41 ---------------------------------------------------------------------------*/
42
43
44#include <xsh_data_pre.h>
45#include <xsh_error.h>
46#include <xsh_msg.h>
47#include <xsh_data_instrument.h>
48#include <xsh_dfs.h>
49#include <xsh_pfits.h>
50#include <tests.h>
51#include <cpl.h>
52#include <math.h>
53#include <getopt.h>
54/*---------------------------------------------------------------------------
55 Defines
56 ---------------------------------------------------------------------------*/
57#define MODULE_ID "XSH_PREPARE"
58
59#define SYNTAX \
60 "Test the xsh_prepare function \n"\
61 " transform RAW frames from a sof in PRE files\n"\
62 "use : ./test_xsh_prepare SOF\n"\
63 " SOF => the raw data FITS file\n"
64
65/*---------------------------------------------------------------------------
66 Functions prototypes
67 ---------------------------------------------------------------------------*/
68
69/*--------------------------------------------------------------------------*/
76/*--------------------------------------------------------------------------*/
77
78int main(int argc, char** argv)
79{
81 xsh_pre *pre = NULL;
82 const char *sof_name = NULL;
83 cpl_frame *master_bias_frame = NULL;
84 cpl_frame *bp_map_frame = NULL;
85 cpl_frameset *set = NULL;
86 cpl_frameset *raws = NULL;
87 cpl_frameset *calib = NULL;
88 int ret=0;
89
90 /* Initialize libraries */
92 cpl_msg_set_level(CPL_MSG_DEBUG);
94
95 /* Analyse parameters */
96 if (argc > 1){
97 sof_name = argv[1];
98 }
99 else{
100 printf(SYNTAX);
101 TEST_END();
102 return 0;
103 }
104
105 XSH_ASSURE_NOT_NULL( sof_name);
106 check( set = sof_to_frameset( sof_name));
107
108 /* Validate frame set */
110 XSH_NEW_FRAMESET( raws);
111 XSH_NEW_FRAMESET( calib);
112 check( xsh_dfs_split_in_group( set, raws, calib));
113 check( bp_map_frame = xsh_find_bpmap( calib));
114 check( master_bias_frame = xsh_find_master_bias( calib, instrument));
115
116#if 0
117 for(i=0;i<3;i++){
118 cpl_frame * frame = NULL;
119 char framename[256];
120
121 sprintf(framename,"frame%d.fits",i);
122 frame = xsh_test_create_frame(framename,10,10,
123 XSH_BIAS_UVB,CPL_FRAME_GROUP_RAW, instrument);
124 cpl_frameset_insert(set,frame);
125 }
126#endif
127 /* USE prepare function */
128 check(xsh_prepare( raws, bp_map_frame, master_bias_frame,
129 MODULE_ID, instrument,0,CPL_FALSE));
130#if 0
131 /* TEST1 : load the result with PRE structure */
132 for(i=0;i<3;i++){
133 cpl_frame * frame = NULL;
134 frame = cpl_frameset_get_frame(set,i);
135 check(pre = xsh_pre_load(frame,instrument));
136 xsh_pre_free(&pre);
137 }
138#endif
139 xsh_msg("load all prepare frame success");
140
141 cleanup:
142 xsh_free_frameset(&set);
143 xsh_free_frameset( &raws);
144 xsh_free_frameset( &calib);
146 if (cpl_error_get_code() != CPL_ERROR_NONE) {
147 xsh_pre_free(&pre);
148 xsh_error_dump(CPL_MSG_ERROR);
149 ret=1;
150 }
151 TEST_END();
152 return ret;
153}
154
int main()
Unit test of xsh_bspline_interpol.
#define MODULE_ID
#define SYNTAX
static xsh_instrument * instrument
cpl_frameset * sof_to_frameset(const char *sof_name)
Definition: tests.c:576
cpl_frame * xsh_test_create_frame(const char *name, int nx, int ny, const char *tag, cpl_frame_group group, xsh_instrument *instrument)
Definition: tests.c:119
xsh_pre * xsh_pre_load(cpl_frame *frame, xsh_instrument *instr)
Load a xsh_pre structure from a frame.
Definition: xsh_data_pre.c:849
void xsh_pre_free(xsh_pre **pre)
Free a xsh_pre structure.
Definition: xsh_data_pre.c:823
void xsh_prepare(cpl_frameset *frames, cpl_frame *bpmap, cpl_frame *mbias, const char *prefix, xsh_instrument *instr, const int pre_overscan_corr, const bool flag_neg_and_thresh_pix)
This function transform RAW frames dataset in PRE frames dataset attaching the default bad pixel map ...
Definition: xsh_prepare.c:122
#define check(COMMAND)
Definition: xsh_error.h:71
#define xsh_error_dump(level)
Definition: xsh_error.h:92
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
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
void xsh_free_frameset(cpl_frameset **f)
Deallocate a frame set and set the pointer to NULL.
Definition: xsh_utils.c:2254
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
#define TEST_END()
Definition: tests.h:111
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
cpl_frame * xsh_find_bpmap(cpl_frameset *set)
find the bad pixel map in a set of files
Definition: xsh_dfs.c:1595
cpl_frame * xsh_find_master_bias(cpl_frameset *frames, xsh_instrument *instr)
Find master bias frame.
Definition: xsh_dfs.c:3319
void xsh_dfs_split_in_group(cpl_frameset *input, cpl_frameset *raws, cpl_frameset *calib)
split input sof in groups: raw and calib
Definition: xsh_dfs.c:1202
xsh_instrument * xsh_dfs_set_groups(cpl_frameset *set)
Set the group as RAW or CALIB in a frameset and return the instrument detected.
Definition: xsh_dfs.c:1046
#define XSH_BIAS_UVB
Definition: xsh_dfs.h:394
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138
#define XSH_NEW_FRAMESET(POINTER)
Definition: xsh_utils.h:84