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.
muse_maskmuse_sky_create_skymask (muse_image *aImage, double aMinFraction, double aFraction, const char *aQCPrefix)
 Select spaxels to be considered as sky.
cpl_error_code muse_sky_save_continuum (muse_processing *aProcessing, const cpl_table *aContinuum, cpl_propertylist *aHeader)
 Save sky continuum table to file.
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.
cpl_error_code muse_sky_lines_save (muse_processing *aProcessing, const cpl_table *aLines, cpl_propertylist *aHeader)
 Save sky lines table to file.
cpl_table * muse_sky_lines_load (muse_processing *aProcessing)
 Load the sky data files.
cpl_error_code muse_sky_lines_apply_strength (cpl_table *aLines, const cpl_array *aStrength)
 Apply the line strengths to the lines.
cpl_error_code muse_sky_lines_cut (cpl_table *aLines, double aMinflux)
 Remove all lines below a certain flux limit.
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.
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.
cpl_table * muse_sky_continuum_create (cpl_table *aSpectrum, cpl_table *aLines, cpl_image *aLsfImage, muse_wcs *aLsfWCS, double aBinWidth)
 Create a continuum spectrum.
cpl_table * muse_sky_continuum_load (muse_processing *aProcessing)
 Load the sky continuum.
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.
cpl_error_code muse_sky_subtract_lines_old (muse_pixtable *aPixtable, cpl_table *aLines, muse_lsf_params **aLsfParams)
 Subtract sky lines from a pixtable.
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.
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.
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.
cpl_error_code muse_sky_subtract_lines (muse_pixtable *aPixtable, cpl_table *aLines, muse_lsf_cube **aLsfCube)
 Subtract sky lines from a pixtable.
cpl_error_code muse_sky_subtract_continuum (muse_pixtable *aPixtable, cpl_table *aSpectrum)
 Subtract sky continuum from pixel table.

Variables

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

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:
aSpectrum Sky spectrum
aLines Sky emission line list
aLsfImage LSF data to use
aLsfWCS WCS information for the LSF data
aBinWidth Continuum 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:
aProcessing the 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:
aImage MUSE (white-light) image of the field of view.
aMinFraction Lowest fraction of spectra to ignore
aFraction Lowest fraction of remaining spectra to select
aQCPrefix prefix 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 NULL aImage is NULL

Definition at line 120 of file muse_sky_common.c.

References muse_image::data, muse_image::header, muse_mask::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:
aLines List of emission lines.
aStrength Array of strengths, sorted by line group.
Return values:
CPL_ERROR_NONE Everything 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 233 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:
aLines non-OH lines table
aOh_transitions OH transition table
aT_vibr structure 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 383 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:
aLines List of emission lines.
aMinflux Minimal flux, in 10^-20 erg/(s cm^2 arcsec^2)
Return values:
CPL_ERROR_NONE Everything 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 262 of file muse_sky_lines.c.

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:
aSpectrum Sky spectrum
aLines Sky lines table. The line fluxes are adjusted.
aLsfImage Image to store the LSF.
aWCS The 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_FOUND aSpectrum 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:
aSpectrum Measured sky spectrum.
aLines Sky 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 NULL aStat 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:
aProcessing the 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:
aProcessing the processing structure
aLines the sky lines table
aHeader the 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_INPUT one of the arguments is NULL
return CPL_ERROR_ILLEGAL_INPUT the 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:
aLines sky lines table
aLow lower limit, in Angstrom
aHigh higher limit, in Angstrom
Return values:
CPL_ERROR_NONE Success
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:
aLambda Wavelength array.
aLines Sky emission line table
aLsfImage LSF data to use
aLsfWCS WCS 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(), and muse_lsf_apply().

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:
aHeader header to store the QC parameters for the sky continuum
aContinuum sky continuum table
aPrefix prefix for the QC keywords
Exceptions:
set CPL_ERROR_NULL_INPUT and return one of the input arguments is NULL
set CPL_ERROR_DATA_NOT_FOUND and return aContinuum 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:
aHeader header with the QC parameters for the sky lines
aLines sky line table
aPrefix prefix for the QC keywords
Exceptions:
set CPL_ERROR_NULL_INPUT and return one of the input arguments is NULL
set CPL_ERROR_DATA_NOT_FOUND and return aLines 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:
aProcessing the processing structure
aContinuum the sky continuum table
aHeader the 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_INPUT one of the arguments is NULL
return CPL_ERROR_ILLEGAL_INPUT the 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:
aCube MUSE datacube.
aMask Mask 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:
aPixtable Pixel table. The data column will be changed.
aSpectrum Continuum 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_cplarray_interpolate_table_linear(), muse_cpltable_check(), muse_cpltable_extract_column(), muse_pixtable_def, muse_pixtable_extracted_delete(), muse_pixtable_extracted_get_size(), muse_pixtable_extracted_get_slices(), muse_pixtable_restrict_wavelength(), 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:
aPixtable Pixel table. The data column will be changed.
aLines Line list with individual line fluxes
aLsfCube The 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_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:
aPixtable Pixel table. The data column will be changed.
aLines Line list with individual line fluxes
aLsfParams LSF parameters for the instrument
Return values:
CPL_ERROR_NONE if 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_extracted_delete(), muse_pixtable_extracted_get_size(), muse_pixtable_extracted_get_slices(), muse_pixtable_get_nrow(), muse_pixtable_origin_get_ifu(), muse_pixtable_origin_get_slice(), and muse_pixtable::table.

Referenced by muse_postproc_process_exposure().


Variable Documentation

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().


Generated on 26 Jan 2017 for MUSE Pipeline Reference Manual by  doxygen 1.6.1