ERIS Pipeline Reference Manual 1.9.2
eris_nix_img_cal_phot.c
1/* $Id$
2 *
3 * This file is part of the ERIS Pipeline
4 * Copyright (C) 2017 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$
23 * $Date$
24 * $Revision$
25 */
26
27#ifdef HAVE_CONFIG_H
28#include <config.h>
29#endif
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35#include <string.h>
36#include <eris_nix_dfs.h>
37#include <eris_nix_scired.h>
38#include <hdrl.h>
39
40#include <cpl.h>
41
42/*-----------------------------------------------------------------------------
43 Static variables
44 -----------------------------------------------------------------------------*/
45
46static const char eris_nix_img_cal_phot_description[] =
47"This recipe calibrates the photometry of ERIS/NIX frames. It does this \n"
48"in one of 3 ways. \n"
49"\n"
50"1. If a frame that has already been photometrically calibrated is\n"
51" present in the input set of files (SoF), then the photometric\n"
52" zeropoint is transferred from that to the target images.\n"
53"\n"
54" Input files:\n"
55" DO CATG Explanation Req. #Frames\n"
56" ------- ----------- --- -------\n"
57" "ERIS_NIX_IMG_STD_COMBINED_PRO_CATG
58 " photometrically Y 1\n"
59" calibrated file\n"
60" "ERIS_NIX_CAL_WCS_OBJECT_JITTER_PRO_CATG
61 " files to be Y 1-n\n"
62" calibrated\n"
63"\n"
64" Output files:\n"
65" DO CATG Explanation Name\n"
66" ------- ----------- ----\n"
67" "ERIS_NIX_CAL_PHOT_OBJECT_JITTER_PRO_CATG
68 " Calibrated cal_phot.<in_name>\n"
69" files\n"
70"\n"
71" The structure of the output files is the same as the input\n"
72" except for some additional keywords defining the zeropoint,\n"
73" stored in the primary header and the header of the extension\n"
74" holding catalogued objects, if present:\n"
75" --- ESO.QC.MAGZPT = The zeropoint transferred from the input\n"
76" calibrated image.\n"
77" --- ESO.QC.MAGZERR = The zeropoint sigma transferred from\n"
78" the input calibrated image.\n"
79" --- PHOTZP = The zeropoint taking into account the exposure\n"
80" time and extinction for this image. This\n"
81" correction can be applied directly to the image\n"
82" data.\n"
83" --- PHOTZPER = The uncertainty of PHOTZP.\n"
84" --- ZPMETHOD = 'separate_STD_star'\n"
85" --- ZP_CAT = <value of parameter cdssearch_astron>\n"
86"\n"
87"2. If there is no photometrically calibrated frame in the SoF \n"
88" then the recipe will search for a standard star in each frame\n"
89" by trying to associate an object found there with an entry in a \n"
90" catalogue of photometric standards, specified using parameter\n"
91" cdssearch-photom. Currently, the method works only if there is\n"
92" a single standard star in the field.\n"
93"\n"
94" Input files:\n"
95" DO CATG Explanation Req. #Frames\n"
96" ------- ----------- --- -------\n"
97" "ERIS_NIX_CAL_WCS_OBJECT_JITTER_PRO_CATG
98 " target frames with Y 1-n\n"
99" absolutely calibrated\n"
100" wcs, that is with\n"
101" ESO.WCS_METHOD = \n"
102" 'science_field_standard'\n"
103" "ERIS_NIX_PHOT_DATA_PRO_CATG
104 " a photometry data\n"
105" file with colour\n"
106" equations relating\n"
107" the catalogue\n"
108" filters to those\n"
109" of NIX\n"
110"\n"
111" Output files:\n"
112" DO CATG Explanation Name\n"
113" ------- ----------- ----\n"
114" "ERIS_NIX_CAL_PHOT_OBJECT_JITTER_PRO_CATG
115 " Calibrated cal_phot.<in_name>\n"
116" files\n"
117"\n"
118" The structure of each output file is the same as the input\n"
119" except for some added keywords defining the zeropoint stored\n"
120" in the FITS headers, and the addition of a new extension\n"
121" named MATCHSTD_PHOT with details of the matched photometric\n"
122" standards. The new header items are:\n"
123" -- ESO.QC.MAGZPT The zeropoint calculated through aperture 3\n"
124" using objects from the current SoF images.\n"
125" -- ESO.QC.MAGZERR The zeropoint sigma calculated through\n"
126" aperture 3 using objects from the current\n"
127" SoF images.\n"
128" -- ESO.QC.MAGNZPT The number of objects used to calculate the\n"
129" zeropoint.\n"
130" -- ESO.QC.LIMITING_MAG The 5 sigma limiting magnitude through\n"
131" aperture 3.\n"
132" -- PHOTZP The zeropoint taking into account the\n"
133" exposure time and extinction for this image.\n"
134" -- PHOTZPER The uncertainty of PHOTZP.\n"
135" -- ZPMETHOD = '2MASS'\n"
136"\n"
137" Calculation of the photometric zeropoint for each frame is done\n"
138" using the same CASU routines as are used for HAWK-I. The images\n"
139" in the SoF are treated together, as if they were from the 4 \n"
140" HAWKI-I detectors.\n"
141"\n"
142"3. If there is no photometrically calibrated frame in the SoF\n"
143" and either their astrometric calibration is not absolute or no\n"
144" standard stars are found in the target frames, then the\n"
145" assigned zeropoint will be the default value for this filter,\n"
146" copied from the photometric data file.\n"
147"\n"
148" The inputs required are the same as for case 2. The outputs\n"
149" will be the same as for case 1, except for:\n"
150" -- ZPMETHOD = 'DEFAULT'\n"
151"\n";
152
153#define RECIPE_NAME "eris_nix_img_cal_phot"
154#define CONTEXT "eris."RECIPE_NAME
155
156/*-----------------------------------------------------------------------------
157 Private function prototypes
158 -----------------------------------------------------------------------------*/
159
160cpl_recipe_define(eris_nix_img_cal_phot, ERIS_BINARY_VERSION,
161 "John Lightfoot",
162 PACKAGE_BUGREPORT, "2017",
163 "Calibrate photometry of ERIS/NIX frames",
164 eris_nix_img_cal_phot_description);
165
166/*-----------------------------------------------------------------------------
167 Function code
168 -----------------------------------------------------------------------------*/
169
170/*----------------------------------------------------------------------------*/
178/*----------------------------------------------------------------------------*/
179
180static cpl_error_code eris_nix_img_cal_phot_fill_parameterlist(
181 cpl_parameterlist * self) {
182
183 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
184
185 hdrl_parameter * catalogue_defaults = NULL;
186 cpl_parameterlist * catalogue_parlist = NULL;
187 cpl_parameter * p = NULL;
188
189 /* Flag to decide how we get the photometric standard star information. */
190
191 p = cpl_parameter_new_enum(CONTEXT".cdssearch_photom",
192 CPL_TYPE_STRING,
193 "CDS photometric catalogue",
194 CONTEXT,
195 "2MASS", 2, "none", "2MASS");
196 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "cdssearch_photom");
197 cpl_parameterlist_append(self, p);
198
199 /* parameter list for object catalogue generation */
200 /* ..generate the default list first */
201
202 catalogue_defaults = hdrl_catalogue_parameter_create(20, 3.0, CPL_TRUE,
203 10.0, CPL_TRUE, 128, 5.0, 3.0,
204 ERIS_NIX_SATURATION_DEFAULT, HDRL_CATALOGUE_ALL);
205 catalogue_parlist = hdrl_catalogue_parameter_create_parlist(CONTEXT,
206 "catalogue", catalogue_defaults);
207
208 /* ..subset the parameters actually used */
209
210 for (p = cpl_parameterlist_get_first(catalogue_parlist);
211 p != NULL;
212 p = cpl_parameterlist_get_next(catalogue_parlist)) {
213
214 const char * pname = cpl_parameter_get_name(p);
215 if (strstr(pname, "minmax") == NULL) {
216 cpl_parameter * duplicate = cpl_parameter_duplicate(p);
217 cpl_parameterlist_append(self, duplicate);
218 }
219 }
220
221 /* ..add ao-params which specifies how to set params depending on AO */
222
223 p = cpl_parameter_new_enum(CONTEXT".catalogue.ao-params",
224 CPL_TYPE_STRING,
225 "Default catalogue.core-radius and "
226 "catalogue.mesh-size depending on "
227 "AOMODE, or not",
228 CONTEXT,
229 "auto", 2, "auto", "user");
230 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "catalogue.ao-params");
231 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
232 cpl_parameterlist_append(self, p);
233
234 /* parameters for object-catalogue matching algorithm */
235
236 p = cpl_parameter_new_value(CONTEXT".pixel_radius",
237 CPL_TYPE_DOUBLE,
238 "Max. distance between object and catalogue "
239 "entry for association (pixels)",
240 CONTEXT, 5.0);
241 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "pixel-radius");
242 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
243 cpl_parameterlist_append(self, p);
244
245 p = cpl_parameter_new_range(CONTEXT".minphotom",
246 CPL_TYPE_INT,
247 "Min number of matched stars for photometric "
248 "calibration", CONTEXT, 1, 1, 100000);
249 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "minphotom");
250 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
251 cpl_parameterlist_append(self, p);
252
253 p = cpl_parameter_new_value(CONTEXT".magerrcut",
254 CPL_TYPE_DOUBLE,
255 "Matched stars with magnitude error above "
256 "this cutoff will not be used.",
257 CONTEXT, 0.5);
258 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "magerrcut");
259 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
260 cpl_parameterlist_append(self, p);
261
262 p = cpl_parameter_new_value(CONTEXT".debug-data",
263 CPL_TYPE_BOOL, "true to save interim results",
264 CONTEXT, CPL_FALSE);
265 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "debug-data");
266 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
267 cpl_parameterlist_append(self, p);
268
269 /* tidy up */
270
271 hdrl_parameter_delete(catalogue_defaults);
272 cpl_parameterlist_delete(catalogue_parlist);
273
274 return 0;
275}
276
277
278/*----------------------------------------------------------------------------*/
285/*----------------------------------------------------------------------------*/
286
287static int eris_nix_img_cal_phot(cpl_frameset * frameset,
288 const cpl_parameterlist * parlist) {
289
290 eris_nix_scired_cal_phot(frameset, parlist, RECIPE_NAME, CONTEXT);
291
292 return (int) cpl_error_get_code();
293}
cpl_error_code eris_nix_scired_cal_phot(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
This recipe calibrates the photometry of ERIS/NIX frames.
hdrl_parameter * hdrl_catalogue_parameter_create(int obj_min_pixels, double obj_threshold, cpl_boolean obj_deblending, double obj_core_radius, cpl_boolean bkg_estimate, int bkg_mesh_size, double bkg_smooth_fwhm, double det_eff_gain, double det_saturation, hdrl_catalogue_options resulttype)
Creates catalogue Parameters object.
cpl_parameterlist * hdrl_catalogue_parameter_create_parlist(const char *base_context, const char *prefix, hdrl_parameter *defaults)
Create parameter list for the catalogue computation.
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter