High-Level Data Reduction Library: hdrl_resample.h Source File

High-Level Data Reduction Library 1.6.0 High-Level data reduction routines for ESO pipelines

Loading...
Searching...
No Matches
hdrl_resample.h
Go to the documentation of this file.
1/*
2 * This file is part of the HDRL
3 * Copyright (C) 2020 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#ifndef HDRL_RESAMPLE_H
21#define HDRL_RESAMPLE_H
22
23/*-----------------------------------------------------------------------------
24 Includes
25 -----------------------------------------------------------------------------*/
26
27#include <cpl.h>
28#include <hdrl_parameter.h>
29CPL_BEGIN_DECLS
30
31/*-----------------------------------------------------------------------------
32 Defines
33 -----------------------------------------------------------------------------*/
34
35 /* Table columns of the resampling table. */
36
37#define HDRL_RESAMPLE_TABLE_RA "ra" /* Right ascension column of the table*/
38#define HDRL_RESAMPLE_TABLE_DEC "dec" /* Declination column of the table*/
39#define HDRL_RESAMPLE_TABLE_LAMBDA "lambda" /* wavelength column of the table */
40#define HDRL_RESAMPLE_TABLE_DATA "data" /* data column of the table */
41#define HDRL_RESAMPLE_TABLE_BPM "bpm" /* bpm column of the table */
42#define HDRL_RESAMPLE_TABLE_ERRORS "errors" /* error column of the table */
43
44/* Right ascension column type of the table*/
45#define HDRL_RESAMPLE_TABLE_RA_TYPE CPL_TYPE_DOUBLE
46/* Declination column type of the table*/
47#define HDRL_RESAMPLE_TABLE_DEC_TYPE CPL_TYPE_DOUBLE
48/* wavelength column type of the table */
49#define HDRL_RESAMPLE_TABLE_LAMBDA_TYPE CPL_TYPE_DOUBLE
50/* data column type of the table */
51#define HDRL_RESAMPLE_TABLE_DATA_TYPE CPL_TYPE_DOUBLE
52/* bpm column type of the table */
53#define HDRL_RESAMPLE_TABLE_BPM_TYPE CPL_TYPE_INT
54/* error type column of the table */
55#define HDRL_RESAMPLE_TABLE_ERRORS_TYPE CPL_TYPE_DOUBLE
56
57 typedef enum {
58 HDRL_RESAMPLE_METHOD_NEAREST = 0,
59 HDRL_RESAMPLE_METHOD_RENKA = 1,
60 HDRL_RESAMPLE_METHOD_LINEAR,
61 HDRL_RESAMPLE_METHOD_QUADRATIC,
62 HDRL_RESAMPLE_METHOD_DRIZZLE,
63 HDRL_RESAMPLE_METHOD_LANCZOS,
64 HDRL_RESAMPLE_METHOD_NONE /* Can be used for range checking */
65} hdrl_resample_method ;
66
67 typedef enum {
68 HDRL_RESAMPLE_OUTGRID_2D,
69 HDRL_RESAMPLE_OUTGRID_3D
70} hdrl_resample_outgrid ;
71
72 typedef struct {
73 cpl_propertylist * header; /* cpl propertylist containing the wcs informations */
74 hdrl_imagelist * himlist; /* hdrl imagelist containing the data/errors/bpm */
75} hdrl_resample_result;
76
77/*----------------------------------------------------------------------------
78 RESAMPLING Computation
79 ----------------------------------------------------------------------------*/
80
81cpl_table*
82 hdrl_resample_imagelist_to_table(const hdrl_imagelist * himlist,
83 const cpl_wcs* wcs);
84cpl_table*
85 hdrl_resample_image_to_table(const hdrl_image * hima, const cpl_wcs* wcs);
86
87 hdrl_resample_result *
88 hdrl_resample_compute(const cpl_table *restable,
89 hdrl_parameter *method,
90 hdrl_parameter *outputgrid,
91 const cpl_wcs* wcs);
92
93 void
94 hdrl_resample_result_delete(hdrl_resample_result *resdata);
95
96/*----------------------------------------------------------------------------
97 RESAMPLING Parameters for output definition
98 ----------------------------------------------------------------------------*/
99
100 hdrl_parameter*
101 hdrl_resample_parameter_create_outgrid2D(const double delta_ra,
102 const double delta_dec);
103
104 hdrl_parameter*
105 hdrl_resample_parameter_create_outgrid3D(const double delta_ra,
106 const double delta_dec,
107 const double delta_lambda);
108
109 hdrl_parameter*
110 hdrl_resample_parameter_create_outgrid2D_userdef(const double delta_ra,
111 const double delta_dec,
112 const double ra_min,
113 const double ra_max,
114 const double dec_min,
115 const double dec_max,
116 const double fieldmargin);
117
118 hdrl_parameter*
119 hdrl_resample_parameter_create_outgrid3D_userdef(const double delta_ra,
120 const double delta_dec,
121 const double delta_lambda,
122 const double ra_min,
123 const double ra_max,
124 const double dec_min,
125 const double dec_max,
126 const double lambda_min,
127 const double lambda_max,
128 const double fieldmargin);
129
130/*----------------------------------------------------------------------------
131 RESAMPLING Parameters for method definition
132 ----------------------------------------------------------------------------*/
133
134 hdrl_parameter*
135 hdrl_resample_parameter_create_renka(const int loop_distance,
136 cpl_boolean use_errorweights,
137 const double critical_radius);
138 hdrl_parameter*
139 hdrl_resample_parameter_create_drizzle(const int loop_distance,
140 cpl_boolean use_errorweights,
141 const double pix_frac_x,
142 const double pix_frac_y,
143 const double pix_frac_lambda);
144
145 hdrl_parameter*
146 hdrl_resample_parameter_create_nearest(void);
147
148 hdrl_parameter*
149 hdrl_resample_parameter_create_linear(const int loop_distance,
150 cpl_boolean use_errorweights);
151
152 hdrl_parameter*
153 hdrl_resample_parameter_create_quadratic(const int loop_distance,
154 cpl_boolean use_errorweights);
155
156 hdrl_parameter*
157 hdrl_resample_parameter_create_lanczos(const int loop_distance,
158 cpl_boolean use_errorweights,
159 const int kernel_size);
160
161/*----------------------------------------------------------------------------
162 Checks and verifications for the RESAMPLING Parameters
163 ----------------------------------------------------------------------------*/
164
165cpl_error_code
166 hdrl_resample_parameter_outgrid_verify(const hdrl_parameter * hp);
167cpl_error_code
168 hdrl_resample_parameter_method_verify(const hdrl_parameter * hp);
169 int
170 hdrl_resample_parameter_outgrid_check(const hdrl_parameter * self);
171 int
172 hdrl_resample_parameter_method_check(const hdrl_parameter * hp);
173
174/*-----------------------------------------------------------------------------
175 Private declarations - must not be used outside of hdrl
176 -----------------------------------------------------------------------------*/
177
178#ifdef HDRL_USE_PRIVATE
179
180/* Helper Functions */
181
182cpl_error_code
183hdrl_wcs_xy_to_radec(const cpl_wcs *wcs, double x, double y,
184 double *ra, double *dec);
185
186cpl_error_code
187hdrl_wcs_to_propertylist(const cpl_wcs * wcs, cpl_propertylist * header,
188 cpl_boolean only2d);
189
190#endif
191CPL_END_DECLS
192
193#endif /* RECIPES_HDRL_RESAMPLE_H_ */
hdrl_resample_outgrid
hdrl_resample_outgrid
Definition hdrl_resample.h:67
HDRL_RESAMPLE_OUTGRID_3D
@ HDRL_RESAMPLE_OUTGRID_3D
Definition hdrl_resample.h:69
HDRL_RESAMPLE_OUTGRID_2D
@ HDRL_RESAMPLE_OUTGRID_2D
Definition hdrl_resample.h:68
hdrl_resample_method
hdrl_resample_method
Definition hdrl_resample.h:57
HDRL_RESAMPLE_METHOD_NONE
@ HDRL_RESAMPLE_METHOD_NONE
Definition hdrl_resample.h:64
HDRL_RESAMPLE_METHOD_RENKA
@ HDRL_RESAMPLE_METHOD_RENKA
Definition hdrl_resample.h:59
HDRL_RESAMPLE_METHOD_DRIZZLE
@ HDRL_RESAMPLE_METHOD_DRIZZLE
Definition hdrl_resample.h:62
HDRL_RESAMPLE_METHOD_LANCZOS
@ HDRL_RESAMPLE_METHOD_LANCZOS
Definition hdrl_resample.h:63
HDRL_RESAMPLE_METHOD_LINEAR
@ HDRL_RESAMPLE_METHOD_LINEAR
Definition hdrl_resample.h:60
HDRL_RESAMPLE_METHOD_QUADRATIC
@ HDRL_RESAMPLE_METHOD_QUADRATIC
Definition hdrl_resample.h:61
HDRL_RESAMPLE_METHOD_NEAREST
@ HDRL_RESAMPLE_METHOD_NEAREST
Definition hdrl_resample.h:58
hdrl_parameter.h
hdrl_parameter
struct _hdrl_parameter_ hdrl_parameter
Definition hdrl_parameter.h:27
hdrl_resample_compute
hdrl_resample_result * hdrl_resample_compute(const cpl_table *restable, hdrl_parameter *method, hdrl_parameter *outputgrid, const cpl_wcs *wcs)
High level resampling function.
Definition hdrl_resample.c:735
hdrl_resample_result_delete
void hdrl_resample_result_delete(hdrl_resample_result *resdata)
Deallocates the memory associated to a hdrl_resample_result object.
Definition hdrl_resample.c:848
hdrl_resample_image_to_table
cpl_table * hdrl_resample_image_to_table(const hdrl_image *hima, const cpl_wcs *wcs)
Convert a hdrl image into a cpl table that can be given as input to hdrl_resample_compute()
Definition hdrl_resample.c:2605
hdrl_resample_imagelist_to_table
cpl_table * hdrl_resample_imagelist_to_table(const hdrl_imagelist *himlist, const cpl_wcs *wcs)
Convert a hdrl imagelist into a cpl table that can be given as input to hdrl_resample_compute().
Definition hdrl_resample.c:2635
hdrl_resample_parameter_create_nearest
hdrl_parameter * hdrl_resample_parameter_create_nearest(void)
Creates a resample nearest neighbor hdrl parameter object. The algorithm does not use any weighting f...
Definition hdrl_resample.c:3150
hdrl_resample_parameter_method_verify
cpl_error_code hdrl_resample_parameter_method_verify(const hdrl_parameter *hp)
verify parameters have proper values
Definition hdrl_resample.c:3381
hdrl_resample_parameter_method_check
int hdrl_resample_parameter_method_check(const hdrl_parameter *hp)
check method is of proper type
Definition hdrl_resample.c:3482
hdrl_resample_parameter_create_renka
hdrl_parameter * hdrl_resample_parameter_create_renka(const int loop_distance, cpl_boolean use_errorweights, const double critical_radius)
Creates a resample renka hdrl parameter object. The algorithm uses a modified Shepard-like distance w...
Definition hdrl_resample.c:3013
hdrl_resample_parameter_create_lanczos
hdrl_parameter * hdrl_resample_parameter_create_lanczos(const int loop_distance, cpl_boolean use_errorweights, const int kernel_size)
Creates a resample Lanczos hdrl parameter object. The algorithm uses a restricted SINC distance weigh...
Definition hdrl_resample.c:3198
hdrl_resample_parameter_create_drizzle
hdrl_parameter * hdrl_resample_parameter_create_drizzle(const int loop_distance, cpl_boolean use_errorweights, const double pix_frac_x, const double pix_frac_y, const double pix_frac_lambda)
Creates a resample drizzle hdrl parameter object. The algorithm uses a drizzle-like distance weightin...
Definition hdrl_resample.c:3253
hdrl_resample_parameter_create_quadratic
hdrl_parameter * hdrl_resample_parameter_create_quadratic(const int loop_distance, cpl_boolean use_errorweights)
Creates a resample quadratic hdrl parameter object. The algorithm uses a quadratic inverse distance w...
Definition hdrl_resample.c:3108
hdrl_resample_parameter_create_linear
hdrl_parameter * hdrl_resample_parameter_create_linear(const int loop_distance, cpl_boolean use_errorweights)
Creates a resample linear hdrl parameter object. The algorithm uses a linear inverse distance weighti...
Definition hdrl_resample.c:3060
hdrl_resample_parameter_create_outgrid3D
hdrl_parameter * hdrl_resample_parameter_create_outgrid3D(const double delta_ra, const double delta_dec, const double delta_lambda)
Creates a resample_outgrid hdrl parameter object for a 3 dimensional interpolation,...
Definition hdrl_resample.c:2819
hdrl_resample_parameter_create_outgrid3D_userdef
hdrl_parameter * hdrl_resample_parameter_create_outgrid3D_userdef(const double delta_ra, const double delta_dec, const double delta_lambda, const double ra_min, const double ra_max, const double dec_min, const double dec_max, const double lambda_min, const double lambda_max, const double fieldmargin)
Creates a resample_outgrid hdrl parameter object for a 3 dimensional interpolation,...
Definition hdrl_resample.c:2948
hdrl_resample_parameter_outgrid_check
int hdrl_resample_parameter_outgrid_check(const hdrl_parameter *self)
check method is of proper type
Definition hdrl_resample.c:3465
hdrl_resample_parameter_create_outgrid2D
hdrl_parameter * hdrl_resample_parameter_create_outgrid2D(const double delta_ra, const double delta_dec)
Creates a resample_outgrid hdrl parameter object for a 2 dimensional interpolation,...
Definition hdrl_resample.c:2757
hdrl_resample_parameter_create_outgrid2D_userdef
hdrl_parameter * hdrl_resample_parameter_create_outgrid2D_userdef(const double delta_ra, const double delta_dec, const double ra_min, const double ra_max, const double dec_min, const double dec_max, const double fieldmargin)
Creates a resample_outgrid hdrl parameter object for a 2 dimensional interpolation,...
Definition hdrl_resample.c:2879
hdrl_resample_parameter_outgrid_verify
cpl_error_code hdrl_resample_parameter_outgrid_verify(const hdrl_parameter *hp)
verify parameters have proper values
Definition hdrl_resample.c:3292
_hdrl_image_
Definition hdrl_image_defs.h:40
_hdrl_imagelist_
Definition hdrl_imagelist_defs.h:42
hdrl_resample_result
Definition hdrl_resample.h:72
hdrl_resample_result::himlist
hdrl_imagelist * himlist
Definition hdrl_resample.h:74
hdrl_resample_result::header
cpl_propertylist * header
Definition hdrl_resample.h:73