NuRadioReco.modules.voltageToAnalyticEfieldConverter module
- NuRadioReco.modules.voltageToAnalyticEfieldConverter.covariance(function, vmin, up, fast=False)[source]
Numerically compute the covariance matrix from a chi^2 or -logLikelihood function.
- Parameters:
- function: function-like
The function may accept only a vector argument and has to return a scalar.
- vmin: array of floats
Position of the minimum.
- up: float
Threshold value to pass when climbing uphill. up = 1 for a chi^2 function up = 0.5 for a -logLikelihood function
- fast: boolean
If true invert hesse matrix at the minimum, use this if computing function is expensive.
Notes
The algorithm is slow (it needs many function evaluations), but robust. The covariance matrix is derived by explicitly following the chi^2 or -logLikelihood function uphill until it crosses the 1-sigma contour.
The fast alternative is to invert the hessian matrix at the minimum.
Author: Hans Dembinski <hans.dembinski@kit.edu>
Examples
>>> cov = ((2.0,0.2),(0.2,2.0)) >>> invcov = np.linalg.inv(cov) >>> xs = np.array((1.0,-1.0)) >>> def ChiSquare(pars, grad = None): return np.dot(xs-pars,np.dot(invcov,xs-pars)) >>> def NegLogLike(pars, grad = None): return 0.5*ChiSquare(pars) >>> covariance(ChiSquare, xs, 1.0) array([[ 2. , 0.2], [ 0.2, 2. ]]) >>> covariance(ChiSquare, xs, 1.0, fast=True) array([[ 2. , 0.2], [ 0.2, 2. ]]) >>> covariance(NegLogLike, xs, 0.5) array([[ 2. , 0.2], [ 0.2, 2. ]]) >>> covariance(NegLogLike, xs, 0.5, fast=True) array([[ 2. , 0.2], [ 0.2, 2. ]])
- NuRadioReco.modules.voltageToAnalyticEfieldConverter.stacked_lstsq(L, b, rcond=1e-10)[source]
Solve L x = b, via SVD least squares cutting of small singular values L is an array of shape (…, M, N) and b of shape (…, M). Returns x of shape (…, N)
- class NuRadioReco.modules.voltageToAnalyticEfieldConverter.voltageToAnalyticEfieldConverter[source]
Bases:
object
reconstucts the electric-field by foward folding an analytic pulse function through the antenna
This module works only for cosmic rays so far. The cosmic-ray radio pulse can be described in Fourier space with a simple exponential function for the magnitude as a function of frequency. The phase is set to zero. A slope in the phase spectrum corresponds to a translation in time. In each iteration step, the time shift is set to the shift that results in the maximal cross correlation.
The module also calculates the polarization angle and the energy fluence from the fit parameters.
Methods
begin
()begin method.
run
(evt, station, det[, debug, ...])run method.
end
- begin()[source]
begin method. This function is executed before the event loop.
The antenna pattern provider is initialized here.
- run(evt, station, det, debug=False, debug_plotpath=None, use_channels=None, bandpass=None, use_MC_direction=False)[source]
run method. This function is executed for each event
- Parameters:
- evt
- station
- det
- debug: bool
if True debug plotting is enables
- debug_plotpath: string or None
if not None plots will be saved to a file rather then shown. Plots will be save into the debug_plotpath directory
- use_channels: array of ints (default: [0, 1, 2, 3])
the channel ids to use for the electric field reconstruction default: 0 - 3
- bandpass: [float, float] (default: [100 * units.MHz, 500 * units.MHz])
the lower and upper frequecy for which the analytic pulse is calculated. A butterworth filter of 10th order and a rectangular filter is applied. default 100 - 500 MHz
- use_MC_direction: bool
use simulated direction instead of reconstructed direction