X-shooter Pipeline Reference Manual 3.8.15
test-xsh_subtract_sky_nod.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.12 $
24 */
25#ifdef HAVE_CONFIG_H
26# include <config.h>
27#endif
28
29/*--------------------------------------------------------------------------*/
35/*--------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------
39 Includes
40 ---------------------------------------------------------------------------*/
41
42
43#include <xsh_data_order.h>
44#include <xsh_error.h>
45#include <xsh_msg.h>
46#include <xsh_data_instrument.h>
47#include <xsh_dfs.h>
48#include <xsh_pfits.h>
49#include <tests.h>
50#include <xsh_utils_table.h>
51#include <cpl.h>
52#include <math.h>
53#include <getopt.h>
54
55/*---------------------------------------------------------------------------
56 Defines
57 ---------------------------------------------------------------------------*/
58#define MODULE_ID "XSH_SUBTRACT_SKY_NOD"
59
60#define SYNTAX "Test xsh_subtract_sky_nod\n"\
61 "usage : ./test_xsh_subtract_sky_nod [<o[tions>] <raw_file1> <raw_file2> ... \n"\
62 " Subtract noded files 2 by 2).\n"\
63 "<raw_files> the list of raw files, 2 by 2\n"\
64
65#if 0
66static const char * Options = "?" ;
67
68enum {
70} ;
71
72static struct option LongOptions[] = {
73 {"point", required_argument, 0, POINT_OPT},
74 {"size", required_argument, 0, SIZE_OPT},
75 {"step", required_argument, 0, STEP_OPT},
76 {"c-color", required_argument, 0, C_COLOR_OPT},
77 {NULL, 0, 0, 0}
78} ;
79
80static char PointType[16] ;
81static char PointSize[8] ;
82static int PointStep = 8 ;
83static char CentralColor[32] ;
84#endif
85
86/*--------------------------------------------------------------------------
87 Implementation
88 --------------------------------------------------------------------------*/
89#if 0
90static void HandleOptions( int argc, char ** argv )
91{
92 int opt ;
93 int option_index = 0;
94
95 /* Set default values */
96 strcpy( PointType, "cross" ) ;
97 strcpy( PointSize, "" ) ;
98 strcpy( CentralColor, "green" ) ;
99
100 while( (opt = getopt_long( argc, argv, Options,
101 LongOptions, &option_index )) != EOF )
102 switch( opt ) {
103 case POINT_OPT:
104 strcpy( PointType, optarg ) ;
105 break ;
106 case SIZE_OPT:
107 strcpy( PointSize, optarg ) ;
108 break ;
109 case STEP_OPT:
110 sscanf( optarg, "%d", &PointStep ) ;
111 break ;
112 case C_COLOR_OPT:
113 strcpy( CentralColor, optarg ) ;
114 break ;
115 default:
116 printf( SYNTAX ) ;
117 exit( 0 ) ;
118 }
119}
120#endif
121
122/*--------------------------------------------------------------------------*/
130/*--------------------------------------------------------------------------*/
131int main(int argc, char** argv)
132{
133 int ret = 1;
134 xsh_instrument * instrument = NULL ;
135 cpl_frameset *set = NULL;
136 cpl_frameset *ord_set = NULL;
137 int nb_raw_frames , raw_modulo;
138 cpl_frameset * pairs = NULL ;
139 int mode=0;
140 const int decode_bp=2147483647;
141
142 /* Initialize libraries */
144 cpl_msg_set_level(CPL_MSG_DEBUG);
146#if 0
147 HandleOptions( argc, argv );
148#endif
149
150 /* Analyse parameters */
151 if ( argc < 2 ) {
152 printf(SYNTAX);
153 TEST_END();
154 return 0;
155 }
156 else {
157 /* Create frameset from all raw frames */
158 int iarg = 1 ;
159
160 check( set = cpl_frameset_new() ) ;
161 nb_raw_frames = 0 ;
162
163 for( iarg = 1 ; iarg < argc ; iarg++ ) {
164 cpl_frame * input_frame = NULL ;
165
166 check( input_frame = cpl_frame_new() ) ;
167 check(cpl_frame_set_filename( input_frame, argv[iarg] ) );
168 check(cpl_frame_set_tag(input_frame, "OBJECT_SLIT_NOD_VIS" ) ) ;
169 check(cpl_frame_set_group( input_frame, CPL_FRAME_GROUP_RAW ) ) ;
170 check(cpl_frameset_insert( set, input_frame ) ) ;
171 nb_raw_frames++ ;
172 }
173 }
174 xsh_msg( "Nb of frames: %d", nb_raw_frames ) ;
175
181
182 /* Create frames */
183 XSH_ASSURE_NOT_NULL( set );
184
185 raw_modulo = nb_raw_frames % 2;
186 XSH_ASSURE_NOT_ILLEGAL( raw_modulo == 0);
187
188 check(xsh_prepare( set, NULL, (cpl_frame *)-1, XSH_OBJECT_SLIT_NOD,
189 instrument,0,CPL_FALSE));
190 xsh_msg( "Now call xsh_subtract_sky_nod with %d raw frames",
191 nb_raw_frames ) ;
192
193 check( pairs = xsh_subtract_sky_nod( set,
194 instrument, mode)) ;
195 ret = 0 ;
196
197 cleanup:
199 xsh_free_frameset( &pairs);
200 xsh_free_frameset( &set);
201 xsh_free_frameset( &ord_set);
202
203 if ( cpl_error_get_code() != CPL_ERROR_NONE){
204 ret = 1;
205 }
206 TEST_END();
207 return ret ;
208}
209
int main()
Unit test of xsh_bspline_interpol.
static const char * Options
static char mode[32]
static void HandleOptions(int argc, char **argv, int *nscales)
static xsh_instrument * instrument
static struct option LongOptions[]
#define MODULE_ID
#define SYNTAX
static char PointSize[8]
static int PointStep
static char CentralColor[32]
static char PointType[16]
@ C_COLOR_OPT
@ STEP_OPT
@ SIZE_OPT
@ POINT_OPT
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 XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#define check(COMMAND)
Definition: xsh_error.h:71
#define XSH_ASSURE_NOT_NULL(pointer)
Definition: xsh_error.h:99
void xsh_instrument_set_mode(xsh_instrument *i, XSH_MODE mode)
Set a mode on instrument structure.
void xsh_instrument_set_arm(xsh_instrument *i, XSH_ARM arm)
Set an arm on instrument structure.
void xsh_instrument_free(xsh_instrument **instrument)
free an instrument structure
xsh_instrument * xsh_instrument_new(void)
create new instrument structure
void xsh_instrument_set_decode_bp(xsh_instrument *i, const int decode_bp)
Set bad pixel code.
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
cpl_frameset * xsh_subtract_sky_nod(cpl_frameset *raws, xsh_instrument *instrument, int mode_fast)
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
@ XSH_ARM_VIS
@ XSH_MODE_SLIT
#define XSH_OBJECT_SLIT_NOD
Definition: xsh_dfs.h:228
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138