MUSE Pipeline Reference Manual  1.0.2
muse_sky.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-2014 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_SKY_H
23 #define MUSE_SKY_H
24 
25 /*----------------------------------------------------------------------------*
26  * Includes *
27  *----------------------------------------------------------------------------*/
28 #include <cpl.h>
29 
30 #include "muse_utils.h"
31 #include "muse_cplwrappers.h"
32 #include "muse_pixtable.h"
33 #include "muse_resampling.h"
34 #include "muse_lsf.h"
35 
36 /*----------------------------------------------------------------------------*
37  * Defines *
38  *----------------------------------------------------------------------------*/
40 extern const muse_cpltable_def muse_relativespectrum_def[];
41 extern const muse_cpltable_def muse_extinction_def[];
43 
44 /*----------------------------------------------------------------------------*
45  * Special variable types *
46  *----------------------------------------------------------------------------*/
50 /*----------------------------------------------------------------------------*/
56 /*----------------------------------------------------------------------------*/
57 typedef struct {
61  cpl_table *lines;
63  cpl_table *continuum;
65  muse_lsf_params **lsf; /*<< the LSF parameters */
67 
68 /*----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------*/
73 typedef struct {
74  double fraction;
75  double sampling;
76  double csampling;
78 
79 /*----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------*/
84 typedef struct {
85  cpl_size n_param;
86  cpl_size offset;
87  cpl_size refraction;
88  cpl_size sensitivity;
89  cpl_size slit_width;
90  cpl_size bin_width;
91  cpl_size lsf_width;
92  cpl_size hermit[MAX_HERMIT_ORDER];
94 
97 /*----------------------------------------------------------------------------*
98  * Function prototypes *
99  *----------------------------------------------------------------------------*/
102 cpl_error_code muse_sky_lines_set_range(cpl_table *, double, double);
105 
106 muse_mask *muse_sky_create_skymask(muse_image *, double, const char *);
107 cpl_table *muse_sky_spectrum_from_cube(muse_datacube *, const cpl_mask *);
108 void muse_sky_mark_cosmic(cpl_table *aSpectrum, muse_pixtable *aPixtable);
109 cpl_error_code muse_sky_save_continuum(muse_processing *, const cpl_table *, cpl_propertylist *);
110 
111 cpl_error_code muse_sky_lines_save(muse_processing *, const cpl_table *, cpl_propertylist *);
112 muse_sky_fit_params *muse_sky_fit_params_new(cpl_boolean, cpl_boolean, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size);
113 
115 
116 muse_sky_master *muse_sky_master_fit(const cpl_array *, const cpl_array *, const cpl_array *, const cpl_table *);
117 
119 
120 muse_lsf_params *muse_sky_lsf_params_fit(const cpl_array *, const cpl_array *, const cpl_array *, const cpl_table *, const cpl_array *, const cpl_array *, muse_lsf_params *, int, const muse_sky_fit_params *);
123 
124 cpl_error_code muse_sky_lines_apply_strength(cpl_table *, const cpl_array *);
125 cpl_error_code muse_sky_lines_cut(cpl_table *, double);
126 cpl_table *muse_sky_lines_create(const cpl_table *, const cpl_table *, double);
127 cpl_array *muse_sky_apply_lsf(const cpl_array *, const cpl_table *, const muse_lsf_params *);
128 
129 muse_lsf_params *muse_lsf_params_fit(const cpl_array *, cpl_array *, const cpl_array *, const cpl_table *, muse_lsf_params *, int, const muse_sky_fit_params *);
130 
131 /* functios about QC parameters (muse_sky_qc.c) */
132 void muse_sky_qc_lines(cpl_propertylist *, cpl_table *, const char *);
133 void muse_sky_qc_continuum(cpl_propertylist *, cpl_table *, const char *);
134 
135 /* functions about row-by-row sky subtraction (muse_sky_rowbyrow.c) */
136 cpl_error_code muse_sky_subtract_rowbyrow_mask(muse_image *, cpl_table *);
137 cpl_error_code muse_sky_subtract_rowbyrow(muse_image *, cpl_table *, float, unsigned int);
138 
139 #endif /* MUSE_SKY_H */
Structure definition of a MUSE datacube.
Definition: muse_datacube.h:47
cpl_error_code muse_sky_lines_apply_strength(cpl_table *, const cpl_array *)
Apply the line strengths to the lines.
cpl_error_code muse_sky_lines_save(muse_processing *, const cpl_table *, cpl_propertylist *)
Save sky lines table to file.
cpl_table * muse_sky_spectrum_from_cube(muse_datacube *, const cpl_mask *)
Create a spectrum out of a cube by applying a mask.
cpl_table * muse_sky_lines_create(const cpl_table *, const cpl_table *, double)
Create the emission lines from the OH transitions and other lines.
cpl_table * muse_sky_lines_load(muse_processing *)
Load the sky data files.
muse_lsf_params * muse_lsf_params_fit(const cpl_array *, cpl_array *, const cpl_array *, const cpl_table *, muse_lsf_params *, int, const muse_sky_fit_params *)
Fit all entries of one slice.
Definition: muse_lsf_fit.c:131
Structure to hold the MASTER SKY result.
Definition: muse_sky.h:57
cpl_error_code muse_sky_subtract_rowbyrow(muse_image *, cpl_table *, float, unsigned int)
Subtract the sky row-by-row from a CCD-based image.
void muse_sky_qc_lines(cpl_propertylist *, cpl_table *, const char *)
Fill a header with the QC parameters for the sky lines.
Definition: muse_sky_qc.c:46
Structure to define which slice parameters are fit.
Definition: muse_sky.h:84
muse_mask * muse_sky_create_skymask(muse_image *, double, const char *)
Select spaxels to be considered as sky.
void muse_sky_fit_params_delete(muse_sky_fit_params *)
Delete the fit parameter structure.
Structure definition of MUSE three extension FITS file.
Definition: muse_image.h:40
void muse_sky_mark_cosmic(cpl_table *aSpectrum, muse_pixtable *aPixtable)
Mark all pixel above a certain limit as COSMIC.
void muse_sky_qc_continuum(cpl_propertylist *, cpl_table *, const char *)
Fill a header with the QC parameters for the sky continuum.
Definition: muse_sky_qc.c:102
muse_lsf_params * muse_sky_lsf_params_fit(const cpl_array *, const cpl_array *, const cpl_array *, const cpl_table *, const cpl_array *, const cpl_array *, muse_lsf_params *, int, const muse_sky_fit_params *)
Fit all entries of one slice.
cpl_table * muse_sky_continuum_load(muse_processing *)
Load the SKY_CONTINUUM spectrum.
Structure definition of MUSE pixel table.
cpl_table * lines
Table of Atmospheric emission lines and their intensities.
Definition: muse_sky.h:61
Structure to define the major settable sky parameters.
Definition: muse_sky.h:73
const muse_cpltable_def muse_fluxspectrum_def[]
Definition of the flux spectrum table structure.
cpl_error_code muse_sky_lines_set_range(cpl_table *, double, double)
Limit the lines in the table to a wavelength range.
void muse_sky_master_delete(muse_sky_master *)
Delete a MASTER SKY structure.
muse_sky_fit_params * muse_sky_fit_params_new(cpl_boolean, cpl_boolean, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size, cpl_size)
Create a new fit parameter structure.
muse_sky_master * muse_sky_master_fit(const cpl_array *, const cpl_array *, const cpl_array *, const cpl_table *)
Fit all entries of the pixel table to the master sky.
cpl_error_code muse_sky_lines_cut(cpl_table *, double)
Remove all lines below a certain flux limit.
Handling of "mask" files.
Definition: muse_mask.h:42
const muse_cpltable_def muse_pixtable_def[]
MUSE pixel table definition.
muse_sky_master * muse_sky_master_load(muse_processing *)
Load SKY_LINES, SKY_CONTINUUM, and LSF_PROFILE into a structure.
cpl_error_code muse_sky_subtract_rowbyrow_mask(muse_image *, cpl_table *)
Prepare an (object) mask for the sky row-by-row fitting.
Definition of a cpl table structure.
cpl_array * muse_sky_apply_lsf(const cpl_array *, const cpl_table *, const muse_lsf_params *)
Apply the LSF parameters to a spectrum.
cpl_table * continuum
Continuum flux table
Definition: muse_sky.h:63
Structure definition of detector (slice) parameters.
Definition: muse_lsf.h:50
cpl_error_code muse_sky_subtract_pixtable(muse_pixtable *a, muse_sky_master *, muse_lsf_params **)
Subtract the sky spectrum from the "data" column of a pixel table.
cpl_error_code muse_sky_subtract_slice(muse_pixtable *, muse_sky_master *, muse_lsf_params *)
Subtract the sky spectrum from the "data" column of a pixel table for one slice.
muse_lsf_params ** lsf
LSF parameter for the resampled spectrum.
Definition: muse_sky.h:65
muse_sky_master * muse_sky_master_new(void)
Create a muse_sky_master structure.
cpl_error_code muse_sky_save_continuum(muse_processing *, const cpl_table *, cpl_propertylist *)
Save sky continuum table to file.