ERIS Pipeline Reference Manual 1.9.2
eris_nix_img_hdrl_stack.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 <libgen.h>
36//#include <math.h>
37#include <string.h>
38
39//#include "eris_nix_utils.h"
40#include "eris_nix_dfs.h"
41#include "eris_nix_scired.h"
42#include <hdrl.h>
43#include <cpl.h>
44
45/*-----------------------------------------------------------------------------
46 Static variables
47 -----------------------------------------------------------------------------*/
48
49static const char eris_nix_img_hdrl_stack_description[] =
50"This recipe uses HDRL functions to rebin and stack a set of calibrated \n"
51"ERIS/NIX jitter frames.\n"
52"\n"
53"Input files:\n"
54"\n"
55" DO CATG Explanation Req. #Frames\n"
56" ------- ----------- --- -------\n"
57" "ERIS_NIX_CAL_PHOT_OBJECT_JITTER_PRO_CATG
58 " calibrated frames Y 1-n\n"
59" to be stacked.\n"
60" or\n"
61" "ERIS_NIX_CAL_PHOT_STD_JITTER_PRO_CATG
62 " calibrated standard Y 1-n\n"
63" frames to be stacked.\n"
64"\n"
65"Output files:\n"
66"\n"
67" DO CATG Explanation \n"
68" ------- ----------- \n"
69" "ERIS_NIX_IMG_OBS_COMBINED_PRO_CATG
70 " the stacked image of the target.\n"
71" or\n"
72" "ERIS_NIX_IMG_STD_COMBINED_PRO_CATG
73 " the stacked image of the standard.\n"
74" "ERIS_NIX_IMG_CATALOGUE_PRO_CATG
75 " catalogue of sources in the\n"
76" stacked image.\n"
77"\n"
78" The output image will be in a FITS file named \n"
79" 'stack.<first input filename>', with extensions:\n"
80" - DATA, with the stacked target or standard data.\n"
81" - ERR, with the error plane.\n"
82" - DQ, with the stacked image quality\n"
83" - CONFIDENCE, with the target confidence plane.\n"
84" A catalogue of sources in the image will be written to FITS file \n"
85" 'cat.stack.<first input filename>'.\n"
86
87"\n"
88"Notes on the method.\n"
89" The stacking uses hdrl_resample_compute to combine all jitter\n"
90" images in a single cloud of points. When creating the resampled \n"
91" output image all information is used in a single interpolation \n"
92" step, i.e. no image-by-image interpolation is done.\n"
93"\n";
94
95#define RECIPE_NAME "eris_nix_img_hdrl_stack"
96#define CONTEXT "eris."RECIPE_NAME
97/*-----------------------------------------------------------------------------
98 Private function prototypes
99 -----------------------------------------------------------------------------*/
100
101cpl_recipe_define(eris_nix_img_hdrl_stack, ERIS_BINARY_VERSION,
102 "John Lightfoot",
103 PACKAGE_BUGREPORT,
104 "2021",
105 "Stack calibrated ERIS/NIX jitter frames using HDRL",
106 eris_nix_img_hdrl_stack_description);
107
108/*-----------------------------------------------------------------------------
109 Function code
110 -----------------------------------------------------------------------------*/
111
112/*----------------------------------------------------------------------------*/
120/*----------------------------------------------------------------------------*/
121
122static cpl_error_code eris_nix_img_hdrl_stack_fill_parameterlist(
123 cpl_parameterlist * self) {
124
125 if (cpl_error_get_code() != CPL_ERROR_NONE) return cpl_error_get_code();
126
127 hdrl_parameter * catalogue_defaults = NULL;
128 cpl_parameterlist * catalogue_parlist = NULL;
129 cpl_parameter * p = NULL;
130
131 /* The lower rejection threshold to be used during stacking */
132/*
133 p = cpl_parameter_new_range(CONTEXT".stk_lthr", CPL_TYPE_DOUBLE,
134 "Low rejection threshold", CONTEXT,
135 5.0, 1.0e-6, 1.0e10);
136 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "stk-lthr");
137 cpl_parameterlist_append(self, p);
138*/
139 /* The upper rejection threshold to be used during stacking */
140/*
141 p = cpl_parameter_new_range(CONTEXT".stk_hthr", CPL_TYPE_DOUBLE,
142 "Upper rejection threshold", CONTEXT,
143 5.0, 1.0e-6, 1.0e10);
144 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "stk-hthr");
145 cpl_parameterlist_append(self, p);
146*/
147 /* Interpolation method */
148
149 eris_nix_hdrl_stack_param_set(CONTEXT, self);
150
151
152 /* generate the general parameter list for the catalogue */
153
154 catalogue_defaults = hdrl_catalogue_parameter_create(4, 2.5, CPL_TRUE,
155 10.0, CPL_TRUE, 64, 2.0, 3.0,
156 ERIS_NIX_SATURATION_DEFAULT, HDRL_CATALOGUE_ALL);
157 catalogue_parlist = hdrl_catalogue_parameter_create_parlist(CONTEXT,
158 "catalogue", catalogue_defaults);
159
160 /* subset the parameters to be used */
161
162 for (p = cpl_parameterlist_get_first(catalogue_parlist);
163 p != NULL;
164 p = cpl_parameterlist_get_next(catalogue_parlist)) {
165
166 const char * pname = cpl_parameter_get_name(p);
167 if (strstr(pname, "minmax") == NULL) {
168 cpl_parameter * duplicate = cpl_parameter_duplicate(p);
169 cpl_parameterlist_append(self, duplicate);
170 }
171 }
172
173 /* ..add ao-params which specifies how to set params depending on AO */
174
175 p = cpl_parameter_new_enum(CONTEXT".catalogue.ao-params",
176 CPL_TYPE_STRING,
177 "Default catalogue.core-radius and "
178 "catalogue.mesh-size depending on "
179 "AOMODE, or not",
180 CONTEXT,
181 "auto", 2, "auto", "user");
182 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "catalogue.ao-params");
183 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
184 cpl_parameterlist_append(self, p);
185
186 p = cpl_parameter_new_value(CONTEXT".debug-data",
187 CPL_TYPE_BOOL, "true to save interim results",
188 CONTEXT, CPL_FALSE);
189 cpl_parameter_set_alias(p, CPL_PARAMETER_MODE_CLI, "debug-data");
190 cpl_parameter_disable(p, CPL_PARAMETER_MODE_ENV);
191 cpl_parameterlist_append(self, p);
192
193 /* tidy up */
194
195 hdrl_parameter_delete(catalogue_defaults);
196 cpl_parameterlist_delete(catalogue_parlist);
197
198 return 0;
199}
200
201/*----------------------------------------------------------------------------*/
208/*----------------------------------------------------------------------------*/
209
210static int eris_nix_img_hdrl_stack(cpl_frameset * frameset,
211 const cpl_parameterlist * parlist) {
212
213
214 eris_nix_scired_hdrl_stack(frameset, parlist, RECIPE_NAME, CONTEXT);
215
216 return (int)cpl_error_get_code();
217}
cpl_error_code eris_nix_scired_hdrl_stack(cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *recipe_name, const char *context)
This rebin and stack a set of calibrated ERIS/NIX jitter 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