27#ifndef ERIS_NIX_UTILS_H
28#define ERIS_NIX_UTILS_H
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"
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"
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,
69 const char * fill_rejected,
70 const double fill_value,
71 const cpl_size x_probe,
72 const cpl_size y_probe);
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,
86 const char * fill_rejected,
87 const double fill_value,
88 const cpl_size x_probe,
89 const cpl_size y_probe);
92 const double timerange,
93 const located_imagelist * sky_pool,
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);
105 const double fwhm_pix,
109 const cpl_propertylist * wcs_plist);
117 hdrl_parameter * cat_params);
120 const cpl_propertylist *,
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);
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);
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);
154 const cpl_parameterlist * parlist,
155 const cpl_propertylist * plist,
156 double * core_radius,
180 cpl_boolean * windowed,
181 const cpl_propertylist * plist);
184 const hdrl_catalogue_result *);
188 mef_extension_list **,
189 cpl_propertylist **);
192 const char * dps_name,
193 const char * target_hduclas1,
194 const char * target_hduclas2);
197 cpl_image **,
const cpl_boolean);
200 cpl_propertylist ** plist);
209 const located_imagelist *);
222 hdrl_imagelist * himagelist,
223 cpl_image * confidence,
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,
244 const cpl_propertylist *);
248 const cpl_propertylist *);
252 const cpl_propertylist *);
255 const cpl_vector * vector,
256 const cpl_propertylist * plist);
260 const cpl_propertylist *,
264 const cpl_table * refine_wcs);
269 const double obj_threshold,
270 const int bkg_mesh_size,
271 const double bkg_smooth_fwhm,
272 located_imagelist * limages);
275 const int nsigma_cut);
278 const cpl_propertylist * plist,
279 cpl_image * confidence,
280 const int set_confidence);
283 const char * preface);
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);
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);
303cpl_error_code
enu_stack(located_imagelist * limages,
304 const double stk_lthr,
305 const double stk_hthr,
306 const char * stk_method,
308 located_image ** result);
313 cpl_propertylist * qc_list,
314 const char * prefix);
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);
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.