ERIS Pipeline Reference Manual 1.9.2
recipes/eris_ifu_strehl.c
1/*
2 * This file is part of the HDRLDEMO pipeline
3 * Copyright (C) 2014 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23
24/*-----------------------------------------------------------------------------
25 Includes
26 -----------------------------------------------------------------------------*/
27
28#include <hdrl.h>
29
30#include <hdrl_utils.h>
31#include <eris_ifu_dfs.h>
32#include <eris_ifu_strehl.h>
33#include <cpl.h>
34
35
36#define HDRLDEMO_RAW_BPM "RAW_BPM"
37#define HDRLDEMO_RAW_ERROR "RAW_ERROR"
40/*-----------------------------------------------------------------------------
41 Functions prototypes
42 -----------------------------------------------------------------------------*/
43/*-----------------------------------------------------------------------------
44 Static global variables
45 -----------------------------------------------------------------------------*/
46
47#define RECIPE_NAME "eris_ifu_strehl"
48
49static char eris_ifu_strehl_description[] =
50" \n"
51"The recipe computes the Strehl on individual bias subtracted images. \n"
52" \n"
53"Input files: \n"
54" \n"
55" DO category: Explanation: Required: \n"
56" RAW Data Yes \n"
57" RAW_BPM Bad Pixel Mask No \n"
58" RAW_ERROR Associated Error No \n"
59" \n"
60"Output files: \n"
61" \n"
62" DO category: Explanation: \n"
63" ERIS_IFU_STREHL Fitsfile containing strehl as QC param \n"
64" \n"
65"Usage of the recipe: \n"
66" \n"
67"There is currently one method implemented: \n"
68" \n"
69"The recipe assumes that the input raw image contains a single object \n"
70"and it is already pre-processed. This means that the instrument \n"
71"signature has been removed and the contribute from the sky background \n"
72"subtracted. Additionally, it allows the user to correct a residual \n"
73"local sky background evaluated in an annular region centred on the \n"
74"peak of the object PSF, by setting the values of the corresponding \n"
75"parameters (--bkg-radius-low, and --bkg-radius-high in arcsec units). \n"
76" \n"
77"The PSF is identified and its integrated flux, whose determination is \n"
78"controlled by the parameter --flux-radius (in arcsec), is normalized \n"
79"to unity. Next the PSF barycentre is computed and used to generate the \n"
80"theoretical normalised PSF. This depends on i) the telescope pupil \n"
81"characteristics (telescope radius and central obstruction parameters, \n"
82"controlled by --m1, and --m2 in meter) ii) the wavelength (parameter \n"
83"--wavelength in meter) at which the image has been obtained and iii) \n"
84"the detector pixel scale on sky in arcsec (--pixel-scale-x, and \n"
85"--pixel-scale-y). \n"
86" \n"
87"Then the Strehl ratio is obtained by dividing the maximum intensity of \n"
88"the image PSF by the maximum intensity of the ideal PSF. \n"
89" \n"
90"Please note that if no error image is provided, the error is estimated \n"
91"by measuring the MAD (scaled to an rms) on the input image, i.e. each \n"
92"pixel has the same associated error. \n"
93" \n";
94/* TODO:
95 * consistency checks on input parameters.
96 * Make sure psf size is at least 1x1 pixels
97 * Test without errors
98 * Add gain and ron input parameters for error model
99 */
100/* Standard CPL recipe definition */
101cpl_recipe_define(eris_ifu_strehl, ERIS_BINARY_VERSION, "Andrea Modigliani",
102 PACKAGE_BUGREPORT, "2022", "Computes Strehl",
103 eris_ifu_strehl_description);
104
105/*----------------------------------------------------------------------------*/
111/*----------------------------------------------------------------------------*/
112
113static cpl_error_code eris_ifu_strehl_fill_parameterlist(
114 cpl_parameterlist * self)
115{
116 cpl_parameter * par ;
117
118 /* --eris_ifu_strehl.ext-nb-raw
119 par = cpl_parameter_new_value(RECIPE_NAME".ext-nb-raw", CPL_TYPE_INT,
120 "FITS extension of the RAW", RECIPE_NAME, 0);
121 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI, "ext-r");
122 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
123 cpl_parameterlist_append(self, par);
124 */
125
126 /* --eris_ifu_strehl.ext-nb-raw-err
127 par = cpl_parameter_new_value(RECIPE_NAME".ext-nb-raw-err", CPL_TYPE_INT,
128 "FITS extension of the ERROR", RECIPE_NAME, 0);
129 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI, "ext-e");
130 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
131 cpl_parameterlist_append(self, par);
132 */
133
134 /* --eris_ifu_strehl.ext-nb-raw-bpm
135 par = cpl_parameter_new_value(RECIPE_NAME".ext-nb-raw-bpm", CPL_TYPE_INT,
136 "FITS extension or the input BPM", RECIPE_NAME, 0);
137 cpl_parameter_set_alias(par, CPL_PARAMETER_MODE_CLI, "ext-b");
138 cpl_parameter_disable(par, CPL_PARAMETER_MODE_ENV);
139 cpl_parameterlist_append(self, par);
140 */
141
142 /* --eris_ifu_strehl.region-llx/lly/urx/ury */
143 hdrl_parameter * deflts = hdrl_rect_region_parameter_create(1, 1, 0, 0) ;
144 cpl_parameterlist * reg_param = hdrl_rect_region_parameter_create_parlist(
145 RECIPE_NAME, "", "region-", deflts);
146 hdrl_parameter_delete(deflts) ;
147 for (cpl_parameter * p = cpl_parameterlist_get_first(reg_param) ;
148 p != NULL; p = cpl_parameterlist_get_next(reg_param))
149 cpl_parameterlist_append(self, cpl_parameter_duplicate(p));
150 cpl_parameterlist_delete(reg_param);
151
152
153 hdrl_parameter * s_def =
155 5.08/2, 1.8288/2,
156 0.0165966, 0.0165966,
157 1.5, -1 , -1);
158
159 cpl_parameterlist * s_param =
160 hdrl_strehl_parameter_create_parlist(RECIPE_NAME, "", s_def);
161 hdrl_parameter_delete(s_def) ;
162 for (cpl_parameter * p = cpl_parameterlist_get_first(s_param);
163 p != NULL; p = cpl_parameterlist_get_next(s_param))
164 cpl_parameterlist_append(self, cpl_parameter_duplicate(p));
165 cpl_parameterlist_delete(s_param);
166
167 return CPL_ERROR_NONE;
168}
169/*----------------------------------------------------------------------------*/
175/*----------------------------------------------------------------------------*/
176
177static int eris_ifu_strehl(
178 cpl_frameset * frameset,
179 const cpl_parameterlist * parlist)
180{
181 eris_ifu_strehl_compute(frameset, parlist, RECIPE_NAME);
182
183 return (int)cpl_error_get_code();
184}
185
186
187
188
void hdrl_parameter_delete(hdrl_parameter *obj)
shallow delete of a parameter
cpl_parameterlist * hdrl_strehl_parameter_create_parlist(const char *base_context, const char *prefix, hdrl_parameter *par)
Create parameter list for the Strehl computation.
Definition: hdrl_strehl.c:360
hdrl_parameter * hdrl_strehl_parameter_create(double wavelength, double m1_radius, double m2_radius, double pixel_scale_x, double pixel_scale_y, double flux_radius, double bkg_radius_low, double bkg_radius_high)
Creates Strehl Parameters object.
Definition: hdrl_strehl.c:188
cpl_parameterlist * hdrl_rect_region_parameter_create_parlist(const char *base_context, const char *prefix, const char *name_prefix, const hdrl_parameter *defaults)
Create parameter list for hdrl_rect_region.
Definition: hdrl_utils.c:615
hdrl_parameter * hdrl_rect_region_parameter_create(cpl_size llx, cpl_size lly, cpl_size urx, cpl_size ury)
Creates Rect Region Parameters object.
Definition: hdrl_utils.c:459