IIINSTRUMENT Pipeline Reference Manual 4.4.12
naco_img_lingain.c
1/* $Id: naco_img_lingain.c,v 1.11 2013-03-12 08:03:07 llundin Exp $
2 *
3 * This file is part of the DETMON 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., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: llundin $
23 * $Date: 2013-03-12 08:03:07 $
24 * $Revision: 1.11 $
25 * $Name: not supported by cvs2svn $
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_plugin.h"
40
41/* Define here the DO.CATG keywords */
42#define NACO_IMG_LINGAIN_ON_RAW "CAL_LINGAIN_LAMP"
43#define NACO_IMG_LINGAIN_OFF_RAW "CAL_LINGAIN_DARK"
44
45#define RECIPE_NAME "naco_img_lingain"
46
47/* Copy here instrument specific keywords which need to be in the PAF file */
48#define INSTREGEXP "ESO DET MODE NAME|ESO DET NCORRS NAME|" \
49 "ESO INS OPTI7 NAME|ESO INS OPTI6 NAME|" \
50 "ESO INS OPTI5 NAME|ESO INS OPTI4 NAME"
51
52#define PAFREGEXP "^(" REGEXP "|" INSTREGEXP ")$"
53
54#define NIR TRUE
55
56#ifndef NACO_REF_LEVEL
57/* DFO states that the NACO reference level is in the range 1600 - 4000
58 with 3500 being the typical level. For one dataset 3500 is too high,
59 while values below 2300 work. */
60#define NACO_REF_LEVEL 2000
61#endif
62
63/*----------------------------------------------------------------------------
64 Functions prototypes
65 ----------------------------------------------------------------------------*/
66cpl_recipe_define(naco_img_lingain, NACO_BINARY_VERSION,
67 "Lars Lundin", PACKAGE_BUGREPORT, "2007",
68 "Linearity/Gain recipe for the IR domain",
69 irplib_detmon_lg_get_description(RECIPE_NAME, "NACO",
70 NACO_IMG_LINGAIN_ON_RAW,
71 NACO_IMG_LINGAIN_OFF_RAW));
72
73/*----------------------------------------------------------------------------*/
77/*----------------------------------------------------------------------------*/
78
79/*-----------------------------------------------------------------------------
80 Functions code
81 -----------------------------------------------------------------------------*/
82
83
84
85/*---------------------------------------------------------------------------*/
86/*
87 @brief Interpret the command line options and execute the data processing
88 @param frameset the frames list
89 @param parlist the parameters list
90 @return 0 iff everything is ok
91 */
92/*---------------------------------------------------------------------------*/
93static int naco_img_lingain(cpl_frameset * frameset,
94 const cpl_parameterlist * parlist)
95{
96
97 cpl_propertylist * pro_lintbl = cpl_propertylist_new();
98 cpl_propertylist * pro_gaintbl = cpl_propertylist_new();
99 cpl_propertylist * pro_coeffscube = cpl_propertylist_new();
100 cpl_propertylist * pro_bpm = cpl_propertylist_new();
101 cpl_propertylist * pro_corr = cpl_propertylist_new();
102 cpl_propertylist * pro_diff = cpl_propertylist_new();
103 cpl_error_code error = CPL_ERROR_NONE;
104
105 error |= cpl_propertylist_append_string(pro_lintbl, "ESO PRO CATG",
106 "DET_LIN_INFO");
107 error |= cpl_propertylist_append_string(pro_gaintbl, "ESO PRO CATG",
108 "GAIN_INFO");
109 error |= cpl_propertylist_append_string(pro_coeffscube, "ESO PRO CATG",
110 "COEFFS_CUBE");
111 error |= cpl_propertylist_append_string(pro_bpm, "ESO PRO CATG",
112 "BP_MAP_NL");
113 error |= cpl_propertylist_append_string(pro_corr, "ESO PRO CATG",
114 "AUTOCORR");
115 error |= cpl_propertylist_append_string(pro_diff, "ESO PRO CATG",
116 "DIFF_FLAT");
117
118 error |= irplib_detmon_lg(frameset,
119 parlist,
120 NACO_IMG_LINGAIN_ON_RAW,
121 NACO_IMG_LINGAIN_OFF_RAW,
122 RECIPE_NAME,
123 PACKAGE,
124 PAFREGEXP,
125 pro_lintbl,
126 pro_gaintbl,
127 pro_coeffscube,
128 pro_bpm,
129 pro_corr,
130 pro_diff,
131 PACKAGE "/" PACKAGE_VERSION,
132 NULL, NULL, NIR);
133
134 cpl_propertylist_delete(pro_lintbl);
135 cpl_propertylist_delete(pro_gaintbl);
136 cpl_propertylist_delete(pro_coeffscube);
137 cpl_propertylist_delete(pro_bpm);
138 cpl_propertylist_delete(pro_corr);
139 cpl_propertylist_delete(pro_diff);
140
141 /* Propagate the error, if any */
142 cpl_ensure_code(!error, cpl_error_get_code());
143
144 return CPL_ERROR_NONE;
145}
146
147
148
149/*---------------------------------------------------------------------------*/
150/*
151 @internal
152 @brief Fill the parameterlist including NACO specific defaults
153 @param self The parameter list to fill
154 @return 0 if everything is ok
155 */
156/*---------------------------------------------------------------------------*/
157static
158cpl_error_code naco_img_lingain_fill_parameterlist(cpl_parameterlist * self)
159{
160
161 cpl_error_code error =
162 irplib_detmon_lg_fill_parlist_nir_default(self, RECIPE_NAME, PACKAGE);
163 cpl_parameter * p;
164
165 cpl_ensure_code(!error, error);
166
167 /* FIXME: Put the parameter names and their new default values in two arrays
168 and iterate through them */
169 p = cpl_parameterlist_find(self, PACKAGE "." RECIPE_NAME ".ref_level");
170
171 cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
172
173 error = cpl_parameter_set_default_int(p, NACO_REF_LEVEL);
174
175 cpl_ensure_code(!error, error);
176
177 return CPL_ERROR_NONE;
178}