28#ifndef ERIS_IFU_UTILS_H
29#define ERIS_IFU_UTILS_H
41#include "eris_ifu_constants.h"
42#include "eris_ifu_vector.h"
43#include "eris_ifu_dfs.h"
45#define MAX_STR_SIZE 512
46#define FILE_NAME_SZ 256
61enum idl_rel_ops {eq, ne, ge, gt, le, lt};
67 const cpl_vector *indices);
100 const char* filename,
int create,
101 const cpl_propertylist *pl);
103 const char* filename,
int create);
105 const char* filename,
int col,
int create);
107 const char* filename,
int create,
const cpl_propertylist *pl);
109 const char* filename,
int create);
111 const char* filename,
int create,
const cpl_propertylist *pl);
113 const char* filename,
int create);
115 const char* name,
int singlefile,
116 const cpl_propertylist *pl);
120 const char* filename,
int singlefile,
121 const cpl_propertylist *pl);
123 const char* filename,
int singlefile);
126 const cpl_propertylist *plist,
127 const cpl_parameterlist *parlist,
130 const char *filename,
132 const cpl_image *img);
136 const cpl_propertylist *plist,
137 const cpl_parameterlist *parlist,
140 const char *filename,
142 const cpl_imagelist *imglist);
145 const cpl_mask *mask);
160 const char *category,
166 int exposureCorrectionMode);
172 const cpl_parameterlist *p2);
194cpl_error_code eris_ifu_strehl_flag_nans(hdrl_image** hima);
198 deqQualityType qualityType);
204 cpl_imagelist *dataCube,
205 cpl_imagelist *errorCube);
208 cpl_imagelist *dataCube,
209 cpl_imagelist *errorCube,
210 cpl_imagelist *qualCube);
235 const char* key_name,
237 const char* key_help);
250cpl_propertylist* eris_qc_init(
void);
253eris_qc_add_int(cpl_propertylist* table,
261eris_qc_add_bool(cpl_propertylist* table,
269eris_qc_add_float(cpl_propertylist* table,
277eris_qc_add_double(cpl_propertylist* table,
285eris_qc_add_string(cpl_propertylist* table,
297 cpl_propertylist* qc_list,
302 cpl_propertylist* qc_list,
306 const char* context);
309eris_gaussian_maxpos(
const cpl_image * self,
330 hdrl_imagelist** iml,
332 cpl_propertylist* header);
void eris_ifu_free_frameset(cpl_frameset **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_save_table_dbg(const cpl_table *tbl, const char *filename, int create)
Save table for debugging (quick, no DFS overhead)
cpl_error_code eris_ifu_save_cpl_image_dbg(const cpl_image *img, const char *name, int singlefile, const cpl_propertylist *pl)
Save CPL image with mask for debugging.
cpl_error_code eris_ifu_save_imagelist(cpl_frameset *fs, cpl_frame *inherit, const cpl_propertylist *plist, const cpl_parameterlist *parlist, const char *recipe, const char *procatg, const char *filename, cpl_type type, const cpl_imagelist *imglist)
Save imagelist with DFS compliance.
cpl_error_code eris_ifu_save_imagelist_dbg(const cpl_imagelist *imglist, const char *filename, int create)
Save CPL imagelist for debugging (quick, no DFS overhead)
void eris_ifu_free_propertylist(cpl_propertylist **item)
Free memory and set pointer to null.
cpl_vector * eris_ifu_idl_values_at_indices(const cpl_vector *data, const cpl_vector *indices)
Returns a vector of given indices.
void eris_ifu_free_apertures(cpl_apertures **item)
Free memory and set pointer to null.
void eris_ifu_free_string(char **item)
Free memory and set pointer to null.
char * eris_ifu_get_lampString(int lampStatus)
Convert lamp status bitmask to string.
cpl_error_code eris_ifu_parameterlist_append_list(cpl_parameterlist *p1, const cpl_parameterlist *p2)
Append a parameterlist to another one.
void eris_ifu_free_double_array(double **item)
Free memory and set pointer to null.
cpl_table * eris_qclog_init(void)
Initialize QC table.
void eris_ifu_free_vector(cpl_vector **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_save_vector_dbg(const cpl_vector *vec, const char *filename, int create, const cpl_propertylist *pl)
Save vector for debugging (quick, no DFS overhead)
cpl_error_code eris_ifu_save_image_dbg(const cpl_image *img, const char *filename, int create, const cpl_propertylist *pl)
Save image for debugging (quick, no DFS overhead)
void eris_ifu_free_table(cpl_table **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_save_ifu_vector_dbg(const eris_ifu_vector *vec, const char *filename, int create)
Save eris_ifu_vector for debugging (quick, no DFS overhead)
cpl_error_code eris_ifu_cut_endings(cpl_vector **vec, int *begin, int *end, int cut)
Cut leading and trailing -1 of a vector.
cpl_error_code eris_ifu_mask_nans_in_hdrlimage(hdrl_image **hima)
Flag NaNs in HDRL image.
const char * eris_ifu_get_bandString(ifsBand band)
Convert band enum to string.
void eris_ifu_free_ifu_vector(eris_ifu_vector **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_split_hdrl_imagelist(hdrl_imagelist *cube, cpl_imagelist *dataCube, cpl_imagelist *errorCube)
extract from hdrl_imagelist the data and error information
cpl_error_code eris_get_pupil_shift(hdrl_imagelist *iml, const int n, cpl_table **qclog_tbl)
Get what object shift.
cpl_mask * eris_ifu_load_badpixel_mask(const cpl_frameset *frameset, const char *category, int ext)
**
cpl_error_code eris_ifu_hdrl_image_reject_mask(hdrl_image *img, const cpl_mask *mask)
Add mask to HDRL image (reject masked pixels)
cpl_error_code eris_ifu_file_exists(const char *filename)
**
cpl_error_code eris_ifu_get_plane_cut_min_max(ifsBand band, cpl_size *zmin, cpl_size *zmax)
Get band-specific plane indices for NaN trimming.
const char * eris_ifu_get_instrumentString(ifsInstrument instrument)
Convert instrument enum to string.
cpl_error_code eris_pfits_put_qc(cpl_propertylist *plist, cpl_table *qclog)
convert table with QC parameter information to a propertylist
cpl_error_code eris_ifu_get_badpix_qc_from_ima(const cpl_image *image, cpl_propertylist *qc_list, const char *prefix)
compute QC keyword with number of bad pixels and fraction to total
void eris_ifu_free_polynomial(cpl_polynomial **item)
Free memory and set pointer to null.
hdrl_imagelist * eris_ifu_get_hdrlimagelist_by_tag(cpl_frameset *frameset, const char *tag, int exposureCorrectionMode)
Return HDRL imagelist by searching tagged frames in frameset.
void eris_ifu_free_parameter(cpl_parameter **item)
Free memory and set pointer to null.
cpl_propertylist * eris_compute_psf_qc(hdrl_image *hima, const cpl_parameterlist *parlist, const char *context)
compute QC parameters on a PSF STD image
cpl_error_code eris_ifu_save_bivector_dbg(const cpl_bivector *bivec, const char *filename, int col, int create)
Save bivector for debugging (as vector or table)
cpl_imagelist * eris_ifu_hdrl_get_imagelist(const hdrl_imagelist *hdrl_imglist, enum hdrl_t type)
Extract from an HDRL imagelist a specific CPL imagelist.
cpl_mask * eris_ifu_hima_get_obj_mask_percent(hdrl_image *hima, const double percent)
find mask flagging pixels above percent(%) pixels with lower intensity
cpl_mask * eris_ifu_mask_create_border(const cpl_mask *mask)
Add bad pixel border around mask.
cpl_image * eris_ifu_image_create_window(const cpl_image *img)
Create sub-image by removing bad pixel border.
cpl_error_code eris_qclog_add_double_f(cpl_table *table, const char *key_name, const double value, const char *key_help)
add QC float info to table
void eris_ifu_free_int_array(int **item)
Free memory and set pointer to null.
cpl_error_code eris_qclog_add_string(cpl_table *table, const char *name, const char *value, const char *help)
add QC string info to table
cpl_error_code eris_qclog_add_double(cpl_table *table, const char *name, const double value, const char *help)
add QC double info to table
cpl_error_code eris_ifu_save_mask_dbg(const cpl_mask *mask, const char *filename, int create, const cpl_propertylist *pl)
Save mask for debugging (quick, no DFS overhead)
void eris_ifu_free_imagelist(cpl_imagelist **item)
Free memory and set pointer to null.
cpl_vector * eris_ifu_idl_where(const cpl_vector *data, double val, int op)
Implements the where-function known from IDL.
cpl_mask * eris_ifu_quality2bp_mask(const cpl_image *qualityMask, deqQualityType qualityType)
transform input image (quality mask) to output mask with given bit code
cpl_error_code eris_ifu_cube_set_values(hdrl_imagelist **iml)
Set specific pixel values in HDRL imagelist (debugging utility)
void eris_ifu_free_frame(cpl_frame **item)
Free memory and set pointer to null.
cpl_error_code eris_qclog_add_bool(cpl_table *table, const char *name, const char *help)
add QC boolean info to table
cpl_error_code eris_ifu_mask_nans_in_cube(cpl_imagelist *cube)
Mask NaNs and Infs in CPL imagelist (cube)
void eris_ifu_free_hdrl_imagelist(hdrl_imagelist **item)
Free memory and set pointer to null.
cpl_error_code eris_qclog_add_int(cpl_table *table, const char *name, const int value, const char *help)
add QC int info to table
cpl_error_code eris_ifu_save_hdrl_imagelist_dbg(const hdrl_imagelist *imgList, const char *filename, int singlefile)
Save HDRL imagelist for debugging (data + error + mask planes)
cpl_error_code eris_ifu_save_cpl_imagelist_dbg(const cpl_imagelist *imglist, const char *name)
Save CPL imagelist for debugging.
cpl_error_code eris_ifu_save_hdrl_image_dbg(const hdrl_image *hdrl_img, const char *filename, int singlefile, const cpl_propertylist *pl)
Save HDRL image for debugging (data + error + mask)
cpl_mask * eris_ifu_mask_from_image(const cpl_image *img_mask)
eris_ifu_mask_from_image
void eris_ifu_free_float_array(float **item)
Free memory and set pointer to null.
void eris_ifu_free_hdrl_image(hdrl_image **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_cube_trim_nans(const cpl_size zmin, const cpl_size zmax, hdrl_imagelist **iml, cpl_imagelist **bpm, cpl_propertylist *header)
Trim NaN-dominated planes from cube edges.
cpl_imagelist * eris_ifu_interpolatedMask_to_maskZero(cpl_imagelist *bpmCube, double threshold)
return cube flagging (as 1) pixels above a given threshold
cpl_error_code eris_ifu_get_badpix_qc_from_mask(const cpl_mask *bp_mask, cpl_propertylist *qc_list, const char *prefix)
compute QC keyword with number of bad pixels and fraction to total
void eris_ifu_free_image(cpl_image **item)
Free memory and set pointer to null.
cpl_error_code eris_qclog_add_double_format(cpl_table *table, const char *name, const double value, const char *help)
add QC double (with format) info to table
void eris_ifu_free_matrix(cpl_matrix **item)
Free memory and set pointer to null.
void eris_ifu_free_mask(cpl_mask **item)
Free memory and set pointer to null.
cpl_frameset * eris_ifu_get_frameset_by_tag(const cpl_frameset *frameset, const char *tag)
Get frames with given tag from frameset.
const char * eris_ifu_get_preopticsScaleString(ifsPreopticsScale scale)
Convert pre-optics scale enum to string.
void eris_ifu_free_parameterlist(cpl_parameterlist **item)
Free memory and set pointer to null.
cpl_error_code eris_ifu_split3_hdrl_imagelist(hdrl_imagelist *cube, cpl_imagelist *dataCube, cpl_imagelist *errorCube, cpl_imagelist *qualCube)
extract from hdrl_imagelist the data and error information
cpl_error_code eris_ifu_save_image(cpl_frameset *fs, const cpl_propertylist *plist, const cpl_parameterlist *parlist, const char *recipe, const char *procatg, const char *filename, cpl_type type, const cpl_image *img)
Save image with DFS compliance.
double eris_ifu_get_band_resolution(ifsBand band)
Get nominal spectral resolution for a given band.
void eris_ifu_free_bivector(cpl_bivector **item)
Free memory and set pointer to null.
void eris_ifu_free_hdrl_parameter(hdrl_parameter **item)
Free memory and set pointer to null.
cpl_mask * eris_ifu_hima_get_obj_mask(hdrl_image *hima, const cpl_size niter, const double kappa)
find mask flagging pixels above a threshold set by ks-clip algorithm