HAWKI Pipeline Reference Manual  1.8.12
hawki_cal_lingain.c
1 /* $Id: hawki_cal_lingain.c,v 1.4 2010/09/28 14:13:48 cgarcia Exp $
2  *
3  * This file is part of the CRIRES 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: cgarcia $
23  * $Date: 2010/09/28 14:13:48 $
24  * $Revision: 1.4 $
25  * $Name: hawki-1_8_12 $
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 
32 /*----------------------------------------------------------------------------
33  Includes and Defines
34  ----------------------------------------------------------------------------*/
35 
36 #include <cpl.h>
37 
38 #include "irplib_detmon_lg.h"
39 #include "irplib_detmon.h"
40 #include "irplib_plugin.h"
41 
42 #include "hawki_dfs.h"
43 
44 #define RECIPE_NAME "hawki_cal_lingain"
45 
46 /* Copy here instrument specific keywords which need to be in the PAF file */
47 #define INSTREGEXP "ESO INS SETUP ID"
48 #define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
49 
50 
51 /*----------------------------------------------------------------------------
52  Functions prototypes
53  ----------------------------------------------------------------------------*/
54 
57 cpl_error_code hawki_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist);
58 
59 IRPLIB_RECIPE_DEFINE(hawki_cal_lingain, HAWKI_BINARY_VERSION,
60  hawki_cal_lingain_fill_parlist_default(recipe->parameters),
61  "Enrique Garcia", PACKAGE_BUGREPORT, "2009",
62  "Linearity/Gain recipe for the IR domain",
63  irplib_detmon_lg_get_description(RECIPE_NAME, "HAWKI",
64  HAWKI_CAL_LINGAIN_LAMP_RAW,
65  HAWKI_CAL_LINGAIN_DARK_RAW));
66 
67 /*---------------------------------------------------------------------------*/
68 /*
69  @brief Interpret the command line options and execute the data processing
70  @param frameset the frames list
71  @param parlist the parameters list
72  @return 0 if everything is ok
73  */
74 /*---------------------------------------------------------------------------*/
75 static int hawki_cal_lingain(cpl_frameset * frameset,
76  const cpl_parameterlist * parlist)
77 {
78  cpl_error_code error ;
79  cpl_propertylist * pro_lintbl ;
80  cpl_propertylist * pro_gaintbl ;
81  cpl_propertylist * pro_coeffscube ;
82  cpl_propertylist * pro_bpm ;
83  cpl_propertylist * pro_corr ;
84  cpl_propertylist * pro_diff ;
85 
86  /* Create the PRO keys propertylist */
87  pro_lintbl = cpl_propertylist_new() ;
88  cpl_propertylist_append_string(pro_lintbl, CPL_DFS_PRO_CATG,
89  HAWKI_CALPRO_LINGAIN_LIN) ;
90  cpl_propertylist_append_string(pro_lintbl, CPL_DFS_PRO_TYPE,
91  HAWKI_PROTYPE_LIN_STATS) ;
92 
93  pro_gaintbl = cpl_propertylist_new() ;
94  cpl_propertylist_append_string(pro_gaintbl, CPL_DFS_PRO_CATG,
95  HAWKI_CALPRO_LINGAIN_GAIN) ;
96  cpl_propertylist_append_string(pro_gaintbl, CPL_DFS_PRO_TYPE,
97  HAWKI_PROTYPE_GAIN_STATS) ;
98 
99  pro_coeffscube = cpl_propertylist_new() ;
100  cpl_propertylist_append_string(pro_coeffscube, CPL_DFS_PRO_CATG,
101  HAWKI_CALPRO_LINGAIN_COEFFS) ;
102  cpl_propertylist_append_string(pro_coeffscube, CPL_DFS_PRO_TYPE,
103  HAWKI_PROTYPE_LIN_COEFFS) ;
104 
105  pro_bpm = cpl_propertylist_new() ;
106  cpl_propertylist_append_string(pro_bpm, CPL_DFS_PRO_CATG,
107  HAWKI_CALPRO_LINGAIN_BPM) ;
108  cpl_propertylist_append_string(pro_bpm, CPL_DFS_PRO_TYPE,
109  HAWKI_PROTYPE_BPM_LEVELS) ;
110 
111  pro_corr = cpl_propertylist_new() ;
112  cpl_propertylist_append_string(pro_corr, CPL_DFS_PRO_CATG,
113  HAWKI_CALPRO_LINGAIN_CORR) ;
114  cpl_propertylist_append_string(pro_corr, CPL_DFS_PRO_TYPE,
115  HAWKI_PROTYPE_LINGAIN_CORR) ;
116 
117  pro_diff = cpl_propertylist_new() ;
118  cpl_propertylist_append_string(pro_diff, CPL_DFS_PRO_CATG,
119  HAWKI_CALPRO_LINGAIN_DIFF) ;
120  cpl_propertylist_append_string(pro_diff, CPL_DFS_PRO_TYPE,
121  HAWKI_PROTYPE_LINGAIN_DIFF) ;
122 
123  /* Call the lingain function */
124  error = irplib_detmon_lg(frameset,
125  parlist,
126  HAWKI_CAL_LINGAIN_LAMP_RAW,
127  HAWKI_CAL_LINGAIN_DARK_RAW,
128  RECIPE_NAME,
129  PACKAGE_TARNAME,
130  PAFREGEXP,
131  pro_lintbl,
132  pro_gaintbl,
133  pro_coeffscube,
134  pro_bpm,
135  pro_corr,
136  pro_diff,
137  PACKAGE "/" PACKAGE_VERSION,
138  NULL, NULL, TRUE);
139 
140  /* Delete the PRO keys propertylist */
141  cpl_propertylist_delete(pro_lintbl) ;
142  cpl_propertylist_delete(pro_gaintbl) ;
143  cpl_propertylist_delete(pro_coeffscube) ;
144  cpl_propertylist_delete(pro_bpm) ;
145  cpl_propertylist_delete(pro_corr) ;
146  cpl_propertylist_delete(pro_diff) ;
147 
148  /* Propagate the error, if any */
149  cpl_ensure_code(!error, error);
150 
151  /* Return */
152  if (cpl_error_get_code())
153  {
154  cpl_msg_error(__func__,
155  "HAWK-I pipeline could not recover from previous errors");
156  return -1 ;
157  }
158  else return 0;
159 }
160 
161 cpl_error_code
162 hawki_cal_lingain_fill_parlist_default(cpl_parameterlist * parlist)
163 {
164  cpl_parameter * p;
165  cpl_error_code error ;
166 
167  error=irplib_detmon_lg_fill_parlist_nir_default(parlist,
168  RECIPE_NAME, PACKAGE_TARNAME);
169  cpl_ensure_code(!error, error);
170 
171  /* Set to reduce all extensions */
172  p = cpl_parameterlist_find(parlist, PACKAGE_TARNAME "." RECIPE_NAME
173  ".exts");
174  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
175  error = cpl_parameter_set_default_int(p, -1);
176  cpl_ensure_code(!error, error);
177 
178 
179  return CPL_ERROR_NONE;
180 }