MUSE Pipeline Reference Manual  2.1.1
Data Structures | Functions | Variables
Sky subtraction

Data Structures

struct  muse_sky_params
 Structure to define the major settable sky parameters. More...
 

Functions

cpl_table * muse_sky_spectrum_from_cube (muse_datacube *aCube, const cpl_mask *aMask)
 Create a spectrum out of a cube by applying a mask. More...
 
muse_maskmuse_sky_create_skymask (muse_image *aImage, double aMinFraction, double aFraction, const char *aQCPrefix)
 Select spaxels to be considered as sky. More...
 
cpl_error_code muse_sky_save_continuum (muse_processing *aProcessing, const cpl_table *aContinuum, cpl_propertylist *aHeader)
 Save sky continuum table to file. More...
 
cpl_error_code muse_sky_lines_set_range (cpl_table *aLines, double aLow, double aHigh)
 Limit the lines in the table to a wavelength range. More...
 
cpl_error_code muse_sky_lines_save (muse_processing *aProcessing, const cpl_table *aLines, cpl_propertylist *aHeader)
 Save sky lines table to file. More...
 
cpl_table * muse_sky_lines_load (muse_processing *aProcessing)
 Load the sky data files. More...
 
cpl_error_code muse_sky_lines_apply_strength (cpl_table *aLines, const cpl_array *aStrength)
 Apply the line strengths to the lines. More...
 
cpl_error_code muse_sky_lines_cut (cpl_table *aLines, double aMinflux)
 Remove all lines below a certain flux limit. More...
 
cpl_table * muse_sky_lines_create (const cpl_table *aLines, const cpl_table *aOh_transitions, double aT_vibr)
 Create the emission lines from the OH transitions and other lines. More...
 
cpl_error_code muse_sky_lines_fit (cpl_table *aSpectrum, cpl_table *aLines, cpl_image *aLsfImage, muse_wcs *aWCS)
 Fit all entries of the pixel table to the master sky. More...
 
cpl_table * muse_sky_continuum_create (cpl_table *aSpectrum, cpl_table *aLines, cpl_image *aLsfImage, muse_wcs *aLsfWCS, double aBinWidth)
 Create a continuum spectrum. More...
 
cpl_table * muse_sky_continuum_load (muse_processing *aProcessing)
 Load the sky continuum. More...
 
cpl_error_code muse_sky_lines_fit_old (cpl_table *aSpectrum, cpl_table *aLines)
 Fit all entries of the pixel table to the master sky. More...
 
cpl_error_code muse_sky_subtract_lines_old (muse_pixtable *aPixtable, cpl_table *aLines, muse_lsf_params **aLsfParams)
 Subtract sky lines from a pixtable. More...
 
void muse_sky_qc_lines (cpl_propertylist *aHeader, cpl_table *aLines, const char *aPrefix)
 Fill a header with the QC parameters for the sky lines. More...
 
void muse_sky_qc_continuum (cpl_propertylist *aHeader, cpl_table *aContinuum, const char *aPrefix)
 Fill a header with the QC parameters for the sky continuum. More...
 
cpl_array * muse_sky_lines_spectrum (const cpl_array *aLambda, cpl_table *aLines, const cpl_image *aLsfImage, const muse_wcs *aLsfWCS)
 Create spectrum for a single slice. More...
 
cpl_error_code muse_sky_subtract_lines (muse_pixtable *aPixtable, cpl_table *aLines, muse_lsf_cube **aLsfCube)
 Subtract sky lines from a pixtable. More...
 
cpl_error_code muse_sky_subtract_continuum (muse_pixtable *aPixtable, cpl_table *aSpectrum)
 Subtract sky continuum from pixel table. More...
 

Variables

const muse_cpltable_def muse_fluxspectrum_def []
 Definition of the flux spectrum table structure. More...
 

Detailed Description

The sky subtraction consists of two steps: the calculation of the common sky parameters (continuum spectrum and emission line fluxes), and the actual subtraction of this spectrum applied to LSF parameters from each slice. The communication between these two steps is realized with the muse_sky_master structure.

As input for the master sky calculation a parameter file is used that will be read into a muse_sky_lines structure.

This type of file contains one or more binary tables with the relative fluxes on the sky emission lines. If both tables are present, they are merged, so that lines should not appear in both tables.

Columns:

This type of file contains one or more binary tables with the relative fluxes on the sky emission lines. If both tables are present, they are merged, so that lines should not appear in both tables.

Columns:

Function Documentation

cpl_table* muse_sky_continuum_create ( cpl_table *  aSpectrum,
cpl_table *  aLines,
cpl_image *  aLsfImage,
muse_wcs aLsfWCS,
double  aBinWidth 
)

Create a continuum spectrum.

Parameters
aSpectrumSky spectrum
aLinesSky emission line list
aLsfImageLSF data to use
aLsfWCSWCS information for the LSF data
aBinWidthContinuum spectrum bin with
Returns
Continuum spectrum table.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aSpectrum) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aLines) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aLsfImage) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aLsfWCS) not fulfilled

Definition at line 319 of file muse_sky_master.c.

References muse_cplarray_interpolate_linear(), muse_cpltable_extract_column(), muse_cpltable_new(), muse_fluxspectrum_def, and muse_sky_lines_spectrum().

Referenced by muse_postproc_process_exposure().

cpl_table* muse_sky_continuum_load ( muse_processing aProcessing)

Load the sky continuum.

Parameters
aProcessingthe processing structure
Returns
The spectrum as cpl_table, or NULL

Definition at line 367 of file muse_sky_master.c.

References muse_processing::inframes, muse_cpltable_load(), muse_fluxspectrum_def, muse_frameset_find(), and muse_processing_append_used().

muse_mask* muse_sky_create_skymask ( muse_image aImage,
double  aMinFraction,
double  aFraction,
const char *  aQCPrefix 
)

Select spaxels to be considered as sky.

Parameters
aImageMUSE (white-light) image of the field of view.
aMinFractionLowest fraction of spectra to ignore
aFractionLowest fraction of remaining spectra to select
aQCPrefixprefix for the QC keywords
Returns
A newly created bitmask for sky spaxels.

Use thresholding to create a mask of sky regions. The output mask contains a QC parameter aQCPrefix" THRESHOLD" in its header component.

Exceptions
set CPL_ERROR_NULL_INPUT, return NULLaImage is NULL

Definition at line 120 of file muse_sky_common.c.

References muse_image::data, muse_mask::header, muse_image::header, muse_mask::mask, muse_cplimage_get_percentile(), muse_image_reject_from_dq(), and muse_mask_new().

Referenced by muse_postproc_process_exposure().

cpl_error_code muse_sky_lines_apply_strength ( cpl_table *  aLines,
const cpl_array *  aStrength 
)

Apply the line strengths to the lines.

Parameters
aLinesList of emission lines.
aStrengthArray of strengths, sorted by line group.
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aLines != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aStrength != NULL) not fulfilled
CPL_ERROR_ILLEGAL_INPUT(aLines['group'] != NULL) not fulfilled
CPL_ERROR_ILLEGAL_INPUT(aLines['flux'] != NULL) not fulfilled

The line strengths are applied in-place, changing the emission lines list.

Definition at line 239 of file muse_sky_lines.c.

Referenced by muse_sky_lines_fit(), and muse_sky_lines_fit_old().

cpl_table* muse_sky_lines_create ( const cpl_table *  aLines,
const cpl_table *  aOh_transitions,
double  aT_vibr 
)

Create the emission lines from the OH transitions and other lines.

Parameters
aLinesnon-OH lines table
aOh_transitionsOH transition table
aT_vibrstructure to hold vibrational transitions
Returns
the sky emission line table

If the input parameters are NULL, then the function returns an empty table (default).

Algorithm:
Create emission lines from OH transitions, append the additional emission lines, apply line strengths by group

Definition at line 389 of file muse_sky_lines.c.

Referenced by muse_sky_lines_load().

cpl_error_code muse_sky_lines_cut ( cpl_table *  aLines,
double  aMinflux 
)

Remove all lines below a certain flux limit.

Parameters
aLinesList of emission lines.
aMinfluxMinimal flux, in 10^-20 erg/(s cm^2 arcsec^2)
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aLines != NULL) not fulfilled

The line strengths are applied in-place, changing the emission lines list.

Definition at line 268 of file muse_sky_lines.c.

References muse_cpltable_new(), and muse_sky_lines_lines_def.

cpl_error_code muse_sky_lines_fit ( cpl_table *  aSpectrum,
cpl_table *  aLines,
cpl_image *  aLsfImage,
muse_wcs aWCS 
)

Fit all entries of the pixel table to the master sky.

Parameters
aSpectrumSky spectrum
aLinesSky lines table. The line fluxes are adjusted.
aLsfImageImage to store the LSF.
aWCSThe WCS header of the image.
Returns
CPL_ERROR_NONE if everythin is OK.
Return values
CPL_ERROR_NULL_INPUT(aSpectrum != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aLines != NULL) not fulfilled
Exceptions
set CPL_ERROR_DATA_NOT_FOUNDaSpectrum has no entries

Definition at line 227 of file muse_sky_master.c.

References muse_cpl_optimize_lvmq(), muse_cpltable_extract_column(), and muse_sky_lines_apply_strength().

Referenced by muse_postproc_process_exposure().

cpl_error_code muse_sky_lines_fit_old ( cpl_table *  aSpectrum,
cpl_table *  aLines 
)

Fit all entries of the pixel table to the master sky.

Parameters
aSpectrumMeasured sky spectrum.
aLinesSky lines table.
Return values
CPL_ERROR_NULL_INPUT(aSpectrum != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aLines != NULL) not fulfilled
Exceptions
set CPL_ERROR_DATA_NOT_FOUND, return NULLaStat has no entries

Definition at line 436 of file muse_sky_old.c.

References muse_cpl_optimize_lvmq(), muse_cpltable_extract_column(), and muse_sky_lines_apply_strength().

Referenced by muse_postproc_process_exposure().

cpl_table* muse_sky_lines_load ( muse_processing aProcessing)

Load the sky data files.

Parameters
aProcessingthe processing structure
Returns
Table with sky lines
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aFile != NULL) not fulfilled

The file must consist of two extensions containing the OH transition table ("OH_TRANSITIONS") and the table of other lines ("LINES").

Definition at line 169 of file muse_sky_lines.c.

References muse_processing::inframes, muse_cpltable_load(), muse_frameset_find(), muse_processing_append_used(), muse_sky_lines_create(), and muse_sky_lines_lines_def.

cpl_error_code muse_sky_lines_save ( muse_processing aProcessing,
const cpl_table *  aLines,
cpl_propertylist *  aHeader 
)

Save sky lines table to file.

Parameters
aProcessingthe processing structure
aLinesthe sky lines table
aHeaderthe FITS header to use for the primary HDU
Returns
CPL_ERROR_NONE on success, another CPL error code on failure

The table extension is marked with and EXTNAME of "LINES".

Exceptions
return CPL_ERROR_NULL_INPUTone of the arguments is NULL
return CPL_ERROR_ILLEGAL_INPUTthe output frame could not be created

Definition at line 136 of file muse_sky_lines.c.

References muse_cpltable_append_file(), muse_processing_new_frame(), muse_sky_lines_lines_def, and muse_processing::outframes.

cpl_error_code muse_sky_lines_set_range ( cpl_table *  aLines,
double  aLow,
double  aHigh 
)

Limit the lines in the table to a wavelength range.

Parameters
aLinessky lines table
aLowlower limit, in Angstrom
aHighhigher limit, in Angstrom
Return values
CPL_ERROR_NONESuccess
CPL_ERROR_NULL_INPUT(aSkyData != NULL) not fulfilled

This function is used to improve the efficiency of the fits by removing lines outside of the data range.

Definition at line 108 of file muse_sky_lines.c.

Referenced by muse_postproc_process_exposure().

cpl_array* muse_sky_lines_spectrum ( const cpl_array *  aLambda,
cpl_table *  aLines,
const cpl_image *  aLsfImage,
const muse_wcs aLsfWCS 
)

Create spectrum for a single slice.

Parameters
aLambdaWavelength array.
aLinesSky emission line table
aLsfImageLSF data to use
aLsfWCSWCS information for the LSF data return the spectrum as cpl_array

The values in the returned array correspond to the wavelengths in the aLambda parameter.

Definition at line 64 of file muse_sky_subtract.c.

References muse_cplarray_add_window(), muse_cplarray_find_sorted(), muse_cpltable_extract_column(), muse_lsf_apply(), MUSE_PIXTABLE_DATA, MUSE_PIXTABLE_LAMBDA, and muse_pixtable::table.

Referenced by muse_sky_continuum_create().

void muse_sky_qc_continuum ( cpl_propertylist *  aHeader,
cpl_table *  aContinuum,
const char *  aPrefix 
)

Fill a header with the QC parameters for the sky continuum.

Parameters
aHeaderheader to store the QC parameters for the sky continuum
aContinuumsky continuum table
aPrefixprefix for the QC keywords
Exceptions
set CPL_ERROR_NULL_INPUT and returnone of the input arguments is NULL
set CPL_ERROR_DATA_NOT_FOUND and returnaContinuum does not contain any rows

Definition at line 102 of file muse_sky_qc.c.

void muse_sky_qc_lines ( cpl_propertylist *  aHeader,
cpl_table *  aLines,
const char *  aPrefix 
)

Fill a header with the QC parameters for the sky lines.

Parameters
aHeaderheader with the QC parameters for the sky lines
aLinessky line table
aPrefixprefix for the QC keywords
Exceptions
set CPL_ERROR_NULL_INPUT and returnone of the input arguments is NULL
set CPL_ERROR_DATA_NOT_FOUND and returnaLines does not contain any rows

Definition at line 46 of file muse_sky_qc.c.

cpl_error_code muse_sky_save_continuum ( muse_processing aProcessing,
const cpl_table *  aContinuum,
cpl_propertylist *  aHeader 
)

Save sky continuum table to file.

Parameters
aProcessingthe processing structure
aContinuumthe sky continuum table
aHeaderthe FITS header to use for the primary HDU
Returns
CPL_ERROR_NONE on success, another CPL error code on failure

The table extension is marked with and EXTNAME of "CONTINUUM".

Exceptions
return CPL_ERROR_NULL_INPUTone of the arguments is NULL
return CPL_ERROR_ILLEGAL_INPUTthe output frame could not be created

Definition at line 169 of file muse_sky_common.c.

References muse_cpltable_append_file(), muse_processing_new_frame(), and muse_processing::outframes.

cpl_table* muse_sky_spectrum_from_cube ( muse_datacube aCube,
const cpl_mask *  aMask 
)

Create a spectrum out of a cube by applying a mask.

Parameters
aCubeMUSE datacube.
aMaskMask image of sky regions.
Returns
Table with data spectrum.

Definition at line 70 of file muse_sky_common.c.

References muse_datacube::data, muse_datacube::dq, muse_datacube::header, muse_cpltable_new(), muse_dataspectrum_def, muse_pfits_get_cd(), muse_pfits_get_crpix(), and muse_pfits_get_crval().

cpl_error_code muse_sky_subtract_continuum ( muse_pixtable aPixtable,
cpl_table *  aSpectrum 
)

Subtract sky continuum from pixel table.

Parameters
aPixtablePixel table. The data column will be changed.
aSpectrumContinuum spectrum
Returns
CPL_ERROR_NONE on success or another CPL error code on failure

Definition at line 216 of file muse_sky_subtract.c.

References muse_cpltable_check(), muse_cpltable_extract_column(), muse_pixtable_def, muse_pixtable_restrict_wavelength(), muse_pixtable_spectrum_apply(), and muse_pixtable::table.

Referenced by muse_postproc_process_exposure().

cpl_error_code muse_sky_subtract_lines ( muse_pixtable aPixtable,
cpl_table *  aLines,
muse_lsf_cube **  aLsfCube 
)

Subtract sky lines from a pixtable.

Parameters
aPixtablePixel table. The data column will be changed.
aLinesLine list with individual line fluxes
aLsfCubeThe LSF cube
Returns
CPL_ERROR_NONE on success or another CPL error code on failure

Definition at line 150 of file muse_sky_subtract.c.

References muse_cpltable_check(), muse_pixtable_def, muse_pixtable_extracted_delete(), muse_pixtable_extracted_get_size(), muse_pixtable_extracted_get_slices(), muse_pixtable_get_nrow(), MUSE_PIXTABLE_ORIGIN, muse_pixtable_origin_get_ifu(), muse_pixtable_origin_get_slice(), and muse_pixtable::table.

Referenced by muse_postproc_process_exposure().

cpl_error_code muse_sky_subtract_lines_old ( muse_pixtable aPixtable,
cpl_table *  aLines,
muse_lsf_params **  aLsfParams 
)

Subtract sky lines from a pixtable.

Parameters
aPixtablePixel table. The data column will be changed.
aLinesLine list with individual line fluxes
aLsfParamsLSF parameters for the instrument
Return values
CPL_ERROR_NONEif everything was OK.
Exceptions
set CPL_ERROR_NULL_INPUT, return CPL_ERROR_NULL_INPUT(aPixtable != NULL) not fulfilled
set CPL_ERROR_NULL_INPUT, return CPL_ERROR_NULL_INPUT(aPixtable->table != NULL) not fulfilled
set CPL_ERROR_DATA_NOT_FOUND, return CPL_ERROR_DATA_NOT_FOUND(aPixtable->table is a pixel table) not fulfilled
set CPL_ERROR_NULL_INPUT, return CPL_ERROR_NULL_INPUT(aLines != NULL) not fulfilled
set CPL_ERROR_NULL_INPUT, return CPL_ERROR_NULL_INPUT(aLsfParams != NULL) not fulfilled
Remarks
This function adds a FITS header (MUSE_HDR_PT_SKYSUB) with the boolean value 'T' to the pixel table, for information.

Definition at line 532 of file muse_sky_old.c.

References muse_pixtable::header, muse_cpltable_extract_column(), MUSE_HDR_PT_SKYSUB, muse_lsf_params_get(), muse_lsf_params_spectrum(), MUSE_PIXTABLE_DATA, muse_pixtable_extracted_delete(), muse_pixtable_extracted_get_size(), muse_pixtable_extracted_get_slices(), muse_pixtable_get_nrow(), MUSE_PIXTABLE_LAMBDA, MUSE_PIXTABLE_ORIGIN, muse_pixtable_origin_get_ifu(), muse_pixtable_origin_get_slice(), and muse_pixtable::table.

Referenced by muse_postproc_process_exposure().

Variable Documentation

const muse_cpltable_def muse_fluxspectrum_def[]
Initial value:
= {
{"lambda", CPL_TYPE_DOUBLE, "Angstrom", "%7.2f", "wavelength", CPL_TRUE},
{"flux", CPL_TYPE_DOUBLE, "erg/(s cm^2 arcsec^2)", "%e", "Flux", CPL_TRUE},
{ NULL, 0, NULL, NULL, NULL, CPL_FALSE }
}

Definition of the flux spectrum table structure.

  • lambda: wavelength [Angstrom]
  • flux: Flux [erg/(s cm^2 arcsec^2)]

The table can be expected to be sorted by the wavelength.

Definition at line 55 of file muse_sky_common.c.

Referenced by muse_sky_continuum_create(), and muse_sky_continuum_load().