ERIS Pipeline Reference Manual 1.9.2
sc_weights.h File Reference
#include <sc_basic.h>

Go to the source code of this file.

#define SC_COLDEPTH   10
 
#define SC_EXTRACOVER   5
 
#define SC_SAMPFAC   5.
 
#define SC_LIMRELLAMVAR   0.01
 
#define SC_BINS_PER_FWHM   200.
 
#define SC_KERNFAC   3.
 
cpl_error_code sc_weights (cpl_table *skyspec, cpl_table *fitpar, cpl_table *groups, cpl_parameterlist *parlist)
 
cpl_error_code sc_weights_initfitpar (cpl_table *fitpar, cpl_parameterlist *parlist, const cpl_table *groups)
 
cpl_error_code sc_weights_getpixcontrib (cpl_table *skyspec, cpl_table *fitpar, cpl_table *groups, const cpl_parameterlist *parlist)
 
cpl_error_code sc_weights_createwavegrid (cpl_table *groupspec, const cpl_table *skyspec)
 
cpl_error_code sc_weights_getgrouplines (cpl_table *groupspec, cpl_table *fitpar, cpl_table *groups, const cpl_parameterlist *parlist, const char grouptype, const int group)
 
cpl_error_code sc_weights_convolve (cpl_table *groupspec, const double fwhm, const double reflam, const double speedpar)
 
cpl_error_code sc_weights_calckernel (cpl_array *kernel, const double fwhm)
 
cpl_error_code sc_weights_rebinspec (cpl_table *skyspec, const cpl_table *groupspec)
 
cpl_error_code sc_weights_fillgrouparrays (cpl_table *skyspec, const char grouptype, const int group)
 
cpl_error_code sc_weights_normpixcontrib (cpl_table *skyspec, const char grouptype)
 
cpl_error_code sc_weights_getdomgroups (cpl_table *skyspec, const cpl_parameterlist *parlist, const char grouptype)
 

Detailed Description

Header for library for preparing the line group weights of each pixel of the input sky spectrum

Author
Stefan Noll & ESO In-Kind Team Innsbruck
Since
14 Feb 2011
Date
17 Jul 2013

Definition in file sc_weights.h.

Macro Definition Documentation

◆ SC_BINS_PER_FWHM

#define SC_BINS_PER_FWHM   200.

Bins per FWHM for integral of Gaussian

Definition at line 74 of file sc_weights.h.

◆ SC_COLDEPTH

#define SC_COLDEPTH   10

Initial depth of array columns for line group weights

Definition at line 64 of file sc_weights.h.

◆ SC_EXTRACOVER

#define SC_EXTRACOVER   5

Extra pixels at both sides of the airglow model spectrum (pixel scale of input sky spectrum)

Definition at line 67 of file sc_weights.h.

◆ SC_KERNFAC

#define SC_KERNFAC   3.

Radius of Gaussian kernel in FWHM/2

Definition at line 76 of file sc_weights.h.

◆ SC_LIMRELLAMVAR

#define SC_LIMRELLAMVAR   0.01

Threshold for recalculation of kernel depending on relative change of wavelength

Definition at line 72 of file sc_weights.h.

◆ SC_SAMPFAC

#define SC_SAMPFAC   5.

Oversampling factor for airglow model spectrum

Definition at line 69 of file sc_weights.h.

Function Documentation

◆ sc_weights()

cpl_error_code sc_weights ( cpl_table *  skyspec,
cpl_table *  fitpar,
cpl_table *  groups,
cpl_parameterlist *  parlist 
)

Derives line group weights for each pixel of the input sky spectrum.

INPUT:

Parameters
skyspecCPL table with sky spectrum
groupsCPL table with airglow line information
parlistinput CPL parameter list

OUTPUT:

Parameters
skyspecsky spectrum with line group weights
fitparCPL table of fit parameters
groupsmodified line table
parlistparameter list complemented by weight-specific parameters

ERRORS:

  • none

Definition at line 49 of file sc_weights.c.

References sc_weights_getpixcontrib(), and sc_weights_initfitpar().

Referenced by sc_skycorr_fit().

◆ sc_weights_calckernel()

cpl_error_code sc_weights_calckernel ( cpl_array *  kernel,
const double  fwhm 
)

Calculates Gaussian kernel depending on the FWHM provided by the general parameter list. The number of kernel pixels is the upper odd integer number of the input FWHM times SC_KERNFAC. The sum of the kernel values is normalised to 1.

INPUT:

Parameters
fwhmFWHM of Gaussian in pixels

OUTPUT:

Parameters
kernelCPL array with convolution kernel elements

ERRORS:

  • Invalid object value(s)

Definition at line 755 of file sc_weights.c.

References SC_BINS_PER_FWHM, SC_KERNFAC, and SC_MAXLEN.

Referenced by sc_weights_convolve().

◆ sc_weights_convolve()

cpl_error_code sc_weights_convolve ( cpl_table *  groupspec,
const double  fwhm,
const double  reflam,
const double  speedpar 
)

Convolves line group spectrum with a wavelength-dependent Gaussian kernel. The scaling of the kernel width is forced by the assumption of constant resolution. The speedpar parameter rules the number of kernel calculations. It provides the relative wavelength change that causes a recalculation. If a constant kernel is desired, speedpar has to be set to HUGE_VAL.

INPUT:

Parameters
groupspecCPL table with input line group spectrum
fwhmwidth of Gaussian in pixels
reflamreference wavelength for fwhm
speedparcriterion for recalculation of kernel (relative change of kernel width)

OUTPUT:

Parameters
groupspecconvolved spectrum

ERRORS:

  • No data
  • Invalid input parameter(s)
  • Invalid object structure

Definition at line 620 of file sc_weights.c.

References sc_basic_convolvewindow(), SC_MAXLEN, and sc_weights_calckernel().

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_createwavegrid()

cpl_error_code sc_weights_createwavegrid ( cpl_table *  groupspec,
const cpl_table *  skyspec 
)

Creates a wavelength grid for line group spectra. The original grid of the input sky spectrum is extended by SC_EXTRACOVER pixels on each margin and split up in SC_SAMPFAC smaller pixels for a better sampling. The output spectrum consists of three columns that provide the central wavelength, the lower wavelength limit, and the flux for each pixel. The latter is always zero.

INPUT:

Parameters
skyspecCPL table with sky spectrum

OUTPUT:

Parameters
groupspecCPL table with wavelength grid for line group spectra

ERRORS:

  • none

Definition at line 416 of file sc_weights.c.

References SC_EXTRACOVER, and SC_SAMPFAC.

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_fillgrouparrays()

cpl_error_code sc_weights_fillgrouparrays ( cpl_table *  skyspec,
const char  grouptype,
const int  group 
)

Writes ID and flux contribution of the provided group into pixel-specific arrays of the sky spectrum columns belonging to the given group type. The array size depends on the pixel with the highest number of contributing line groups. Unused array elements remain invalid.

INPUT:

Parameters
skyspecCPL table with sky and line group spectrum
grouptypeline group type (either 'A' or 'B')
groupnumber of line group

OUTPUT:

Parameters
skyspecsky spectrum with updated pixel-specific group flux arrays

ERRORS:

  • none

Definition at line 936 of file sc_weights.c.

References SC_LENLINE.

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_getdomgroups()

cpl_error_code sc_weights_getdomgroups ( cpl_table *  skyspec,
const cpl_parameterlist *  parlist,
const char  grouptype 
)

Gets the IDs of the dominating line group of each pixel and writes them into the sky spectrum table. A line group is only considered if it has a minimum weight of weightlim which is provided by the general parameter list. If such a group does not exist for a pixel, -99 is written.

INPUT:

Parameters
skyspecCPL table of sky spectrum with pixel-specific group weight arrays
parlistinput CPL parameter list
grouptypeline group type (either 'A' or 'B')

OUTPUT:

Parameters
skyspecsky spectrum table with column of dominating groups

ERRORS:

  • none

Definition at line 1089 of file sc_weights.c.

References SC_LENLINE.

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_getgrouplines()

cpl_error_code sc_weights_getgrouplines ( cpl_table *  groupspec,
cpl_table *  fitpar,
cpl_table *  groups,
const cpl_parameterlist *  parlist,
const char  grouptype,
const int  group 
)

Writes line fluxes of a selected group into line group spectrum if the group can be found in the wavelength range covered by the output spectrum. Moreover, for missing groups the relevance and fit flags in the fit parameter table are set to 0.

Note
The input line table remains in a selected state after the end of the routine.

INPUT:

Parameters
groupspecCPL table with wavelength grid for line group spectra
fitparCPL table of fit parameters
groupsCPL table with lines and group classification
parlistinput CPL parameter list
grouptypeline group type (either 'A' or 'B')
groupnumber of line group

OUTPUT:

Parameters
groupspecspectrum with the fluxes of a single line group
fitpartable of fit parameters with updated fit flags

ERRORS:

  • none

Definition at line 528 of file sc_weights.c.

References SC_LENLINE.

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_getpixcontrib()

cpl_error_code sc_weights_getpixcontrib ( cpl_table *  skyspec,
cpl_table *  fitpar,
cpl_table *  groups,
const cpl_parameterlist *  parlist 
)

Calculates spectrum for each line group and gets group contributions to each pixel of the input sky spectrum. Depending on the parameter varfwhm, the line widths are constant or linearly-increasing with wavelength.

INPUT:

Parameters
skyspecCPL table with sky spectrum
fitparCPL table of fit parameters
groupsCPL table with airglow line information
parlistinput CPL parameter list

OUTPUT:

Parameters
skyspecsky spectrum with line group weights
fitpartable of fit parameters with adapted fit flags
groupsline list for wavelength range of sky spectrum only

ERRORS:

  • none

Definition at line 253 of file sc_weights.c.

References SC_COLDEPTH, SC_LENLINE, SC_LIMRELLAMVAR, SC_SAMPFAC, sc_weights_convolve(), sc_weights_createwavegrid(), sc_weights_fillgrouparrays(), sc_weights_getdomgroups(), sc_weights_getgrouplines(), sc_weights_normpixcontrib(), and sc_weights_rebinspec().

Referenced by sc_weights().

◆ sc_weights_initfitpar()

cpl_error_code sc_weights_initfitpar ( cpl_table *  fitpar,
cpl_parameterlist *  parlist,
const cpl_table *  groups 
)

Creates table of fit parameters. There are table columns for parameter type, ID number, system flag, relevance flag, fit flag, value, fit error, estimate error, and number of lines. The parameter types are either the line groups 'A' and 'B' or 'w' for the coefficients of the Chebyshev polynomial for the wavelength grid correction. The number N is a counter that starts with 1 in the case of the line groups and with 0 in the case of the polynomial and the ${\sigma}$-clipping limit. The system flag indicates fit parameters that are connected (e.g. A and B groups of OH lines). By default the relevance and fit flags are set to 1 (valid fit parameter) for all parameters. The initial parameter value is 1 for the line groups. For the 'w' type the coefficient with N = 1 is set to 1 and the remaining ones become 0. This setup ensures that there is no wavelength correction by default. The number of wavelength coefficients is given by the driver parameter cheby_max. An exception is a selected degree of 0 for which also the linear coefficient has to be provided to reproduce the input wavelength grid. For the coefficients of the polynomial the initial relevance and fit flags are set to 0. The fit and estimate error columns as well as the number of lines column are initialised with 0 for all parameters. Finally, the general CPL parameter list is supplemented by the maximum N of the parameter types 'A' and 'B' and the number of parameter systems.

INPUT:

Parameters
parlistinput CPL parameter list
groupsCPL table with airglow line information

OUTPUT:

Parameters
fitparCPL table of fit parameters
parlistparameter list complemented by line group counts

ERRORS:

  • none

Definition at line 88 of file sc_weights.c.

Referenced by sc_weights().

◆ sc_weights_normpixcontrib()

cpl_error_code sc_weights_normpixcontrib ( cpl_table *  skyspec,
const char  grouptype 
)

Divides group flux by flux sum for each pixel to get weights. The operation is performed for the sky spectrum group-weight column belonging to the given group type.

INPUT:

Parameters
skyspecCPL table of sky spectrum with pixel-specific group flux arrays
grouptypeline group type (either 'A' or 'B')

OUTPUT:

Parameters
skyspecsky spectrum with pixel-specific group weight arrays

ERRORS:

  • none

Definition at line 1027 of file sc_weights.c.

References SC_LENLINE.

Referenced by sc_weights_getpixcontrib().

◆ sc_weights_rebinspec()

cpl_error_code sc_weights_rebinspec ( cpl_table *  skyspec,
const cpl_table *  groupspec 
)

Rebins line group spectrum to wavelength grid of input sky spectrum. The resulting fluxes are written in two temporary columns in the sky spectrum: "f_group" for the selected group and "f_all" for the sum flux of all groups. This routine reverses the operations performed in sc_weights_createwavegrid.

INPUT:

Parameters
skyspecCPL table with sky spectrum
groupspecCPL table with line group spectrum

OUTPUT:

Parameters
skyspecCPL table with sky and rebinned line group spectrum

ERRORS:

  • Invalid object structure

Definition at line 871 of file sc_weights.c.

References SC_EXTRACOVER, SC_MAXLEN, and SC_SAMPFAC.

Referenced by sc_weights_getpixcontrib().