ERIS Pipeline Reference Manual 1.9.2
eris_ifu_extract_spec_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_EXTRACT_SPEC_STATIC_H_
22#define ERISP_ERIS_ERIS_IFU_EXTRACT_SPEC_STATIC_H_
23
24#ifdef HAVE_CONFIG_H
25#include <config.h>
26#endif
27
28/*-----------------------------------------------------------------------------
29 Includes
30 -----------------------------------------------------------------------------*/
31
32#include <time.h>
33#include <math.h>
34
35#include <cpl.h>
36#include <hdrl.h>
37#include "eris_ifu_functions.h"
38#include "eris_ifu_vector.h"
39
40/*-----------------------------------------------------------------------------
41 Define
42 -----------------------------------------------------------------------------*/
43
44typedef enum {MASK, POSITION, MAX, FIT, OPTIMAL} mask_method_types;
45struct esParamStruct {
46 mask_method_types mask_method;
47 int center_x;
48 int center_y;
49 double radius;
50 productDepthType productDepth;
51 bool save_mask;
52};
53
54
55struct esSofStruct {
56 hdrl_imagelist *cube;
57 cpl_image *mask;
58// cpl_image *collapsedCube;
59 cpl_propertylist *header;
60 cpl_imagelist *qualImagelist;
61 deqQualityType qualityType;
62 cpl_size nx;
63 cpl_size ny;
64 cpl_size nz;
65};
66
67
68/*-----------------------------------------------------------------------------
69 Functions prototypes
70 -----------------------------------------------------------------------------*/
71
72/*----------------------------------------------------------------------------*/
73void eris_ifu_extract_free_esSofStruct(struct esSofStruct* self);
74
75hdrl_image* eris_ifu_extract_spec_collapse(hdrl_imagelist *cube,
76 cpl_image **contribute);
77
78cpl_image* eris_ifu_extract_spec_create_fit_mask(const hdrl_image *img);
79
80cpl_image* eris_ifu_extract_spec_create_circle_mask(
81 cpl_size center_x,
82 cpl_size center_y,
83 double radius,
84 cpl_size nx,
85 cpl_size ny);
86
87cpl_image* eris_ifu_extract_spec_create_mask(struct esParamStruct params,
88 struct esSofStruct sof,
89 const hdrl_image *collapsedCube,
90 int productDepth);
91
92cpl_bivector* eris_ifu_extract_spectrum(
93 hdrl_imagelist *cube,
94 cpl_image *mask,
95 double startLambda,
96 double deltaLambda,
97 cpl_vector **error,
98 cpl_vector **totalFlux,
99 cpl_vector **quality);
100
101//cpl_bivector* eris_ifu_extract_spectrum2(
102// hdrl_imagelist *cube,
103// cpl_image *mask,
104// double startLambda,
105// double deltaLambda,
106// cpl_vector **error,
107// cpl_vector **totalFlux);
108
109//cpl_bivector* eris_ifu_extract_spectrum3(
110// hdrl_imagelist *cube,
111// cpl_image *mask,
112// double startLambda,
113// double deltaLambda,
114// cpl_vector **error,
115// cpl_vector **totalFlux);
116
117cpl_bivector* eris_ifu_optimal_extraction(const hdrl_imagelist *cube,
118 const cpl_imagelist *cube_dqi,
119 const cpl_image *img_mask,
120 double startLambda,
121 double deltaLambda,
122 int productDepth,
123 cpl_vector **error_out);
124
125cpl_error_code eris_ifu_opt_extr_get_center_fwhm(const hdrl_image *hdrl_img,
126 int edge_trim,
127 cpl_size *xcen,
128 cpl_size *ycen,
129 double *fwhm);
130
131cpl_mask* eris_ifu_opt_extr_create_mask(int nx,
132 int ny,
133 int xcen,
134 int ycen,
135 double fwhm);
136
137cpl_error_code eris_ifu_opt_extr_simple_extraction(const hdrl_imagelist *cube,
138 const cpl_mask *mask,
139 cpl_vector **spec,
140 cpl_vector **spec_var);
141
142cpl_bivector * eris_ifu_opt_extr_helper_usepix(const cpl_mask *mask, int *n_usepix);
143
144cpl_error_code eris_ifu_opt_extr_helper_fill_vertical(cpl_image *img, const eris_ifu_vector *vec);
145
146void eris_ifu_opt_extr_helper_fill_horizontal(cpl_image *img, const cpl_image *slice, const cpl_bivector *usepix, int row, int power);
147
148void eris_ifu_opt_extr_helper_set_positive(cpl_image *img);
149
150cpl_vector* eris_ifu_opt_extr_get_col(const cpl_image *img, int colnr);
151
152cpl_vector *eris_ifu_opt_extr_get_row(const cpl_image *img, int rownr);
153
154cpl_error_code eris_ifu_opt_extr_set_row(cpl_image *img,
155 int rownr,
156 const cpl_vector *vec);
157
158cpl_error_code eris_ifu_opt_extr_set_col(cpl_image *img,
159 int colnr,
160 const cpl_vector *vec);
161
162cpl_vector* eris_ifu_opt_extr_create_lambda(int size,
163 double startLambda,
164 double deltaLambda);
165
166cpl_error_code eris_ifu_opt_extr_vector_sqrt(cpl_vector *vec);
167
168cpl_bivector* eris_ifu_opt_extr_doit(const hdrl_imagelist *cube,
169 const cpl_imagelist *cube_dqi,
170 const cpl_mask *mask,
171 const eris_ifu_vector *spec,
172 const eris_ifu_vector *spec_var,
173 double startLambda,
174 double deltaLambda,
175 int productDepth,
176 cpl_vector **error_out);
177
178int eris_ifu_opt_extr_get_not_finite(cpl_vector *vec);
179
180void eris_ifu_opt_extr_convert_0_to_NaN_vec(cpl_vector *vec);
181
182double eris_ifu_opt_extr_estimate_radius(const cpl_image *img,
183 cpl_size center_x,
184 cpl_size center_y,
185 double initial_radius,
186 int productDepth);
187
188//double eris_ifu_opt_extr_median_without_NaN(cpl_vector *vec);
189
190cpl_error_code eris_ifu_cpl_vector_sqrt(cpl_vector *vec);
191
192#endif
193
194