IIINSTRUMENT Pipeline Reference Manual 4.4.12
naco_strehl.c
1/* $Id: naco_strehl.c,v 1.22 2008-04-18 00:25:30 llundin Exp $
2 *
3 * This file is part of the NACO 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: 2008-04-18 00:25:30 $
24 * $Revision: 1.22 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#define HDRL_USE_EXPERIMENTAL
29
30/*-----------------------------------------------------------------------------
31 Includes
32 -----------------------------------------------------------------------------*/
33
34#ifdef HAVE_CONFIG_H
35#include <config.h>
36#endif
37
38#include "naco_strehl.h"
39#include "naco_parameter.h"
40
41#include "irplib_strehl.h"
42
43#ifdef HDRL_USE_EXPERIMENTAL
44#include "hdrl.h"
45#endif
46
47/*----------------------------------------------------------------------------*/
53/*----------------------------------------------------------------------------*/
54
57/*----------------------------------------------------------------------------*/
79/*----------------------------------------------------------------------------*/
80cpl_error_code naco_strehl_compute(const cpl_image * self,
81 const cpl_parameterlist * parlist,
82 const char * recipename,
83 double lam,
84 double dlam,
85 double pos_x,
86 double pos_y,
87 double pixscale,
88 double * pstrehl,
89 double * pstrehl_err,
90 double * pstar_bg,
91 double * pstar_peak,
92 double * pstar_flux,
93 double * ppsf_peak,
94 double * ppsf_flux,
95 double * pbg_noise)
96{
97
98 cpl_errorstate cleanstate = cpl_errorstate_get();
99 const double r1 = naco_parameterlist_get_double(parlist, recipename,
100 NACO_PARAM_STAR_R);
101 const double r2 = naco_parameterlist_get_double(parlist, recipename,
102 NACO_PARAM_BG_RINT);
103 const double r3 = naco_parameterlist_get_double(parlist, recipename,
104 NACO_PARAM_BG_REXT);
105
106#ifdef HDRL_USE_EXPERIMENTAL
107 hdrl_parameter * hdrl_param = NULL;
108 hdrl_strehl_result hdrl_strehl;
109 hdrl_image * hdrl_self = NULL;
110
111 hdrl_strehl.strehl_value.data = 0.0;
112
113#endif
114
115 skip_if(irplib_strehl_compute(self,
116 IRPLIB_STREHL_M1, IRPLIB_STREHL_M2,
117 lam, dlam,
118 pixscale,
119 IRPLIB_STREHL_BOX_SIZE,
120 pos_x,
121 pos_y,
122 r1, r2, r3,
123 -1, -1,
124 pstrehl,
125 pstrehl_err,
126 pstar_bg,
127 pstar_peak,
128 pstar_flux,
129 ppsf_peak,
130 ppsf_flux,
131 pbg_noise));
132
133#ifdef HDRL_USE_EXPERIMENTAL
134
135 hdrl_self = hdrl_image_create(self, NULL);
136
137 skip_if (hdrl_self == NULL);
138
139 /* HDRL uses SI (m) and the mirror dimensions are given as radii */
140 hdrl_param = hdrl_strehl_parameter_create(lam * 1e-6,
141 IRPLIB_STREHL_M1 * 0.5,
142 IRPLIB_STREHL_M2 * 0.5,
143 pixscale, pixscale,
144 r1, r2, r3);
145 if (hdrl_param != NULL)
146 hdrl_strehl = hdrl_strehl_compute(hdrl_self, hdrl_param);
147
148 if (!cpl_errorstate_is_equal(cleanstate)) {
149 irplib_error_recover(cleanstate, "HDRL Strehl computation failed "
150 "(keeping %g)", *pstrehl);
151 } else if (0.0 < *pstrehl && *pstrehl < 1.0 &&
152 (hdrl_strehl.strehl_value.data <= 0.0 ||
153 hdrl_strehl.strehl_value.data >= 1.0)) {
154 cpl_msg_warning(cpl_func, "Ignoring suspicious HDRL Strehl: %g "
155 "(keeping %g)", hdrl_strehl.strehl_value.data,
156 *pstrehl);
157 } else {
158 cpl_msg_info(cpl_func, "Changing Strehl: %g -> %g",
159 *pstrehl, hdrl_strehl.strehl_value.data);
160 *pstrehl = hdrl_strehl.strehl_value.data;
161 }
162
163#endif
164
165 end_skip;
166
167#ifdef HDRL_USE_EXPERIMENTAL
168 hdrl_parameter_delete(hdrl_param);
169 hdrl_image_delete(hdrl_self);
170#endif
171
172 return cpl_error_get_code();
173}
174
double naco_parameterlist_get_double(const cpl_parameterlist *self, const char *recipe, naco_parameter bitmask)
Retrieve the value of a NACO parameter of type double.
cpl_error_code naco_strehl_compute(const cpl_image *self, const cpl_parameterlist *parlist, const char *recipename, double lam, double dlam, double pos_x, double pos_y, double pixscale, double *pstrehl, double *pstrehl_err, double *pstar_bg, double *pstar_peak, double *pstar_flux, double *ppsf_peak, double *ppsf_flux, double *pbg_noise)
Compute the strehl ratio in an image.
Definition: naco_strehl.c:80