MUSE Pipeline Reference Manual  1.0.2
Data Structures | Functions | Variables
Line Spread Function related functions

Data Structures

struct  muse_lsf_params
 Structure definition of detector (slice) parameters. More...
 

Functions

static cpl_error_code muse_lsf_line_apply (const cpl_array *aLambda, cpl_array *aSpectrum, const muse_lsf_params *aLsf, double aLineLambda, double aLineFlux)
 Apply the MUSE LSF function to a single line. More...
 
muse_lsf_paramsmuse_lsf_params_new (cpl_size n_sensit, cpl_size n_lsf_width, cpl_size n_hermit)
 Create a new lsf_params structure. More...
 
cpl_size muse_lsf_params_get_size (muse_lsf_params **aParams)
 Count the number of entries in the array. More...
 
void muse_lsf_params_delete_one (muse_lsf_params *aParams)
 Delete an allocated muse_lsf_params structure. More...
 
void muse_lsf_params_delete (muse_lsf_params **aParams)
 Delete an allocated array of muse_lsf_params structure. More...
 
cpl_error_code muse_lsf_params_save (const muse_lsf_params **aLsf, const char *aFile)
 Save slice LSF parameters to the extension "slice" on disk. More...
 
muse_lsf_params ** muse_lsf_params_load (const char *aFile, muse_lsf_params **aParams, int aIFU)
 Load slice LSF parameters from the extension "SLICE_PARAM". More...
 
muse_lsf_params ** muse_processing_lsf_params_load (muse_processing *aProcessing, int aIFU)
 Load slice LSF parameters. More...
 
muse_lsf_paramsmuse_lsf_params_get (muse_lsf_params **aParams, int aIFU, int aSlice)
 Get the slice LSF parameters for one slice. More...
 
static cpl_array * muse_lsf_G (cpl_array *aX, cpl_array *aCoeffs)
 Helper function "G" for integrated damped gauss-hermitean function. More...
 
cpl_array * muse_lsf_spectrum_get_lines (const cpl_array *aLambda, const cpl_array *aLinesLambda, const cpl_array *aLinesFlux, const muse_lsf_params *aLsf)
 Set the lines spectrum from the lines table and the detector LSF. More...
 
double muse_lsf_fwhm_lambda (const muse_lsf_params *aDP, double aLambda, double aFlux, double aSampling, unsigned int aLength, FILE *aOutstream)
 Measure the FWHM of an LSF at a given wavelength. More...
 

Variables

const muse_cpltable_def muse_lsfparams_def []
 Definition of a lsf parameters table. More...
 

Detailed Description

Function Documentation

double muse_lsf_fwhm_lambda ( const muse_lsf_params aDP,
double  aLambda,
double  aFlux,
double  aSampling,
unsigned int  aLength,
FILE *  aOutstream 
)

Measure the FWHM of an LSF at a given wavelength.

Parameters
aDPthe LSF parameters (for one IFU and slice)
aLambdawavelength at which to evaluate the LSF
aFluxflux of the line to distribute
aSamplingsampling of the spectrum in Angstrom
aLengthlength of spectrum in pixels
aOutstreamfile pointer for verbose output (can be NULL)
Returns
The FWHM of the LSF at this wavelength or 0. on error.

This function creates a spectrum of given aLength with given resolution (aSampling), fills it with a line with given flux (aFlux) at the given wavelength aLambda. This spectrum is then used to measures peak intensity, searches for the position where the intensity reaches half the peak, to derive the FWHM from this. If aOutstream is not NULL, debug output about the parameters and measurement values is written to this file pointer.

Exceptions
set CPL_ERROR_NULL_INPUT, return 0.aDP is NULL
set CPL_ERROR_ILLEGAL_INPUT, return 0.aDP contains lsf_width of zero or one
set CPL_ERROR_ILLEGAL_OUTPUT, return 0.FWHM is outside the test spectrum for the given parameters

Definition at line 710 of file muse/muse_lsf.c.

References muse_lsf_params::bin_width, muse_lsf_params::lambda_ref, muse_lsf_params::lsf_width, muse_lsf_spectrum_get_lines(), and muse_lsf_params::slit_width.

static cpl_array* muse_lsf_G ( cpl_array *  aX,
cpl_array *  aCoeffs 
)
static

Helper function "G" for integrated damped gauss-hermitean function.

Parameters
aXX values array to apply
aCoeffspointer to five values for the damping polynomial
Returns
The return value array.
Exceptions
set CPL_ERROR_NULL_INPUT, return 0.0(aX != NULL) not fulfilled
set CPL_ERROR_NULL_INPUT, return 0.0(aCoeffs != NULL) not fulfilled
Pseudo code:
R(x) = aCoeffs[0] * x**4 + aCoeffs[1] * x**3
     + aCoeffs[2] * x**2 + aCoeffs[3] * x + aCoeffs[4]

G(x) =  exp(-0.5 * x**2)
      + R(x) * exp(-x**2) / 60
      + x * sqrt(Pi/2) * erf(x * sqrt(0.5))

Definition at line 490 of file muse/muse_lsf.c.

References muse_cplarray_erf(), muse_cplarray_exp(), and muse_cplarray_poly1d().

Referenced by muse_lsf_line_apply().

static cpl_error_code muse_lsf_line_apply ( const cpl_array *  aLambda,
cpl_array *  aSpectrum,
const muse_lsf_params aLsf,
double  aLineLambda,
double  aLineFlux 
)
static

Apply the MUSE LSF function to a single line.

Parameters
aLambdaWavelength bins [Angstrom]
aSpectrumSpectrum to add the line
aLsfLSF parameters
aLineLambdaLine wavelength
aLineFluxLine flux
Return values
CPL_ERROR_NONEEverything went OK
CPL_ERROR_NULL_INPUT(aSpectrum != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aParam != NULL) not fulfilled
CPL_ERROR_DATA_NOT_FOUND(cpl_table_has_column(aSpectrum, "lines")) not fulfilled
Pseudo code:
x = (aLambda - aLineLambda) / aLsf.width
slit_width = aLsf.slit_width / aLsf.width
bin_width  = aLsf.bin_width  / aLsf.width

y = G(x + slit_width/2 + bin_width/2) - G(x - slit_width/2 + bin_width/2)
  - G(x + slit_width/2 - bin_width/2) + G(x - slit_width/2 - bin_width/2)

spectrum += y * aLineFlux

Definition at line 549 of file muse/muse_lsf.c.

References muse_lsf_params::bin_width, muse_lsf_params::hermit, muse_lsf_params::lambda_ref, muse_lsf_params::lsf_width, muse_cplarray_add_window(), muse_cplarray_find_sorted(), muse_cplarray_poly1d_double(), muse_lsf_G(), and muse_lsf_params::slit_width.

Referenced by muse_lsf_spectrum_get_lines().

void muse_lsf_params_delete ( muse_lsf_params **  aParams)

Delete an allocated array of muse_lsf_params structure.

Parameters
aParamsStructure to delete.

Definition at line 148 of file muse/muse_lsf.c.

References muse_lsf_params_delete_one().

Referenced by muse_sky_master_delete().

void muse_lsf_params_delete_one ( muse_lsf_params aParams)

Delete an allocated muse_lsf_params structure.

Parameters
aParamsStructure to delete.

Definition at line 129 of file muse/muse_lsf.c.

References muse_lsf_params::hermit, muse_lsf_params::lsf_width, and muse_lsf_params::sensitivity.

Referenced by muse_lsf_params_delete(), muse_lsf_params_fit(), muse_sky_lsf_params_fit(), and muse_sky_slice_apply_lsf_parametrization().

muse_lsf_params* muse_lsf_params_get ( muse_lsf_params **  aParams,
int  aIFU,
int  aSlice 
)

Get the slice LSF parameters for one slice.

Returns
Pointer to parameter structure.

Definition at line 458 of file muse/muse_lsf.c.

Referenced by muse_sky_subtract_pixtable().

cpl_size muse_lsf_params_get_size ( muse_lsf_params **  aParams)

Count the number of entries in the array.

Parameters
aParamsLSF parameter array
Returns
Number of entries in the array.

Definition at line 111 of file muse/muse_lsf.c.

Referenced by muse_lsf_params_load().

muse_lsf_params** muse_lsf_params_load ( const char *  aFile,
muse_lsf_params **  aParams,
int  aIFU 
)

Load slice LSF parameters from the extension "SLICE_PARAM".

Parameters
aFileFile name (file must exist, is written as extension)
aParamsNULL-terminated array of LSF parameters to append to, or NULL.
aIFUthe IFU/channel number, or 0 for all IFUs/channels
Returns
NULL-terminated array of LSF parameters.

The extension "SLICE_PARAM" (or "CHANnn.SLICE_PARAM") is expected to be a table with the slice dependent LSF parameters.

Definition at line 309 of file muse/muse_lsf.c.

References muse_lsf_params::bin_width, muse_lsf_params::hermit, muse_lsf_params::lsf_width, muse_cpltable_get_array_copy(), muse_cpltable_load(), muse_lsf_params_get_size(), muse_lsf_params_new(), muse_lsf_params::sensitivity, and muse_lsf_params::slit_width.

Referenced by muse_processing_lsf_params_load(), and muse_sky_master_load().

muse_lsf_params* muse_lsf_params_new ( cpl_size  n_sensit,
cpl_size  n_lsf_width,
cpl_size  n_hermit 
)

Create a new lsf_params structure.

Parameters
n_sensitOrder of polynomial sensitivity parametrization.
n_lsf_widthOrder of polynomial lsf width parametrization.
n_hermitOrder of polynomial parametrization of hermitean coefficients.
Returns
Structure to hold the data.

All polynomial parametrizations are meant as wavelength dependent.

Definition at line 75 of file muse/muse_lsf.c.

References muse_lsf_params::bin_width, muse_lsf_params::hermit, muse_lsf_params::lambda_ref, muse_lsf_params::lsf_width, muse_lsf_params::sensitivity, and muse_lsf_params::slit_width.

Referenced by muse_lsf_params_fit(), muse_lsf_params_load(), muse_sky_lsf_params_fit(), and muse_sky_slice_apply_lsf_parametrization().

cpl_error_code muse_lsf_params_save ( const muse_lsf_params **  aLsf,
const char *  aFile 
)

Save slice LSF parameters to the extension "slice" on disk.

Parameters
aLsfNULL-terminated array of LSF parameters.
aFileFile name (file must exist, is written as extension)
Return values
CPL_ERROR_NONEif everything went OK
CPL_ERROR_NULL_INPUT(aLsf != NULL) not fulfilled
CPL_ERROR_DATA_NOT_FOUND(*aLsf != NULL) not fulfilled
CPL_ERROR_NULL_INPUT(aFile != NULL) not fulfilled

The slice parameters are converted to a table structure:

  • ifu: IFU number
  • slice: slice number within the IFU
  • sensitivitysensitivity, relative to the reference
  • lsf_width: LSF gauss-hermitean width [Angstrom]
  • hermit3: 3rd order hermitean coefficient
  • hermit4: 4th order hermitean coefficient
  • hermit5: 5th order hermitean coefficient
  • hermit6: 6th order hermitean coefficient

Definition at line 215 of file muse/muse_lsf.c.

References muse_cpltable_append_file().

cpl_array* muse_lsf_spectrum_get_lines ( const cpl_array *  aLambda,
const cpl_array *  aLinesLambda,
const cpl_array *  aLinesFlux,
const muse_lsf_params aLsf 
)

Set the lines spectrum from the lines table and the detector LSF.

Parameters
aLambdaWavelength bins
aLinesLambdaArray with lines wavelengths
aLinesFluxArray with lines fluxes
aLsfLSF parameters
Returns
Spectrum with flux from lines.
Exceptions
set CPL_ERROR_NULL_INPUT, return NULL(aSpectrum != NULL) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aLines != NULL) not fulfilled
set CPL_ERROR_NULL_INPUT, return NULL(aLsf != NULL) not fulfilled
Pseudo code:
spectrum = 0
for line in aLines:
    spectrum += muse_lsf_line_apply(aLsf, line.lambda, line.flux)
return spectrum

Definition at line 655 of file muse/muse_lsf.c.

References muse_lsf_line_apply().

Referenced by muse_lsf_fwhm_lambda(), muse_lsf_params_fit(), and muse_sky_apply_lsf().

muse_lsf_params** muse_processing_lsf_params_load ( muse_processing aProcessing,
int  aIFU 
)

Load slice LSF parameters.

Parameters
aProcessingthe processing structure
aIFUthe IFU/channel number, or 0 for all IFUs/channels
Returns
a pointer to the LSF params or NULL on error
Exceptions
set CPL_ERROR_NULL_INPUT, return NULLinvalid processing pointer
propagate CPL error code, return NULLLST_TABLE frame not found in input frameset of the processing structure

The input files must be tables with the slice dependent LSF parameters.

Definition at line 393 of file muse/muse_lsf.c.

References muse_processing::inframes, muse_frameset_find(), muse_lsf_params_load(), and muse_processing_append_used().

Variable Documentation

const muse_cpltable_def muse_lsfparams_def[]
Initial value:
= {
{"ifu", CPL_TYPE_INT, NULL, "%i", "IFU number", CPL_TRUE},
{"slice", CPL_TYPE_INT, NULL, "%i", "slice number within the IFU", CPL_TRUE},
{"sensitivity", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, NULL, "%e",
"detector sensitivity, relative to the reference", CPL_TRUE},
{"offset", CPL_TYPE_DOUBLE, NULL, "%e", "wavelength calibration offset", CPL_TRUE},
{"refraction", CPL_TYPE_DOUBLE, NULL, "%e", "relative refraction index", CPL_TRUE},
{"slit_width", CPL_TYPE_DOUBLE, "Angstrom", "%e", "slit width", CPL_TRUE},
{"bin_width", CPL_TYPE_DOUBLE, "Angstrom", "%e", "bin width", CPL_TRUE},
{"lsf_width", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, "Angstrom", "%e",
" LSF gauss-hermitean width", CPL_TRUE},
{"hermit3", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, NULL, "%e",
"3rd order hermitean coefficient", CPL_TRUE},
{"hermit4", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, NULL, "%e",
"4th order hermitean coefficient", CPL_TRUE},
{"hermit5", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, NULL, "%e",
"5th order hermitean coefficient", CPL_TRUE},
{"hermit6", CPL_TYPE_DOUBLE | CPL_TYPE_POINTER, NULL, "%e",
"6th order hermitean coefficient", CPL_TRUE},
{ NULL, 0, NULL, NULL, NULL, CPL_FALSE }
}

Definition of a lsf parameters table.

  • ifu: IFU number
  • slice: slice number within the IFU
  • sensitivitysensitivity, relative to the reference
  • lsf_width: LSF gauss-hermitean width [Angstrom]
  • hermit3: 3rd order hermitean coefficient
  • hermit4: 4th order hermitean coefficient
  • hermit5: 5th order hermitean coefficient
  • hermit6: 6th order hermitean coefficient

Definition at line 173 of file muse/muse_lsf.c.