CR2RE Pipeline Reference Manual 1.6.7
cr2res_utils.h
1/*
2 * This file is part of the CR2RES Pipeline
3 * Copyright (C) 2002,2003 European Southern Observatory
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18 */
19
20#ifndef CR2RES_UTILS_H
21#define CR2RES_UTILS_H
22
23/*-----------------------------------------------------------------------------
24 Includes
25 -----------------------------------------------------------------------------*/
26
27#include <cpl.h>
28#include <hdrl.h>
29
30/*-----------------------------------------------------------------------------
31 Define
32 -----------------------------------------------------------------------------*/
33
34#define CR2RES_PIPELINE_AUTHORS \
35 "Yves Jung, Thomas Marquart, Ansgar Wehrhahn, Nikolai Piskunov"
36
37#define CR2RES_NB_DETECTORS 3
38#define CR2RES_NB_DECKER_POSITIONS 3
39#define CR2RES_DETECTOR_SIZE 2048
40#define CR2RES_DETECTOR_OVEREXP_THRESH 37000
41#define CR2RES_SATURATED_LINES_THRESH 4000000
42#define CR2RES_APPROX_SLIT_HEIGHT 175
43
44/* Provided by Paul Bristow (email 10/09/2020) */
45#define CR2RES_GAIN_CHIP1 2.15
46#define CR2RES_GAIN_CHIP2 2.19
47#define CR2RES_GAIN_CHIP3 2.00
48
49typedef enum {
50 CR2RES_DECKER_INVALID,
51 CR2RES_DECKER_NONE,
52 CR2RES_DECKER_1_3,
53 CR2RES_DECKER_2_4
54} cr2res_decker ;
55
56/*-----------------------------------------------------------------------------
57 Prototypes
58 -----------------------------------------------------------------------------*/
59
60double cr2res_mjd_obs_now(void) ;
61double cr2res_utils_get_center_mjd(const cpl_frameset * frameset) ;
62
63int cr2res_order_idx_to_real(int order_idx, int order_zp) ;
64int cr2res_order_real_to_idx(int order_real, int order_zp) ;
65
66double cr2res_ra_hms2deg(int hh, int mm, double ss) ;
67double cr2res_dec_hms2deg(int dd, int mm, double ss) ;
68
69char * cr2res_decker_print_position(cr2res_decker dpos) ;
70
71int cr2res_format_setting(char * setting_id) ;
72int cr2res_format_setting2(char * setting_id) ;
73int cr2res_is_short_wavelength(const char * setting_id) ;
74
75double cr2res_vector_get_mad(cpl_vector * invec, double *mad);
76
78 const cpl_vector * ycen);
80 const cpl_vector * ycen);
81
82cpl_table * cr2res_combine_extracted(
83 const cpl_table * extracta,
84 const cpl_table * extractb);
85
86
87cpl_polynomial * cr2res_fit_interorder(
88 cpl_image * img,
89 cpl_table * trace_wave,
90 cpl_size order_x,
91 cpl_size order_y) ;
92
94 const cpl_table * trace_wave,
95 cpl_polynomial *** coef_slit,
96 cpl_polynomial *** coef_wave,
97 int * size) ;
98
100 const cpl_table * trace_wave,
101 cpl_image ** slitpos,
102 cpl_image ** wavelength) ;
103
104cpl_image * cr2res_image_cut_rectify(
105 const cpl_image * img_in,
106 const cpl_vector * ycen,
107 int height);
109 const cpl_image * rect_in,
110 const cpl_vector * ycen,
111 cpl_image * img_out );
113 const cpl_polynomial * poly,
114 const cpl_vector * vec);
115
117 const cpl_table * blaze,
118 int * ngood,
119 double * blaze_tot);
120
121cpl_vector * cr2res_threshold_spec(const cpl_vector * invector, int smooth,
122 double thresh) ;
123
124char * cr2res_get_base_name(const char * filename) ;
125char * cr2res_get_root_name(const char * filename) ;
126#ifdef CR2RES_UNUSED
127const char * cr2res_extract_filename(const cpl_frameset *, const char *) ;
128#endif
129cpl_frameset * cr2res_extract_frameset(const cpl_frameset *, const char *) ;
131 const cpl_frameset * in,
132 const char ** tags,
133 int ntags) ;
134
135cpl_polynomial * cr2res_convert_array_to_poly(const cpl_array * arr) ;
137 const cpl_polynomial * poly,
138 int size) ;
139
141 const cpl_image * ima_data,
142 const double gain,
143 const double ron,
144 cpl_image ** ima_errs) ;
145
147 const cpl_bivector * extracted_spec,
148 const cpl_bivector * catalog,
149 const char * title,
150 double wmin,
151 double wmax) ;
152
153int cr2res_vector_erase_element(
154 cpl_vector * vector,
155 cpl_size pos);
156
157int cr2res_vector_abs(
158 cpl_vector * vector);
159#ifdef CR2RES_UNUSED
160int cr2res_util_optimal_filter_1d(
161 const double * Yarg,
162 double Lam1,
163 double * Result,
164 int n,
165 int Options[],
166 const double * Xarg,
167 const double * Weights,
168 double Lam2);
169#endif
171 const cpl_image * img,
172 const cpl_image * weight,
173 double lam_x,
174 double lam_y);
175
176cpl_polynomial * cr2res_polyfit_2d(
177 const cpl_vector * x,
178 const cpl_vector * y,
179 const cpl_vector * z,
180 const cpl_size degree[2]
181);
182
183const char * cr2res_get_license(void) ;
184
185#endif
double cr2res_mjd_obs_now(void)
Get the current MJD-OBS.
Definition: cr2res_utils.c:58
int cr2res_format_setting2(char *setting_id)
Format the setting.
Definition: cr2res_utils.c:190
int cr2res_format_setting(char *setting_id)
Format the setting.
Definition: cr2res_utils.c:152
double cr2res_ra_hms2deg(int hh, int mm, double ss)
Convert the RA from hh mm ss to degrees.
Definition: cr2res_utils.c:121
cpl_image * cr2res_image_cut_rectify(const cpl_image *img_in, const cpl_vector *ycen, int height)
Cut a bent order into a rectangle, shifting columns.
Definition: cr2res_utils.c:907
char * cr2res_decker_print_position(cr2res_decker dpos)
Get the decker position string for display.
int * cr2res_vector_get_int(const cpl_vector *ycen)
Definition: cr2res_utils.c:230
cpl_error_code cr2res_detector_shotnoise_model(const cpl_image *ima_data, const double gain, const double ron, cpl_image **ima_errs)
compute photon count error in [ADU]
cpl_polynomial * cr2res_fit_interorder(cpl_image *img, cpl_table *trace_wave, cpl_size order_x, cpl_size order_y)
Fit a 2D Polynomial to the interorder regions.
Definition: cr2res_utils.c:461
double cr2res_dec_hms2deg(int dd, int mm, double ss)
Convert the DEC from dd mm ss to degrees.
Definition: cr2res_utils.c:139
double cr2res_vector_get_mad(cpl_vector *invec, double *mad)
Get MAD from a vector.
Definition: cr2res_utils.c:212
cpl_polynomial * cr2res_convert_array_to_poly(const cpl_array *arr)
Convert an array to polynomial.
cpl_vector * cr2res_threshold_spec(const cpl_vector *invector, int smooth, double thresh)
Find the regions with over-average values in a vector.
double * cr2res_vector_get_rest(const cpl_vector *ycen)
Definition: cr2res_utils.c:253
cpl_vector * cr2res_polynomial_eval_vector(const cpl_polynomial *poly, const cpl_vector *vec)
Evaluate a polynomial on a vector.
int cr2res_order_idx_to_real(int order_idx, int order_zp)
Convert the order_idx into order_real.
Definition: cr2res_utils.c:89
double cr2res_utils_get_center_mjd(const cpl_frameset *frameset)
Calculate the middle of the exposures in the frameset.
cpl_array * cr2res_convert_poly_to_array(const cpl_polynomial *poly, int size)
Convert a polynomial to array.
double cr2res_util_blaze_stat(const cpl_table *blaze, int *ngood, double *blaze_tot)
Computes the average of the blaze.
cpl_image * cr2res_util_optimal_filter_2d(const cpl_image *img, const cpl_image *weight, double lam_x, double lam_y)
Apply the optimal filter in the 2D case.
int cr2res_is_short_wavelength(const char *setting_id)
Identify Short Wavelength.
Definition: cr2res_utils.c:171
char * cr2res_get_root_name(const char *filename)
Find out the root part of a basename (name without extension).
int cr2res_plot_wavecal_result(const cpl_bivector *extracted_spec, const cpl_bivector *catalog, const char *title, double wmin, double wmax)
Plot the spectrum with the catalog.
cpl_frameset * cr2res_extract_frameset_several_tags(const cpl_frameset *in, const char **tags, int ntags)
Extract the frames whose tag is within a list from a frameset.
cpl_table * cr2res_combine_extracted(const cpl_table *extracta, const cpl_table *extractb)
Combine two extracted spectra by resampling one to the other's WL.
Definition: cr2res_utils.c:278
int cr2res_slit_pos_image(const cpl_table *trace_wave, cpl_image **slitpos, cpl_image **wavelength)
get a image of the slitposition (and wavelength) along the slit
Definition: cr2res_utils.c:841
int cr2res_slit_pos(const cpl_table *trace_wave, cpl_polynomial ***coef_slit, cpl_polynomial ***coef_wave, int *size)
Create the polynomials needed to calculate the slit pos and wavelength at any point x,...
Definition: cr2res_utils.c:627
int cr2res_order_real_to_idx(int order_real, int order_zp)
Convert the order_real into order_idx.
Definition: cr2res_utils.c:102
cpl_frameset * cr2res_extract_frameset(const cpl_frameset *, const char *)
Extract the frames with the given tag from a frameset.
int cr2res_image_insert_rect(const cpl_image *rect_in, const cpl_vector *ycen, cpl_image *img_out)
Re-insert a rectangular cut-out of an order into the full frame.
Definition: cr2res_utils.c:984
char * cr2res_get_base_name(const char *filename)
Find out the base name of a file (i.e. without prefix path)
const char * cr2res_get_license(void)
Get the pipeline copyright and license.