ERIS Pipeline Reference Manual 1.8.15
eris_ifu_flat_static.h
1/* $Id$
2 *
3 * This file is part of the ERIS 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 02110-1301 USA
19 */
20
21#ifndef ERISP_ERIS_ERIS_IFU_FLAT_STATIC_H_
22#define ERISP_ERIS_ERIS_IFU_FLAT_STATIC_H_
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif
27#include <eris_ifu_constants.h>
28/*-----------------------------------------------------------------------------
29 Includes
30 -----------------------------------------------------------------------------*/
31
32#include <cpl.h>
33#include <hdrl.h>
34
35typedef enum {
36 FLAT_MODE_NONE,
37 FLAT_MODE_SEGMENT,
38 FLAT_MODE_HDRL,
39 FLAT_MODE_FAST
40} flatMode;
41
42static const char * const flatModes[] = {
43 "segment",
44 "hdrl",
45 "fast"
46};
47
48cpl_error_code eris_ifu_flat_static(cpl_frameset *fs,
49 const cpl_parameterlist *parlist,
50 const flatMode mode,
51 int productDepth,
52 const char *procatg,
53 const char *recipe_name,
54 const char *procatg_prefix,
55 const char *instrument,
56 cpl_propertylist **qc_list,
57 hdrl_image **masterFlatHdrlImg_lo,
58 cpl_image **qualityImage);
59
60double eris_ifu_getThreshold(hdrl_image *img);
61
62int eris_ifu_matchRow(int blocksize, int rx);
63
64cpl_error_code eris_ifu_calc_flat(const cpl_parameterlist *parlist,
65 const char *recipe_name,
66 const flatMode mode,
67 const hdrl_imagelist *hdrl_imagelist_on,
68 const hdrl_imagelist *hdrl_imagelist_off,
69 int productDepth,
70 ifsBand band,
71 hdrl_image **masterFlatHdrlImg_lo,
72 hdrl_image **masterFlatHdrlImg_hi,
73 cpl_image **contrib_map);
74
75cpl_error_code eris_ifu_flat_load_frames(const cpl_frameset *fs,
76 double *gain,
77 double *exptime,
78 hdrl_imagelist **hdrlImgListOn,
79 hdrl_imagelist **hdrlImgListOff);
80
81int eris_ifu_get_qc_saturated(const hdrl_imagelist *dataHdrl);
82
83cpl_error_code eris_ifu_flat_calc_qc_pre(
84 const cpl_parameterlist *parlist,
85 const char *recipe_name,
86 const hdrl_imagelist *hdrl_imglist_on,
87 const hdrl_imagelist *hdrl_imglist_off,
88 cpl_propertylist *qc_list);
89
90cpl_error_code eris_ifu_flat_calc_qc_post(const cpl_parameterlist *parlist,
91 const char *recipe_name,
92 const int productDepth,
93 const char *procatg_prefix,
94 const hdrl_image *masterFlatHdrlImg_hi,
95 const hdrl_image *masterFlatHdrlImg_lo,
96 const hdrl_imagelist *hdrl_imglist_on,
97 const hdrl_imagelist *hdrl_imglist_off,
98 const cpl_image *contrib_map,
99 const cpl_mask *bpm2dMask,
100 const cpl_mask *bpm3dMask,
101 cpl_frameset *fs,
102 cpl_propertylist *qc_list,
103 cpl_image **qualityImage);
104
105cpl_error_code eris_ifu_column_tilt(hdrl_image *hdrl_img, double sigma);
106
107cpl_error_code eris_ifu_flat_thresh_mask(hdrl_image *hdrl_img,
108 double lo_cut,
109 double hi_cut);
110
111cpl_error_code eris_ifu_flat_pixel_qsort(double *pix_arr, int npix);
112
113void eris_ifu_my_fit(double x[], double y[], int ndata, double sig[], int mwt,
114 double *a, double *b, double *siga, double *sigb,
115 double *chi2, double *q);
116
117cpl_error_code eris_ifu_flat_stats_rectangle(const hdrl_image *hdrl_img,
118 double loReject,
119 double hiReject,
120 int llx,
121 int lly,
122 int urx,
123 int ury,
124 double *cleanmean,
125 double *cleanstdev);
126
127cpl_error_code eris_ifu_flat_clean_mean(double *array,
128 int n_elements,
129 double throwaway_low,
130 double throwaway_high,
131 double *cleanmean);
132
133hdrl_image* eris_ifu_flat_median_image(const hdrl_image *hdrl_img_in,
134 double fmedian);
135
136cpl_error_code eris_ifu_sinfo_compare_images(const hdrl_image *hdrl_img1,
137 const hdrl_image *hdrl_img2,
138 hdrl_image *hdrl_img_orig);
139
140cpl_error_code eris_ifu_flat_fast_bpm(hdrl_image *master_flat,
141 const cpl_parameterlist *parlist,
142 int productDepth);
143
144/* ---- Data collector ---- */
145struct structFlatData {
146 int blocksize;
147 cpl_size cnt;
148 cpl_vector *ry,
149 *borderAleft,
150 *borderAright,
151 *borderBleft,
152 *borderBright,
153 *borderCleft,
154 *borderCright,
155 *borderDleft,
156 *borderDright;
157};
158void eris_ifu_free_structFlatData(struct structFlatData* sfd);
159cpl_error_code eris_ifu_flat_data_init(struct structFlatData *self, int blocksize);
160
161cpl_error_code eris_ifu_flat_data_setBorders(struct structFlatData *self, int ry,
162 int leftEdgeA, int rightEdgeA,
163 int leftEdgeB, int rightEdgeB,
164 int leftEdgeC, int rightEdgeC,
165 int leftEdgeD, int rightEdgeD);
166
167cpl_vector* eris_ifu_flat_data_getBorderInterpolated(struct structFlatData *self,
168 int row);
169
170#endif /* ERISP_ERIS_ERIS_IFU_FLAT_STATIC_H_ */