ERIS Pipeline Reference Manual 1.8.15
eris_nix_utils.h
1/* $Id$
2 *
3 * This file is part of the ERIS/NIX 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 * $Rev$
25 */
26
27#ifndef ERIS_NIX_UTILS_H
28#define ERIS_NIX_UTILS_H
29
30#ifdef HAVE_CONFIG_H
31#include <config.h>
32#endif
33
34/*-----------------------------------------------------------------------------
35 Includes
36 -----------------------------------------------------------------------------*/
37
38#include "eris_nix_defs.h"
39#include "eris_nix_detector.h"
40#include "eris_nix_master_bpm.h"
41#include "eris_nix_master_dark.h"
42#include "eris_nix_master_flat.h"
43#include "eris_nix_gain_linearity.h"
44#include "eris_nix_casu_match.h"
45#include <cpl.h>
46
47/*-----------------------------------------------------------------------------
48 Defines
49 -----------------------------------------------------------------------------*/
50
51#define MEF_EXTENSION_CONTAINING_IMAGE "ERIS_NIX_CPL_IMAGE"
52#define MEF_EXTENSION_CONTAINING_MASK "ERIS_NIX_CPL_MASK"
53#define MEF_EXTENSION_CONTAINING_TABLE "ERIS_NIX_CPL_TABLE"
54#define MEF_EXTENSION_CONTAINING_VECTOR "ERIS_NIX_CPL_VECTOR"
55
56/*-----------------------------------------------------------------------------
57 Prototypes
58 -----------------------------------------------------------------------------*/
59
60cpl_error_code enu_basic_calibrate(located_image * limage,
61 const int read_offsets,
62 const cpl_table * refine_wcs,
63 const master_dark * master_dark,
64 const gain_linearity * gain_linearity,
65 const master_flat * flatfield_1,
66 const master_flat * flatfield_2,
67 const master_bpm * master_bpm,
68 const int flag_mask,
69 const char * fill_rejected,
70 const double fill_value,
71 const cpl_size x_probe,
72 const cpl_size y_probe);
73
74cpl_error_code enu_basic_calibrate_himage(hdrl_image * himage,
75 cpl_image * confidence,
76 cpl_propertylist * plist,
77 const cpl_frame * frame,
78 const int read_offsets,
79 const master_dark * master_dark,
80 const gain_linearity * gain_linearity,
81 const master_flat * flatfield_1,
82 const master_flat * flatfield_2,
83 const master_bpm * master_bpm,
84 const int set_confidence,
85 const int flag_mask,
86 const char * fill_rejected,
87 const double fill_value,
88 const cpl_size x_probe,
89 const cpl_size y_probe);
90
91cpl_vector * enu_bracket_skys(const located_image * target,
92 const double timerange,
93 const located_imagelist * sky_pool,
94 const int debug);
95
96hdrl_image * enu_calc_flat(hdrl_imagelist * himlist,
97 const int min_coadds,
98 const hdrl_parameter * collapse_params,
99 const cpl_size filter_size_x,
100 const cpl_size filter_size_y,
101 const hdrl_flat_method method);
102
103cpl_error_code enu_calc_maglim(const located_image * limage,
104 const double photzp,
105 const double fwhm_pix,
106 double * abmaglim);
107
108cpl_error_code enu_calc_pixel_coords(cpl_table * catalogue,
109 const cpl_propertylist * wcs_plist);
110
111hdrl_catalogue_result * enu_catalogue_compute(const hdrl_image *,
112 const cpl_image *,
113 const cpl_wcs *,
114 hdrl_parameter *);
115
116cpl_error_code enu_catalogue_limlist(located_imagelist * limlist,
117 hdrl_parameter * cat_params);
118
119int enu_check_conformance(const cpl_propertylist *,
120 const cpl_propertylist *,
121 const char *);
122
123cpl_error_code enu_check_wcs(const located_image * limage);
124
125cpl_error_code enu_correct_wcs(const cpl_table * refcat,
126 const char * wcs_method,
127 const char * catalogue,
128 located_image * limage,
129 const double match_rad,
130 cpl_table ** matched_stds,
131 cpl_matrix ** xy_shift);
132
133cpl_error_code enu_debug_limlist_save(const int debug,
134 const located_imagelist * limlist,
135 const char * nameroot,
136 const char * recipename,
137 cpl_frameset * frameset,
138 const cpl_parameterlist * parlist,
139 const cpl_frameset * used);
140
141cpl_error_code enu_flat_save(const char * pro_catg,
142 const hdrl_image * flat,
143 const cpl_image * confidence,
144 const cpl_mask * cold_bpm,
145 cpl_frameset * frameset,
146 const cpl_parameterlist * parlist,
147 const char * filename,
148 const char * flat_save,
149 const cpl_propertylist* qclog);
150
151double enu_get_airmass(const cpl_propertylist * plist);
152
153cpl_error_code enu_get_rcore_and_mesh_size(const char * context,
154 const cpl_parameterlist * parlist,
155 const cpl_propertylist * plist,
156 double * core_radius,
157 int * mesh_size);
158
159const char * enu_get_det_mode(const cpl_propertylist * plist);
160
161double enu_get_dit(const cpl_propertylist * plist);
162
163const char * enu_get_filter(const cpl_propertylist * plist);
164
165double enu_get_filter_wavelength(const char * filter);
166
167const char * enu_get_license(void);
168
169cpl_error_code enu_get_ra_dec(const cpl_wcs * wcs,
170 double * ra,
171 double * dec);
172
173cpl_error_code enu_get_window_info(cpl_size * nx,
174 cpl_size * ny,
175 int * rot,
176 cpl_size * strx,
177 cpl_size * stry,
178 cpl_size * nx_chip,
179 cpl_size * ny_chip,
180 cpl_boolean * windowed,
181 const cpl_propertylist * plist);
182
183hdrl_catalogue_result * enu_hdrl_catalogue_result_duplicate(
184 const hdrl_catalogue_result *);
185
186cpl_error_code enu_himage_load_from_fits(const char *,
187 hdrl_image **,
188 mef_extension_list **,
189 cpl_propertylist **);
190
191cpl_image * enu_load_component(mef_extension * mef,
192 const char * dps_name,
193 const char * target_hduclas1,
194 const char * target_hduclas2);
195
196located_image * enu_load_limage_from_frame(const cpl_frame * frame,
197 cpl_image **, const cpl_boolean);
198
199mef_extension_list * enu_load_mef_components(const char * filename,
200 cpl_propertylist ** plist);
201
202located_image * enu_located_image_duplicate(const located_image *);
203
204void enu_located_image_delete(located_image *);
205
206void enu_located_imagelist_delete(located_imagelist *);
207
208located_imagelist * enu_located_imagelist_duplicate(
209 const located_imagelist *);
210
211located_imagelist * enu_limlist_load_from_frameset(cpl_frameset *,
212 const char *,
213 cpl_frameset *);
214
215cpl_error_code enu_located_imagelist_insert(located_imagelist *,
216 located_image *,
217 cpl_size);
218
219located_imagelist * enu_located_imagelist_new(cpl_size);
220
221located_image * enu_located_image_new(hdrl_image * himage,
222 hdrl_imagelist * himagelist,
223 cpl_image * confidence,
224 hdrl_image * bkg,
225 cpl_image * bkg_confidence,
226 cpl_propertylist * plist,
227 hdrl_catalogue_result * objects,
228 cpl_mask * object_mask,
229 hdrl_catalogue_result * wcs,
230 hdrl_catalogue_result * photom,
231 cpl_frame * frame);
232
233void enu_mef_extension_delete(mef_extension *);
234
235void enu_mef_extension_list_delete(mef_extension_list *);
236
237cpl_mask * enu_mef_extension_list_get_mask(mef_extension_list *,
238 const char *);
239
240mef_extension_list * enu_mef_extension_list_new(cpl_size);
241
242mef_extension * enu_mef_new_image(const char *,
243 const cpl_image *,
244 const cpl_propertylist *);
245
246mef_extension * enu_mef_new_mask(const char *,
247 const cpl_mask *,
248 const cpl_propertylist *);
249
250mef_extension * enu_mef_new_table(const char *,
251 const cpl_table *,
252 const cpl_propertylist *);
253
254mef_extension * enu_mef_new_vector(const char * name,
255 const cpl_vector * vector,
256 const cpl_propertylist * plist);
257
258cpl_error_code enu_mef_extension_save(const mef_extension *,
259 const char *,
260 const cpl_propertylist *,
261 unsigned);
262
263cpl_error_code enu_modify_CD_matrix(located_image * limage,
264 const cpl_table * refine_wcs);
265
266cpl_error_code enu_normalise_confidence(cpl_image * confidence);
267
268cpl_error_code enu_opm_limlist(const int obj_min_pixels,
269 const double obj_threshold,
270 const int bkg_mesh_size,
271 const double bkg_smooth_fwhm,
272 located_imagelist * limages);
273
274cpl_error_code enu_opm_lss_limlist(located_imagelist * limlist,
275 const int nsigma_cut);
276
277cpl_error_code enu_remove_read_offsets(hdrl_image * himage,
278 const cpl_propertylist * plist,
279 cpl_image * confidence,
280 const int set_confidence);
281
282char * enu_repreface(const char * filename,
283 const char * preface);
284
285cpl_error_code enu_sky_backgrounds(const char * method,
286 const char * select_method,
287 const double timerange,
288 const located_imagelist * target_data,
289 const located_imagelist * sky_data,
290 const cpl_size x_probe,
291 const cpl_size y_probe,
292 hdrl_imagelist ** sky_himagelist,
293 cpl_imagelist ** sky_confidence_list);
294
295cpl_error_code enu_sky_subtract_limlist(const char * method,
296 const char * select_method,
297 const double timerange,
298 const located_imagelist * sky_data,
299 const cpl_size x_probe,
300 const cpl_size y_probe,
301 located_imagelist * target_data);
302
303cpl_error_code enu_stack(located_imagelist * limages,
304 const double stk_lthr,
305 const double stk_hthr,
306 const char * stk_method,
307 const int stk_fast,
308 located_image ** result);
309
310double enu_get_tel_alt(const cpl_propertylist * plist);
311
312cpl_error_code eris_nix_get_badpix_qc_from_ima(const master_bpm * master_bpm,
313 cpl_propertylist * qc_list,
314 const char * prefix);
315
316cpl_propertylist * enu_raw_flats_qc(located_imagelist * lamp_on_limlist,
317 cpl_mask * bp_map_nl_mask,
318 const cpl_parameterlist * parlist,
319 const char * context,
320 const double threshold_pos,
321 const cpl_boolean verbose,
322 const cpl_boolean rescale_by_dit);
323
324#endif
325
326
located_image * enu_located_image_duplicate(const located_image *)
Make a deep copy of a located_image and its contents.
cpl_mask * enu_mef_extension_list_get_mask(mef_extension_list *, const char *)
Get a cpl_mask from a named mef_extension in a list.
cpl_vector * enu_bracket_skys(const located_image *target, const double timerange, const located_imagelist *sky_pool, const int debug)
Find images taken within a given time of a target image.
cpl_error_code enu_modify_CD_matrix(located_image *limage, const cpl_table *refine_wcs)
Update the CD matrix to reduce image distortion and rotation.
void enu_located_imagelist_delete(located_imagelist *)
Delete a located_imagelist and its contents.
cpl_error_code enu_located_imagelist_insert(located_imagelist *, located_image *, cpl_size)
Insert a located_image at a specified point in a located_imagelist.
void enu_mef_extension_delete(mef_extension *)
Delete a mef_extension and its contents.
cpl_error_code eris_nix_get_badpix_qc_from_ima(const master_bpm *master_bpm, cpl_propertylist *qc_list, const char *prefix)
Compute QC on input master bpm.
mef_extension * enu_mef_new_mask(const char *, const cpl_mask *, const cpl_propertylist *)
Create a mef_extension struct holding a cpl_mask.
cpl_propertylist * enu_raw_flats_qc(located_imagelist *lamp_on_limlist, cpl_mask *bp_map_nl_mask, const cpl_parameterlist *parlist, const char *context, const double threshold_pos, const cpl_boolean verbose, const cpl_boolean rescale_by_dit)
Compute QC on input raw flats.
cpl_error_code enu_flat_save(const char *pro_catg, const hdrl_image *flat, const cpl_image *confidence, const cpl_mask *cold_bpm, cpl_frameset *frameset, const cpl_parameterlist *parlist, const char *filename, const char *flat_save, const cpl_propertylist *qclog)
Save a flatfield result.
int enu_check_conformance(const cpl_propertylist *, const cpl_propertylist *, const char *)
Check that the specified subset of two propertylists match.
located_image * enu_load_limage_from_frame(const cpl_frame *frame, cpl_image **, const cpl_boolean)
Load components of a located_image from a frame.
hdrl_catalogue_result * enu_hdrl_catalogue_result_duplicate(const hdrl_catalogue_result *)
Return a deep copy of the given hdrl_catalogue_result object.
located_imagelist * enu_located_imagelist_duplicate(const located_imagelist *)
Make a deep copy of a located_imagelist and its contents.
cpl_error_code enu_calc_maglim(const located_image *limage, const double photzp, const double fwhm_pix, double *abmaglim)
Calculate magnitude limit of image.
cpl_error_code enu_opm_lss_limlist(located_imagelist *limlist, const int nsigma_cut)
Calculate object masks for LSS images in a located_imagelist.
double enu_get_tel_alt(const cpl_propertylist *plist)
Get telescope altitude of an observation.
mef_extension * enu_mef_new_image(const char *, const cpl_image *, const cpl_propertylist *)
Create a mef_extension to hold a cpl_image.
cpl_error_code enu_get_ra_dec(const cpl_wcs *wcs, double *ra, double *dec)
Get RA and Dec at centre of image with given wcs.
hdrl_image * enu_calc_flat(hdrl_imagelist *himlist, const int min_coadds, const hdrl_parameter *collapse_params, const cpl_size filter_size_x, const cpl_size filter_size_y, const hdrl_flat_method method)
Calculate a flatfield result.
cpl_error_code enu_get_window_info(cpl_size *nx, cpl_size *ny, int *rot, cpl_size *strx, cpl_size *stry, cpl_size *nx_chip, cpl_size *ny_chip, cpl_boolean *windowed, const cpl_propertylist *plist)
Get the detector 'window' information.
cpl_error_code enu_basic_calibrate(located_image *limage, const int read_offsets, const cpl_table *refine_wcs, const master_dark *master_dark, const gain_linearity *gain_linearity, const master_flat *flatfield_1, const master_flat *flatfield_2, const master_bpm *master_bpm, const int flag_mask, const char *fill_rejected, const double fill_value, const cpl_size x_probe, const cpl_size y_probe)
Do basic calibration of located_image (single or cube)
cpl_error_code enu_catalogue_limlist(located_imagelist *limlist, hdrl_parameter *cat_params)
Calculate object catalogues for a list of images.
cpl_error_code enu_sky_subtract_limlist(const char *method, const char *select_method, const double timerange, const located_imagelist *sky_data, const cpl_size x_probe, const cpl_size y_probe, located_imagelist *target_data)
Estimate and subtract sky backgrounds for a list of target images.
cpl_error_code enu_himage_load_from_fits(const char *, hdrl_image **, mef_extension_list **, cpl_propertylist **)
Load an hdrl_image from a multi-extension FITS file.
cpl_error_code enu_debug_limlist_save(const int debug, const located_imagelist *limlist, const char *nameroot, const char *recipename, cpl_frameset *frameset, const cpl_parameterlist *parlist, const cpl_frameset *used)
Save a list of intermediate image results for use in debugging.
mef_extension * enu_mef_new_table(const char *, const cpl_table *, const cpl_propertylist *)
Create a mef_extension struct holding a cpl_table.
mef_extension_list * enu_mef_extension_list_new(cpl_size)
Construct a new mef_extension_list.
located_image * enu_located_image_new(hdrl_image *himage, hdrl_imagelist *himagelist, cpl_image *confidence, hdrl_image *bkg, cpl_image *bkg_confidence, cpl_propertylist *plist, hdrl_catalogue_result *objects, cpl_mask *object_mask, hdrl_catalogue_result *wcs, hdrl_catalogue_result *photom, cpl_frame *frame)
Create a located_image structure and initialise the contents.
double enu_get_airmass(const cpl_propertylist *plist)
Get the mean airmass of an observation.
cpl_error_code enu_calc_pixel_coords(cpl_table *catalogue, const cpl_propertylist *wcs_plist)
Calculate predicted positions of catalogue objects for given wcs.
located_imagelist * enu_limlist_load_from_frameset(cpl_frameset *, const char *, cpl_frameset *)
Load tagged data from a frameset into a located_imagelist.
void enu_located_image_delete(located_image *)
Delete a located_image and its contents.
mef_extension * enu_mef_new_vector(const char *name, const cpl_vector *vector, const cpl_propertylist *plist)
Create a mef_extension struct holding a cpl_vector.
cpl_error_code enu_remove_read_offsets(hdrl_image *himage, const cpl_propertylist *plist, cpl_image *confidence, const int set_confidence)
Function to remove read offsets from an himage and set blank pixels
cpl_error_code enu_normalise_confidence(cpl_image *confidence)
Normalise confidence array so that mean of good pixels is 100.
cpl_error_code enu_stack(located_imagelist *limages, const double stk_lthr, const double stk_hthr, const char *stk_method, const int stk_fast, located_image **result)
Stack a set of images.
cpl_error_code enu_correct_wcs(const cpl_table *refcat, const char *wcs_method, const char *catalogue, located_image *limage, const double match_rad, cpl_table **matched_stds, cpl_matrix **xy_shift)
Correct the wcs of an image.
cpl_error_code enu_basic_calibrate_himage(hdrl_image *himage, cpl_image *confidence, cpl_propertylist *plist, const cpl_frame *frame, const int read_offsets, const master_dark *master_dark, const gain_linearity *gain_linearity, const master_flat *flatfield_1, const master_flat *flatfield_2, const master_bpm *master_bpm, const int set_confidence, const int flag_mask, const char *fill_rejected, const double fill_value, const cpl_size x_probe, const cpl_size y_probe)
Do basic calibration of an hdrl_image.
cpl_error_code enu_mef_extension_save(const mef_extension *, const char *, const cpl_propertylist *, unsigned)
Save a mef_extension struct to FITS file.
char * enu_repreface(const char *filename, const char *preface)
Preface a raw filename with a string.
const char * enu_get_license(void)
Get the pipeline copyright and license.
void enu_mef_extension_list_delete(mef_extension_list *)
Delete a mef_extension_list and its contents.
cpl_image * enu_load_component(mef_extension *mef, const char *dps_name, const char *target_hduclas1, const char *target_hduclas2)
Load data from a MEF component of specified type.
const char * enu_get_filter(const cpl_propertylist *plist)
Get the filter used in an observation.
cpl_error_code enu_check_wcs(const located_image *limage)
Check that the image has valid WCS keywords.
cpl_error_code enu_get_rcore_and_mesh_size(const char *context, const cpl_parameterlist *parlist, const cpl_propertylist *plist, double *core_radius, int *mesh_size)
Get catalogue core-radius and mesh-size appropriate to AO mode.
located_imagelist * enu_located_imagelist_new(cpl_size)
Return a pointer to a new located_imagelist.
hdrl_catalogue_result * enu_catalogue_compute(const hdrl_image *, const cpl_image *, const cpl_wcs *, hdrl_parameter *)
Wrapper for hdrl_catalogue_compute.
cpl_error_code enu_opm_limlist(const int obj_min_pixels, const double obj_threshold, const int bkg_mesh_size, const double bkg_smooth_fwhm, located_imagelist *limages)
Calculate object masks for images in a located_imagelist.
const char * enu_get_det_mode(const cpl_propertylist *plist)
Get the detector mode of an integration.
cpl_error_code enu_sky_backgrounds(const char *method, const char *select_method, const double timerange, const located_imagelist *target_data, const located_imagelist *sky_data, const cpl_size x_probe, const cpl_size y_probe, hdrl_imagelist **sky_himagelist, cpl_imagelist **sky_confidence_list)
Get sky backgrounds for a list of target images.
double enu_get_dit(const cpl_propertylist *plist)
Get the DIT of an integration.
double enu_get_filter_wavelength(const char *filter)
Get the effective wavelength of a filter.
mef_extension_list * enu_load_mef_components(const char *filename, cpl_propertylist **plist)
Load components of a multi-extension FITS file.