MUSE Pipeline Reference Manual  2.1.1
muse_wavecalib.h
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set sw=2 sts=2 et cin: */
3 /*
4  * This file is part of the MUSE Instrument Pipeline
5  * Copyright (C) 2005-2017 European Southern Observatory
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef MUSE_WAVECALIB_H
23 #define MUSE_WAVECALIB_H
24 
25 /*----------------------------------------------------------------------------*
26  * Includes *
27  *----------------------------------------------------------------------------*/
28 #include <cpl.h>
29 
30 #include "muse_image.h"
31 #include "muse_imagelist.h"
32 #include "muse_pfits.h"
33 #include "muse_table.h"
34 
35 /*----------------------------------------------------------------------------*
36  * Special variable types *
37  *----------------------------------------------------------------------------*/
38 
42 /*----------------------------------------------------------------------------*/
46 /*----------------------------------------------------------------------------*/
47 /* keep this in sync with muse_wave_weighting_string[] in muse_wavecalib.c! */
48 typedef enum {
55 
56 /*----------------------------------------------------------------------------*/
60 /*----------------------------------------------------------------------------*/
61 typedef struct {
63  unsigned short xorder;
65  unsigned short yorder;
68  double detsigma;
70  double ddisp;
73  double tolerance;
76  double linesigma;
78  cpl_boolean rflag;
81  cpl_table *residuals;
85  double fitsigma;
87  double targetrms;
92  muse_ins_mode mode;
94 
97 /*----------------------------------------------------------------------------*
98  * Function prototypes *
99  *----------------------------------------------------------------------------*/
100 muse_wave_params *muse_wave_params_new(cpl_propertylist *);
102 
103 cpl_table *muse_wave_calib(muse_image *, cpl_table *, cpl_table *, muse_wave_params *);
104 cpl_table *muse_wave_calib_lampwise(muse_imagelist *, cpl_table *, cpl_table *, muse_wave_params *);
105 
106 cpl_boolean muse_wave_lines_check(muse_table *);
107 cpl_vector *muse_wave_lines_get(cpl_table *, int, double);
108 cpl_vector *muse_wave_lines_get_for_lamp(cpl_table *, const char *, int, double);
109 const char *muse_wave_lines_get_lampname(cpl_table *, const int);
110 cpl_boolean muse_wave_lines_covered_by_data(double, muse_ins_mode);
111 cpl_table *muse_wave_lines_search(muse_image *, double, const unsigned short, const unsigned char);
112 cpl_error_code muse_wave_lines_identify(cpl_table *, cpl_vector *, const muse_wave_params *);
113 
114 cpl_table *muse_wave_line_handle_singlet(muse_image *, cpl_table *, unsigned int, cpl_polynomial *, cpl_polynomial **, const muse_wave_params *, const unsigned short, int);
115 cpl_table *muse_wave_line_handle_multiplet(muse_image *, cpl_table *, unsigned int, cpl_polynomial *, cpl_polynomial **, const muse_wave_params *, const unsigned short, int);
116 cpl_error_code muse_wave_line_fit_single(muse_image *, int, double, int, double, cpl_table *, int);
117 cpl_error_code muse_wave_line_fit_multiple(muse_image *, int, cpl_bivector *, cpl_vector *, int, double, cpl_table *, int);
118 cpl_error_code muse_wave_line_fit_iterate(cpl_table *, double, const muse_wave_params *aParams);
119 
120 cpl_error_code muse_wave_poly_fit(cpl_matrix *, cpl_vector *, cpl_vector *, cpl_polynomial **, double *, muse_wave_params *, const unsigned short);
121 
122 cpl_table *muse_wave_table_create(const unsigned short, const unsigned short, const unsigned short);
123 cpl_error_code muse_wave_table_add_poly(cpl_table *, cpl_polynomial *, double, unsigned short, unsigned short, const unsigned short);
124 cpl_error_code muse_wave_table_get_orders(const cpl_table *, unsigned short *, unsigned short *);
125 cpl_polynomial *muse_wave_table_get_poly_for_slice(const cpl_table *, unsigned short);
126 
127 cpl_image *muse_wave_map(muse_image *, const cpl_table *, const cpl_table *);
128 
129 cpl_error_code muse_wave_plot_residuals(cpl_table *, unsigned char, unsigned short, unsigned int, cpl_boolean, cpl_vector *);
130 cpl_error_code muse_wave_plot_column(cpl_table *, cpl_table *, unsigned char, unsigned short, unsigned int, unsigned int, cpl_boolean);
131 
132 #endif /* MUSE_WAVECALIB_H */
cpl_table * muse_wave_lines_search(muse_image *, double, const unsigned short, const unsigned char)
Search and store emission lines in a column of an arc frame.
cpl_table * muse_wave_calib_lampwise(muse_imagelist *, cpl_table *, cpl_table *, muse_wave_params *)
Find wavelength calibration solution using a list of arc images with different lamps.
cpl_table * muse_wave_calib(muse_image *, cpl_table *, cpl_table *, muse_wave_params *)
Find wavelength calibration solution on an arc frame.
cpl_error_code muse_wave_table_get_orders(const cpl_table *, unsigned short *, unsigned short *)
Determine the x- and y-order of the polynomial stored in a wavelength calibration table...
muse_wave_params * muse_wave_params_new(cpl_propertylist *)
Allocate a wavelength parameters structure and fill it with defaults.
Structure definition for a collection of muse_images.
cpl_error_code muse_wave_plot_residuals(cpl_table *, unsigned char, unsigned short, unsigned int, cpl_boolean, cpl_vector *)
Fancy plotting of wavelength calibration residuals (color coded over x/y-position) using gnuplot...
muse_wave_weighting_type fitweighting
cpl_polynomial * muse_wave_table_get_poly_for_slice(const cpl_table *, unsigned short)
Construct polynomial from the wavelength calibration table entry for the given slice.
cpl_vector * muse_wave_lines_get_for_lamp(cpl_table *, const char *, int, double)
Load wavelengths for a given lamp from a linelist table into a vector.
cpl_error_code muse_wave_lines_identify(cpl_table *, cpl_vector *, const muse_wave_params *)
Identify the wavelength of arc detected lines using pattern matching.
void muse_wave_params_delete(muse_wave_params *)
Deallocate memory associated to a wavelength parameters structure.
muse_ins_mode mode
cpl_boolean rflag
cpl_error_code muse_wave_poly_fit(cpl_matrix *, cpl_vector *, cpl_vector *, cpl_polynomial **, double *, muse_wave_params *, const unsigned short)
Compute the wavelength solution from the sample positions and the respective wavelengths.
cpl_table * muse_wave_table_create(const unsigned short, const unsigned short, const unsigned short)
Create the table to save te wave wavelength calibration coefficients.
cpl_vector * muse_wave_lines_get(cpl_table *, int, double)
Load usable wavelengths from a linelist table into a vector.
cpl_table * residuals
cpl_boolean muse_wave_lines_check(muse_table *)
Check that a LINE_CATALOG has the expected format.
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
muse_wave_weighting_type
Type of weighting to use in the wavelength calibration fit.
cpl_table * muse_wave_line_handle_multiplet(muse_image *, cpl_table *, unsigned int, cpl_polynomial *, cpl_polynomial **, const muse_wave_params *, const unsigned short, int)
Handle fitting of all multiplets across the columns a given slice.
const char * muse_wave_lines_get_lampname(cpl_table *, const int)
Associate the ion listed in a linelist table row to a lamp name.
cpl_boolean muse_wave_lines_covered_by_data(double, muse_ins_mode)
Check, if a given wavelength is covered by a given instrument mode.
Structure containing wavelength calibration parameters.
unsigned short xorder
cpl_error_code muse_wave_table_add_poly(cpl_table *, cpl_polynomial *, double, unsigned short, unsigned short, const unsigned short)
Save the given polynomials to the wavelength calibration table.
cpl_image * muse_wave_map(muse_image *, const cpl_table *, const cpl_table *)
Write out a wavelength map for visual checks.
Structure to store a table together with a property list.
Definition: muse_table.h:43
cpl_error_code muse_wave_plot_column(cpl_table *, cpl_table *, unsigned char, unsigned short, unsigned int, unsigned int, cpl_boolean)
Plot wavelength calibration polynomial and data or residuals using gnuplot.
cpl_error_code muse_wave_line_fit_iterate(cpl_table *, double, const muse_wave_params *aParams)
Use a low-order polynomial to find and discard bad values for line centroid fits of single arc line a...
cpl_error_code muse_wave_line_fit_single(muse_image *, int, double, int, double, cpl_table *, int)
Fit a Gaussian to a single emission line in an arc frame and do simple error handling.
unsigned short yorder
cpl_error_code muse_wave_line_fit_multiple(muse_image *, int, cpl_bivector *, cpl_vector *, int, double, cpl_table *, int)
Fit a multi-Gaussian to a multiplet of arc emission lines and do simple error handling.
cpl_table * muse_wave_line_handle_singlet(muse_image *, cpl_table *, unsigned int, cpl_polynomial *, cpl_polynomial **, const muse_wave_params *, const unsigned short, int)
Handle fitting of all single lines across the columns a given slice.