FORS Pipeline Reference Manual  5.0.9
fors_detlin.c
1 /* $Id: fors_detlin.c,v 1.13 2011-10-24 13:11:17 cgarcia Exp $
2  *
3  * This file is part of the FORS Data Reduction Pipeline
4  * Copyright (C) 2002-2010 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 02110-1301 USA
19  */
20 
21 /*
22  * $Author: cgarcia $
23  * $Date: 2011-10-24 13:11:17 $
24  * $Revision: 1.13 $
25  * $Name: not supported by cvs2svn $
26  */
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30 
31 /*----------------------------------------------------------------------------
32  Includes
33  ----------------------------------------------------------------------------*/
34 
35 #include <cpl.h>
36 
37 #include "irplib_detmon.h"
38 #include "irplib_detmon_lg.h"
39 #include <fors_dfs.h>
40 
41 /* Define here the DO.CATG keywords */
42 #define DETMON_OPT_LG_ON_RAW "DETECTOR_CHECK_FLAT"
43 #define DETMON_OPT_LG_OFF_RAW "DETECTOR_CHECK_BIAS"
44 
45 #define RECIPE_NAME "fors_detlin"
46 
47 #define OPT FALSE
48 
49 /*----------------------------------------------------------------------------
50  Functions prototypes
51  ----------------------------------------------------------------------------*/
52 
53 static cpl_error_code
54 fors_detlin_fill_parlist(cpl_parameterlist *);
55 
56 CPL_RECIPE_DEFINE(fors_detlin, FORS_BINARY_VERSION,
57  fors_detlin_fill_parlist(recipe->parameters),
58  "Lander de Bilbao", "lbilbao@eso.org", "2008",
59  "Linearity/Gain recipe for the optical domain",
60  irplib_detmon_lg_get_description("fors_detlin",
61  PACKAGE_TARNAME,
62  DETMON_OPT_LG_ON_RAW,
63  DETMON_OPT_LG_OFF_RAW));
64 
65 /*---------------------------------------------------------------------------*/
66 /*
67  @brief Interpret the command line options and execute the data processing
68  @param frameset the frames list
69  @param parlist the parameters list
70  @return 0 if everything is ok
71  */
72 /*---------------------------------------------------------------------------*/
73 
74 static int fors_detlin(cpl_frameset *frameset,
75  const cpl_parameterlist *parlist)
76 {
77  cpl_propertylist * lintbl =
78  irplib_detmon_fill_prolist("DET_LIN_INFO", NULL, NULL, CPL_FALSE);
79 
80  cpl_propertylist * gaintbl =
81  irplib_detmon_fill_prolist("GAIN_INFO", NULL, NULL, CPL_FALSE);
82 
83  cpl_propertylist * coeffscube =
84  irplib_detmon_fill_prolist("COEFFS_CUBE", NULL, NULL, CPL_FALSE);
85 
86  cpl_propertylist * bpm =
87  irplib_detmon_fill_prolist("BP_MAP_NL", NULL, NULL, CPL_FALSE);
88 
89  cpl_propertylist * corr =
90  irplib_detmon_fill_prolist("AUTOCORR", NULL, NULL, CPL_FALSE);
91 
92  cpl_propertylist * diff_flat =
93  irplib_detmon_fill_prolist("DIFF_FLAT", NULL, NULL, CPL_FALSE);
94 
95  const cpl_error_code error = irplib_detmon_lg(frameset,
96  parlist,
97  DETMON_OPT_LG_ON_RAW,
98  DETMON_OPT_LG_OFF_RAW,
99  RECIPE_NAME,
100  PACKAGE_TARNAME,
101  REGEXP,
102  lintbl, gaintbl, coeffscube,
103  bpm, corr, diff_flat,
104  PACKAGE "/" PACKAGE_VERSION,
105  NULL, NULL, OPT);
106 
107  cpl_propertylist_delete(lintbl);
108  cpl_propertylist_delete(gaintbl);
109  cpl_propertylist_delete(coeffscube);
110  cpl_propertylist_delete(bpm);
111  cpl_propertylist_delete(corr);
112  cpl_propertylist_delete(diff_flat);
113 
114  {
115  /*
116  * This part is added until ticket DFS05711 is fixed.
117  */
118 
119  cpl_image *chipmap;
120  cpl_image *badpixmap;
121  int llx = dfs_get_parameter_int_const(parlist,
122  PACKAGE_TARNAME "." RECIPE_NAME ".llx");
123  int lly = dfs_get_parameter_int_const(parlist,
124  PACKAGE_TARNAME "." RECIPE_NAME ".lly");
125 
126  badpixmap = dfs_load_image(frameset, "BP_MAP_NL", CPL_TYPE_FLOAT, 0, 1);
127  chipmap = cpl_image_new(2048, 1024, CPL_TYPE_FLOAT);
128  cpl_image_copy(chipmap, badpixmap, llx, lly - 5);
129  cpl_image_delete(badpixmap);
130  dfs_save_image(frameset, chipmap, "BP_MAP_NL_FULL", NULL, parlist,
131  RECIPE_NAME, PACKAGE "/" PACKAGE_VERSION);
132  cpl_image_delete(chipmap);
133  }
134 
135  /* Propagate the error, if any */
136  cpl_ensure_code(!error, error);
137 
138  return CPL_ERROR_NONE;
139 }
140 
141 static cpl_error_code
142 fors_detlin_fill_parlist(cpl_parameterlist * parlist)
143 {
144  cpl_error_code error;
145  cpl_parameter * p;
146 
147  error = irplib_detmon_lg_fill_parlist_opt_default(parlist,
148  "fors_detlin", PACKAGE_TARNAME);
149 
150  cpl_ensure_code(!error, error);
151 
152 
153  p = cpl_parameterlist_find(parlist,
154  PACKAGE_TARNAME "." RECIPE_NAME ".tolerance");
155  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
156  error = cpl_parameter_set_default_double(p, 0.1);
157  cpl_ensure_code(!error, error);
158 
159  p = cpl_parameterlist_find(parlist,
160  PACKAGE_TARNAME "." RECIPE_NAME ".pix2pix");
161  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
162  error = cpl_parameter_set_default_bool(p, 1);
163  cpl_ensure_code(!error, error);
164 
165  p = cpl_parameterlist_find(parlist,
166  PACKAGE_TARNAME "." RECIPE_NAME ".order");
167  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
168  error = cpl_parameter_set_default_int(p, 2);
169  cpl_ensure_code(!error, error);
170 
171  p = cpl_parameterlist_find(parlist,
172  PACKAGE_TARNAME "." RECIPE_NAME ".kappa");
173  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
174  error = cpl_parameter_set_default_double(p, 4.0);
175  cpl_ensure_code(!error, error);
176 
177 
178  p = cpl_parameterlist_find(parlist,
179  PACKAGE_TARNAME "." RECIPE_NAME ".llx");
180  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
181  error = cpl_parameter_set_default_int(p, 1);
182  cpl_ensure_code(!error, error);
183 
184  p = cpl_parameterlist_find(parlist,
185  PACKAGE_TARNAME "." RECIPE_NAME ".urx");
186  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
187  error = cpl_parameter_set_default_int(p, 2048);
188  cpl_ensure_code(!error, error);
189 
190 
191  p = cpl_parameterlist_find(parlist,
192  PACKAGE_TARNAME "." RECIPE_NAME ".lly");
193  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
194  error = cpl_parameter_set_default_int(p, 6);
195  cpl_ensure_code(!error, error);
196 
197  p = cpl_parameterlist_find(parlist,
198  PACKAGE_TARNAME "." RECIPE_NAME ".ury");
199  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
200  error = cpl_parameter_set_default_int(p, 1029);
201  cpl_ensure_code(!error, error);
202 
203 /*
204  p = cpl_parameterlist_find(parlist,
205  PACKAGE_TARNAME "." RECIPE_NAME ".method");
206  cpl_ensure_code(p != NULL, CPL_ERROR_DATA_NOT_FOUND);
207  error = cpl_parameter_set_default_string(p, "MED");
208  cpl_ensure_code(!error, error);
209 */
210 
211  return error;
212 
213 }
cpl_image * dfs_load_image(cpl_frameset *frameset, const char *category, cpl_type type, int ext, int calib)
Loading image data of given category.
Definition: fors_dfs.c:860
int dfs_get_parameter_int_const(const cpl_parameterlist *parlist, const char *name)
Definition: fors_dfs.c:806
int dfs_save_image(cpl_frameset *frameset, const cpl_image *image, const char *category, cpl_propertylist *header, const cpl_parameterlist *parlist, const char *recipename, const char *version)
Saving image data of given category.
Definition: fors_dfs.c:1451