norton_beer package
Module contents
norton_beer
The ‘norton_beer’ library is a python tool box for the Norton-Beer apodization functions.
- Provides:
Norton-Beer apodization window generation in spatial domain
the analytical Fourier transform of the apodization window also known as instrument line shape (ILS)
generation of new apodization window for a fixed spatial resolution of the ILS so that the sides lobes are minimized
Installation
To use norton_beer, first install it using pip:
pip install norton-beer
Testing
To test the norton_beer package, clone the repository from github (https://github.com/konstntokas/norton_beer) and run:
pytest
Note that pytest needs to be installed on the local machine.
Available modules
- apodization
generation of apodization window in spatial domain
- ils
generation of ILS in spectral domain
- optimize
generation of new apodizations for a fixed spatial resolution of the ILS so that the sides lobes are minimized
Further references
Submodules
norton_beer.apodization module
Norton-Beer apodization window in spatial domain
This subpackage contains the generation of Norton-Beer apodization window in spatial domain for any given set pf parameters. The Norton-Beer apodization function class was firstly presented in [1] and [2]. Note, that the sum of the parameters must be equal to 1. Further, if a float from [1.0, 1.1, 1.2, …, 2.0], is given, the parameters are used from [3].
This file is part of norton_beer.
- norton_beer.apodization.check_input(par)
auxiliary function to assign FWHM to parameters, if given.
- Parameters:
par (float or 1darrray) – parameters of Norton-Beer apodization; if float is given, it must be one of [1.0, 1.1, …, 2.0] to use the predefined parameters from <_NORTON_BEER_PARAMS>
- Returns:
par – parameters of Norton-Beer apodization
- Return type:
1darray
- norton_beer.apodization.norton_beer(N, par)
This function generates the Norton-Beer apodization.
- Parameters:
N (int) – number of samples
par (float or 1darrray) – parameters of Norton-Beer apodization; if float is given, it must be one of [1.0, 1.1, …, 2.0] and corresponds to the relative FWHM, which uses the published parameters in [3]
- Returns:
apo – Norton-Beer apodization window
- Return type:
1darray
Notes
References of the Norton-Beer apodization function class are given in [1], [2] and [3]
norton_beer.ils module
ILS of Norton-Beer apodization window in spectral domain
This subpackage contains the generation of the analytical Fourier transform of the Norton-Beer apodization in spectral domain for any given set pf parameters. The Norton-Beer apodization function class was firstly presented in [1] and [2]. Note, that the sum of the parameters must be equal to 1. Further, if a float from [1.0, 1.1, 1.2, …, 2.0], is given, the parameters are used from [3].
This file is part of norton_beer.
- norton_beer.ils.calculate_fwhm(x, y)
This function calculates the full width at half maximum (FWHM) relative to sinc-function.
- Parameters:
x (1darry) – abscissa
y (1darray) – ordinate
- Returns:
fwhm (float) – full width at half maximum
range_fwhm (array-like with two entries) – start and end of FWHM on x-axis
half (float) – half of maximal value
- norton_beer.ils.calculate_secmax(y)
This function calculates the maximal value of side lobes relative to sinc-function
- Parameters:
y (1darray) – ordinate
- Returns:
secmax (float) – absolute maximum of side lobes
secmax_rel (float) – absolute maximum of side lobes relative to sinc
- norton_beer.ils.lin_interp(x, y, i, half)
This function does linear interpolation between two values at position <index> and <index>+1.
- Parameters:
x (1darry) – abscissa
y (1darray) – ordinate
i (int) – index
half (float) – half of maximal value
- Returns:
interpolated value of x-axis at half of maximal value
- Return type:
float
- norton_beer.ils.norton_beer(k, ifglen, par, check_input=True)
This function creates the analytical Fourier Transform of the Norton-Beer apodization.
- Parameters:
k (1darray) – spectral axis
ifglen (float) – signal length
par (float or 1darrray) – parameters of Norton-Beer apodization; if float is given, it must be one of [1.0, 1.1, …, 2.0] and corresponds to the relative FWHM, which uses the published parameters in [3]
check_input (bool, optional) – if True, input is modified for 2 things; firstly, if float is given for <par>, predefined parameters presented by Naylor and Tahic 2007 are used; secondly, it is checked weather sum over parameters is equal to one
- Returns:
result – Fourier transform of Norton-Beer apodization window
- Return type:
1darray
Notes
References of the Norton-Beer apodization function class are given in [1], [2] and [3].
- norton_beer.ils.norton_beer_numerical(k, ifglen, par, nb_sample=100001)
This function generates the ILS numerically via discrete Fourier Transform.
- Parameters:
k (1darray) – spectral axis
ifglen (float) – signal length
par (float or 1darray) – parameters of Norton-Beer apodization
nb_samples (int, optional) – number of samples, should be odd, by default 100001
- Returns:
ils (1darray) – numerical Fourier transformation of Norton-Beer apodization window
ils_x (1darray) – corresponding spectral axis; should be close to <k>
norton_beer.optimize module
Optimization to generation new apodization windows
This subpackage contains the generation of new Norton-Beer apodization windows, where the spectral resolution of its Fourier transform if fixed by the user and the parameters are optimized so that the side lobes of the Fourier transform are minimized. A wrapper function is available, which optimizes the number of parameters needed.
This file is part of norton_beer.
- norton_beer.optimize.boundary_line(fwhm)
This function calculates the relative maximum values defined by the boundary line given by Norton and Beer (1976) doi: 10.1364/JOSA.66.000259
- Parameters:
fwhm (float, ndarray) – full width at half maximum (FWHM) relative to sinc-function
- Returns:
absolute maximum of side lobes relative to sinc-function
- Return type:
float, ndarray
- norton_beer.optimize.optimize_nbpar(fwhm_want, fac=500.0)
This function finds the optimal number of parameters and returns the set of optimized parameters and the full width at half maximum (FWHM) (fwhm) and absolute maximum of the side lobe relative to sinc-function.
- Parameters:
fwhm_want (float) – wanted relative full width at half maximum (FWHM)
fac (float, optional) – weight of fwhm difference in optimization; large values entails an optimized apodization which ILS’s FWHM is close to the wanted FWHM, by default 500.
- Returns:
par (1darray) – optimized parameters for Norton-Beer apodization
fwhm (float) – full width at half maximum (FWHM) relative to sinc-function
secmax (float) – absolute maximum of side lobes relative to sinc-function
- norton_beer.optimize.optimize_par(fwhm_want, nbpar, fac=500.0)
This function optimizes the parameters of Norton-Beer apodization for a given number of parameters and full width at half maximum (FWHM)
- Parameters:
fwhm_want (float) – wanted relative full width at half maximum (FWHM)
nbpar (int) – number of parameters
fac (float, optional) – weight of fwhm difference in optimization; large values entails an optimized apodization which ILS’s FWHM is close to the wanted FWHM, by default 500.
- Returns:
par (1darray) – optimized parameters for Norton-Beer apodization
fwhm (float) – full width at half maximum relative to sinc-function
secmax (float) – absolute maximum of side lobes relative to sinc-function