X-shooter Pipeline Reference Manual 3.8.15
test-product_xsh_master_bias.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: 2011-12-02 14:13:14 $
23 * $Revision: 1.5 $
24 * $Name: not supported by cvs2svn $
25 */
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
29
30/*--------------------------------------------------------------------------*/
38/*--------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------
42 Includes
43 ---------------------------------------------------------------------------*/
44
45
46#include <xsh_data_pre.h>
47#include <xsh_error.h>
48#include <xsh_msg.h>
49#include <xsh_data_instrument.h>
50#include <xsh_dfs.h>
51#include <xsh_pfits.h>
52#include <tests.h>
53#include <cpl.h>
54#include <math.h>
55#include <string.h>
56
57/*---------------------------------------------------------------------------
58 Defines
59 ---------------------------------------------------------------------------*/
60#define MODULE_ID "PRODUCT_XSH_MASTER_BIAS"
61#define SYNTAX "Test the MASTER_BIAS\n"\
62 "use : ./test-product_xsh_master_bias MASTER_BIAS\n"\
63 "MASTER_BIAS => the master bias frame\n"
64/*---------------------------------------------------------------------------
65 Functions prototypes
66 ---------------------------------------------------------------------------*/
67
68/*--------------------------------------------------------------------------*/
76/*--------------------------------------------------------------------------*/
77int main( int argc, char** argv)
78{
79 int res = 0;
80 char* master_bias_name = NULL;
81 const char* master_bias_pcatg = NULL;
82 cpl_propertylist* master_bias_header = NULL;
83 cpl_frame* master_bias_frame = NULL;
84 xsh_pre* master_bias_pre = NULL;
86 double mean =0.0, median=0.0, stdev=0.0, ron=0.0;
87 double structx=0.0, structy=0.0;
88
89 /* Initialize libraries */
91
92 cpl_msg_set_level(CPL_MSG_DEBUG);
94
95 /* Analyse parameters */
96 if (argc > 1){
97 master_bias_name = argv[1];
98 }
99 else{
100 printf(SYNTAX);
101 return 0;
102 }
103
104 /* Read the FITS header to define the arm */
105 XSH_ASSURE_NOT_NULL( master_bias_name);
106 check( master_bias_header = cpl_propertylist_load( master_bias_name, 0 ));
107 check( master_bias_pcatg = xsh_pfits_get_pcatg( master_bias_header));
108
109 /* Create valid instrument */
111 master_bias_frame = cpl_frame_new();
112 cpl_frame_set_filename( master_bias_frame, master_bias_name);
113
114 if ( strstr(master_bias_pcatg, "MASTER_BIAS_UVB") != NULL){
116 cpl_frame_set_tag( master_bias_frame, "MASTER_BIAS_UVB");
117 }
118 else if ( strstr(master_bias_pcatg, "MASTER_BIAS_VIS") != NULL){
120 cpl_frame_set_tag( master_bias_frame, "MASTER_BIAS_VIS");
121 }
122 else {
123 xsh_msg( "Invalid pcatg %s", master_bias_pcatg);
125 }
126
127 /* Create a pre */
128 check( master_bias_pre = xsh_pre_load( master_bias_frame, instrument));
129
130 /* Verify header */
131 check( mean = xsh_pfits_get_qc_mbiasavg ( master_bias_pre->data_header));
132 check( median = xsh_pfits_get_qc_mbiasmed( master_bias_pre->data_header));
133 check( stdev = xsh_pfits_get_qc_mbiasrms ( master_bias_pre->data_header));
134 check( ron = xsh_pfits_get_qc_ron( master_bias_pre->data_header));
135 check( structx = xsh_pfits_get_qc_structx( master_bias_pre->data_header));
136 check( structy = xsh_pfits_get_qc_structy( master_bias_pre->data_header));
137
138 xsh_msg(" Given ron %f Compute ron %f",master_bias_pre->ron, ron);
139 xsh_msg(" structx %f structy %f",structx, structy);
140 xsh_msg(" stdev %f median %f mean %f",stdev, median, mean);
141 xsh_msg(" All is OK");
142 cleanup:
143 if (cpl_error_get_code() != CPL_ERROR_NONE) {
144 xsh_error_dump(CPL_MSG_ERROR);
145 res = 1;
146 }
147 xsh_pre_free( &master_bias_pre);
148 xsh_free_frame( &master_bias_frame);
150 return res;
151}
152
#define MODULE_ID
#define SYNTAX
int main()
Unit test of xsh_bspline_interpol.
static xsh_instrument * instrument
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
#define XSH_ASSURE_NOT_ILLEGAL(cond)
Definition: xsh_error.h:107
#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_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
#define xsh_msg(...)
Print a message on info level.
Definition: xsh_msg.h:121
const char * xsh_pfits_get_pcatg(const cpl_propertylist *plist)
find out the pcatg
Definition: xsh_pfits.c:1627
double xsh_pfits_get_qc_structy(const cpl_propertylist *plist)
Definition: xsh_pfits_qc.c:244
double xsh_pfits_get_qc_mbiasavg(const cpl_propertylist *plist)
find out the QC.MBIASAVG value
Definition: xsh_pfits_qc.c:114
double xsh_pfits_get_qc_mbiasrms(const cpl_propertylist *plist)
find out the QC.MBIASRMS value
Definition: xsh_pfits_qc.c:154
double xsh_pfits_get_qc_ron(const cpl_propertylist *plist)
Definition: xsh_pfits_qc.c:267
double xsh_pfits_get_qc_mbiasmed(const cpl_propertylist *plist)
find out the QC.MBIASMED value
Definition: xsh_pfits_qc.c:134
double xsh_pfits_get_qc_structx(const cpl_propertylist *plist)
Definition: xsh_pfits_qc.c:222
void xsh_free_frame(cpl_frame **f)
Deallocate a frame and set the pointer to NULL.
Definition: xsh_utils.c:2269
int xsh_debug_level_set(int level)
set debug level
Definition: xsh_utils.c:3125
double ron
Definition: xsh_data_pre.h:94
cpl_propertylist * data_header
Definition: xsh_data_pre.h:66
#define TESTS_INIT(DRL_ID)
Definition: tests.h:105
@ XSH_ARM_UVB
@ XSH_ARM_VIS
@ XSH_DEBUG_LEVEL_MEDIUM
Definition: xsh_utils.h:138