MUSE Pipeline Reference Manual  0.18.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  *
5  * This file is part of the MUSE Instrument Pipeline
6  * Copyright (C) 2005-2011 European Southern Observatory
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef MUSE_WAVECALIB_H
24 #define MUSE_WAVECALIB_H
25 
26 /*----------------------------------------------------------------------------*
27  * Includes *
28  *----------------------------------------------------------------------------*/
29 #include <cpl.h>
30 
31 #include "muse_image.h"
32 #include "muse_imagelist.h"
33 
34 /*----------------------------------------------------------------------------*
35  * Special variable types *
36  *----------------------------------------------------------------------------*/
37 
41 /*----------------------------------------------------------------------------*/
45 /*----------------------------------------------------------------------------*/
46 /* keep this in sync with muse_wave_weighting_string[] in muse_wavecalib.c! */
47 typedef enum {
54 
55 /*----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------*/
60 typedef struct {
62  unsigned short xorder;
64  unsigned short yorder;
67  double detsigma;
69  double ddisp;
72  double tolerance;
75  double linesigma;
77  cpl_boolean rflag;
80  cpl_table *residuals;
84  double fitsigma;
86  double targetrms;
91 
94 /*----------------------------------------------------------------------------*
95  * Function prototypes *
96  *----------------------------------------------------------------------------*/
99 
100 cpl_table *muse_wave_calib(muse_image *, cpl_table *, cpl_table *, muse_wave_params *);
101 cpl_table *muse_wave_calib_lampwise(muse_imagelist *, cpl_table *, cpl_table *, muse_wave_params *);
102 
103 cpl_boolean muse_wave_lines_check(cpl_table *, cpl_propertylist *);
104 cpl_vector *muse_wave_lines_get(cpl_table *, int, double);
105 cpl_vector *muse_wave_lines_get_for_lamp(cpl_table *, const char *, int, double);
106 const char *muse_wave_lines_get_lampname(cpl_table *, const int);
107 cpl_table *muse_wave_lines_search(muse_image *, double, const unsigned short);
108 cpl_error_code muse_wave_lines_identify(cpl_table *, cpl_vector *, const muse_wave_params *);
109 
110 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);
111 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);
112 cpl_error_code muse_wave_line_fit_single(muse_image *, int, double, int, double, cpl_table *, int);
113 cpl_error_code muse_wave_line_fit_multiple(muse_image *, int, cpl_bivector *, cpl_vector *, int, double, cpl_table *, int);
114 cpl_error_code muse_wave_line_fit_iterate(cpl_table *, double, const muse_wave_params *aParams);
115 
116 cpl_error_code muse_wave_poly_fit(cpl_matrix *, cpl_vector *, cpl_vector *, cpl_polynomial **, double *, muse_wave_params *, const unsigned short);
117 
118 cpl_table *muse_wave_table_create(const unsigned short, const unsigned short, const unsigned short);
119 cpl_error_code muse_wave_table_add_poly(cpl_table *, cpl_polynomial *, double, unsigned short, unsigned short, const unsigned short);
120 cpl_error_code muse_wave_table_get_orders(const cpl_table *, unsigned short *, unsigned short *);
121 cpl_polynomial *muse_wave_table_get_poly_for_slice(const cpl_table *, unsigned short);
122 
123 cpl_image *muse_wave_map(muse_image *, const cpl_table *, const cpl_table *);
124 
125 cpl_error_code muse_wave_plot_residuals(cpl_table *, unsigned short, unsigned int, cpl_boolean, cpl_vector *);
126 cpl_error_code muse_wave_plot_column(cpl_table *, cpl_table *, unsigned short, unsigned int, unsigned int, cpl_boolean);
127 
128 #endif /* MUSE_WAVECALIB_H */
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:41
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_table * muse_wave_lines_search(muse_image *, double, const unsigned short)
Search and store emission lines in a column of an arc frame.
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.