MUSE Pipeline Reference Manual  1.0.2
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-2012 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 
33 /*----------------------------------------------------------------------------*
34  * Special variable types *
35  *----------------------------------------------------------------------------*/
36 
40 /*----------------------------------------------------------------------------*/
44 /*----------------------------------------------------------------------------*/
45 /* keep this in sync with muse_wave_weighting_string[] in muse_wavecalib.c! */
46 typedef enum {
53 
54 /*----------------------------------------------------------------------------*/
58 /*----------------------------------------------------------------------------*/
59 typedef struct {
61  unsigned short xorder;
63  unsigned short yorder;
66  double detsigma;
68  double ddisp;
71  double tolerance;
74  double linesigma;
76  cpl_boolean rflag;
79  cpl_table *residuals;
83  double fitsigma;
85  double targetrms;
90 
93 /*----------------------------------------------------------------------------*
94  * Function prototypes *
95  *----------------------------------------------------------------------------*/
98 
99 cpl_table *muse_wave_calib(muse_image *, cpl_table *, cpl_table *, muse_wave_params *);
100 cpl_table *muse_wave_calib_lampwise(muse_imagelist *, cpl_table *, cpl_table *, muse_wave_params *);
101 
102 cpl_boolean muse_wave_lines_check(cpl_table *, cpl_propertylist *);
103 cpl_vector *muse_wave_lines_get(cpl_table *, int, double);
104 cpl_vector *muse_wave_lines_get_for_lamp(cpl_table *, const char *, int, double);
105 const char *muse_wave_lines_get_lampname(cpl_table *, const int);
106 cpl_table *muse_wave_lines_search(muse_image *, double, const unsigned short, const unsigned char);
107 cpl_error_code muse_wave_lines_identify(cpl_table *, cpl_vector *, const muse_wave_params *);
108 
109 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);
110 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);
111 cpl_error_code muse_wave_line_fit_single(muse_image *, int, double, int, double, cpl_table *, int);
112 cpl_error_code muse_wave_line_fit_multiple(muse_image *, int, cpl_bivector *, cpl_vector *, int, double, cpl_table *, int);
113 cpl_error_code muse_wave_line_fit_iterate(cpl_table *, double, const muse_wave_params *aParams);
114 
115 cpl_error_code muse_wave_poly_fit(cpl_matrix *, cpl_vector *, cpl_vector *, cpl_polynomial **, double *, muse_wave_params *, const unsigned short);
116 
117 cpl_table *muse_wave_table_create(const unsigned short, const unsigned short, const unsigned short);
118 cpl_error_code muse_wave_table_add_poly(cpl_table *, cpl_polynomial *, double, unsigned short, unsigned short, const unsigned short);
119 cpl_error_code muse_wave_table_get_orders(const cpl_table *, unsigned short *, unsigned short *);
120 cpl_polynomial *muse_wave_table_get_poly_for_slice(const cpl_table *, unsigned short);
121 
122 cpl_image *muse_wave_map(muse_image *, const cpl_table *, const cpl_table *);
123 
124 cpl_error_code muse_wave_plot_residuals(cpl_table *, unsigned short, unsigned int, cpl_boolean, cpl_vector *);
125 cpl_error_code muse_wave_plot_column(cpl_table *, cpl_table *, unsigned short, unsigned int, unsigned int, cpl_boolean);
126 
127 #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...
Structure definition for a collection of muse_images.
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.
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
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.
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.
cpl_error_code muse_wave_plot_residuals(cpl_table *, unsigned short, unsigned int, cpl_boolean, cpl_vector *)
Fancy plotting of wavelength calibration residuals (color coded over x/y-position) 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_boolean muse_wave_lines_check(cpl_table *, cpl_propertylist *)
Check that a LINE_CATALOG has the expected format.
cpl_error_code muse_wave_plot_column(cpl_table *, cpl_table *, 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_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.
muse_wave_params * muse_wave_params_new(void)
Allocate a wavelength parameters structure and fill it with defaults.
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.