IIINSTRUMENT Pipeline Reference Manual 4.5.1
visir_inputs.h
1/* $Id: visir_inputs.h,v 1.55 2013-02-21 16:39:11 jtaylor Exp $
2 *
3 * This file is part of the VISIR 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: jtaylor $
23 * $Date: 2013-02-21 16:39:11 $
24 * $Revision: 1.55 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef VISIR_INPUTS_H
29#define VISIR_INPUTS_H
30
31/*-----------------------------------------------------------------------------
32 Includes
33 -----------------------------------------------------------------------------*/
34
35#include <cpl.h>
36#include <cxlist.h> /* for cx_list */
37
38#include "irplib_framelist.h"
39
40#include "visir_spc_optmod.h"
41
42/*-----------------------------------------------------------------------------
43 Define
44 -----------------------------------------------------------------------------*/
45
46/* The values range from 0 (or 1) to 2**16-1 (or 2**16) */
47#define VISIR_HCYCLE_BPM_THRESHOLD 65000.0
48
49/* Due to a inconsistency in the chosen VISIR FITS-format the pixels in
50 the half-cycle image are offset, such that the lowest pixel value is
51 -32768 (or perhaps -32767?). This is fixed by adding 32768 to each
52 pixel value */
53#define VISIR_HCYCLE_OFFSET 32768.0
54
55typedef enum {
56 /* VISIR nod/chopping mode detection */
57
58 /* Mode can be assumed to be: PERPENDICULAR */
59 VISIR_CHOPNOD_PERPENDICULAR,
60
61 /* Mode can be assumed to be: PARALLEL */
62 VISIR_CHOPNOD_PARALLEL,
63
64 /* Mode is determined from FITS header */
65 VISIR_CHOPNOD_AUTO
66
67} visir_chopnod_mode;
68
69typedef enum {
70 VISIR_ERROR,
71 VISIR_VARIANCE,
72 VISIR_WEIGHT
73} visir_error_type;
74
75typedef enum {
76 VISIR_DATA_CUBE1,
77 VISIR_DATA_CUBE2,
78 VISIR_DATA_BURST,
79 VISIR_DATA_AQU_HCYCLE,
80 VISIR_DATA_AQU_BURST,
81 VISIR_DATA_AQU_BURST_EXT,
82 /* only INT frame, no half cycles, format of an 2015 commissioning, can
83 * probably be removed in future */
84 VISIR_DATA_AQU_INT,
85} visir_data_type;
86
87typedef enum {
88 VISIR_EXTRACT_METHOD_UNKNOWN = 0,
89 VISIR_EXTRACT_METHOD_APERTURE = 'A',
90 VISIR_EXTRACT_METHOD_OPTIMAL = 'O',
91} visir_extract_t;
92
93typedef enum {
94 VISIR_SKY_METHOD_UNKNOWN = 0,
95 VISIR_SKY_METHOD_AVERAGE = 'A',
96 VISIR_SKY_METHOD_LINFIT = 'F',
97 VISIR_SKY_METHOD_MEDIAN = 'M',
98} visir_sky_t;
99
100typedef struct { int l, r; } visir_aplimits;
101typedef struct {
102 size_t nlimits;
103 int ident;
104 visir_extract_t extract_method;
105 visir_sky_t sky_method;
106 visir_aplimits* limits;
107} visir_apdefs;
108
109static inline void
110visir_apdefs_delete(visir_apdefs* apdefs)
111{
112 cpl_free(apdefs->limits);
113 cpl_free(apdefs);
114}
115
116static inline visir_apdefs*
117visir_apdefs_new(const size_t n, int ident, visir_extract_t emethod, visir_sky_t smethod)
118{
119 visir_apdefs* apdefs = cpl_malloc(sizeof(visir_apdefs));
120 apdefs->nlimits = n;
121 apdefs->ident = ident;
122 apdefs->extract_method = emethod;
123 apdefs->sky_method = smethod;
124 apdefs->limits = cpl_calloc(n, sizeof(visir_aplimits));
125 return apdefs;
126}
127
128typedef cx_list visir_aplist; // a list of visir_apdefs
129void visir_aplist_destroy(visir_aplist * list);
130#define visir_aplist_delete cx_list_delete
131#define visir_aplist_new cx_list_new
132#define visir_aplist_push_back cx_list_push_back
133#define visir_aplist_size cx_list_size
134
135static inline cpl_boolean
136visir_data_is_aqu(const visir_data_type dtype)
137{
138 return dtype == VISIR_DATA_AQU_HCYCLE || dtype == VISIR_DATA_AQU_BURST ||
139 dtype == VISIR_DATA_AQU_BURST_EXT || dtype == VISIR_DATA_AQU_INT;
140}
141
142static inline cpl_boolean
143visir_data_is_drs(const visir_data_type dtype)
144{
145 return !visir_data_is_aqu(dtype);
146}
147
148static inline cpl_boolean
149visir_data_is_burst(const visir_data_type dtype)
150{
151 return dtype == VISIR_DATA_BURST || dtype == VISIR_DATA_AQU_BURST ||
152 dtype == VISIR_DATA_AQU_BURST_EXT;
153}
154
155
156/*-----------------------------------------------------------------------------
157 Functions prototypes
158 -----------------------------------------------------------------------------*/
159
160cpl_imagelist * visir_inputs_combine(const char *, const cpl_parameterlist *,
161 const irplib_framelist *, const char *,
162 const char *, int *, cpl_boolean,
163 double, visir_spc_resol);
164cpl_image ** visir_img_recombine_list(const char *,
165 const cpl_parameterlist *,
166 cpl_imagelist *,
167 const cpl_propertylist **,
168 cpl_geom_combine, cpl_boolean *);
169cpl_image ** visir_img_recombine(const char *, const cpl_parameterlist *,
170 const irplib_framelist *, const char *,
171 const char *, cpl_geom_combine, cpl_boolean *,
172 cpl_boolean, double, visir_spc_resol);
173cpl_imagelist * visir_load_imagelist(const irplib_framelist *, int,
174 cpl_boolean);
175cpl_imagelist * visir_load_hcycle(const irplib_framelist *, int);
176
177visir_aplist * visir_aplist_new_from_file(const char *);
178visir_apdefs * visir_apdefs_new_from_line(char *, int);
179char * visir_apdefs_dump(const visir_apdefs *);
180
181cpl_error_code visir_image_reject_hot(cpl_image *, const char *);
182
183cpl_imagelist * visir_imagelist_load_last(const irplib_framelist *);
184
185cpl_image ** visir_img_collapse_beam(cpl_propertylist *,
186 const cpl_image *,
187 const cpl_parameterlist *,
188 const char *,
189 visir_chopnod_mode,
190 const cpl_propertylist *);
191
192double visir_img_check_box(const cpl_apertures *, int, int,
193 const cpl_apertures *, int, int,
194 double, double, cpl_boolean *, cpl_boolean *);
195
196double visir_img_check_align(const cpl_apertures *, int,
197 const cpl_apertures *, int, int,
198 double, double,
199 cpl_boolean *);
200
201double visir_img_check_line(const cpl_apertures *, int,
202 const cpl_apertures *, int,
203 double, double);
204
205cpl_error_code visir_get_data_type(const cpl_frame * frame,
206 const cpl_propertylist * plist,
207 visir_data_type * ptype, cpl_size * pnext);
208
209cpl_bivector * visir_load_lintable(cpl_frame * linframe, cpl_boolean is_spec);
210
211cpl_image *
212visir_load_bpm(cpl_frame * frm, visir_data_type dtype, cpl_boolean is_spec);
213
214cpl_error_code visir_load_cube2_split(cpl_imagelist *, cpl_imagelist *,
215 const irplib_framelist *, const int,
216 const int, const int);
217
218cpl_error_code visir_load_burst(cpl_imagelist *, cpl_imagelist *,
219 const cpl_frame *, const cpl_propertylist *,
220 const int, const int, const int, const int,
221 const int, const int);
222cpl_error_code visir_load_burst_aqu(cpl_imagelist *, cpl_imagelist *,
223 const cpl_frame *, const cpl_propertylist *,
224 const int, const int, const int);
225
226cpl_error_code visir_img_burst_find_delta_chop(const cpl_propertylist *,
227 int *, int *);
228
229
230visir_chopnod_mode visir_img_find_beam(cpl_propertylist *,
231 const cpl_image *,
232 const cpl_image *,
233 const cpl_propertylist *,
234 const cpl_parameterlist *,
235 const char *,
236 double [],
237 double []);
238
239cpl_error_code visir_img_find_beam_two(cpl_propertylist *, const cpl_image *,
240 const cpl_image *, double, double, double,
241 double [], double []);
242
243#endif
cpl_image ** visir_img_recombine_list(const char *, const cpl_parameterlist *, cpl_imagelist *, const cpl_propertylist **, cpl_geom_combine, cpl_boolean *)
The VISIR imaging combination using cross correlation.
cpl_imagelist * visir_load_hcycle(const irplib_framelist *, int)
Load the HCYCLE images from a VISIR file.
cpl_image ** visir_img_collapse_beam(cpl_propertylist *, const cpl_image *, const cpl_parameterlist *, const char *, visir_chopnod_mode, const cpl_propertylist *)
Collapse the 3/4 beams of a combined image.
Definition: visir_inputs.c:613
cpl_imagelist * visir_imagelist_load_last(const irplib_framelist *)
Load the last frame of the input files to an image list.
cpl_error_code visir_load_cube2_split(cpl_imagelist *, cpl_imagelist *, const irplib_framelist *, const int, const int, const int)
Load and split the data in a CUBE2 file.
Definition: visir_inputs.c:242
cpl_imagelist * visir_inputs_combine(const char *, const cpl_parameterlist *, const irplib_framelist *, const char *, const char *, int *, cpl_boolean, double, visir_spc_resol)
The VISIR input data re-combination is performed here.
Definition: visir_inputs.c:795
cpl_imagelist * visir_load_imagelist(const irplib_framelist *, int, cpl_boolean)
Load either a INTERM or Half-Cycle cube from a VISIR file.
visir_apdefs * visir_apdefs_new_from_line(char *, int)
Parse a line from the user-supplied apertures definition file, creating a new visir_apdefs object.
char * visir_apdefs_dump(const visir_apdefs *)
Convert an aperture definition into its string representation.
cpl_image ** visir_img_recombine(const char *, const cpl_parameterlist *, const irplib_framelist *, const char *, const char *, cpl_geom_combine, cpl_boolean *, cpl_boolean, double, visir_spc_resol)
The VISIR imaging combination using cross correlation.
visir_aplist * visir_aplist_new_from_file(const char *)
Load the user-supplied apertures definition file.
cpl_bivector * visir_load_lintable(cpl_frame *linframe, cpl_boolean is_spec)
load and normalize linearity table into a bivector
Definition: visir_inputs.c:536
cpl_error_code visir_image_reject_hot(cpl_image *, const char *)
Reject the hot pixels in an image.