Python version - Methods
- class glow.freq_domain.Fw_FFT_OldReg(It, p_prec={})
Bases:
FwGeneral
Computation of the amplification factor as the FFT of \(I(\tau)\).
This class uses the information about the images stored in
p_crits
to regularize the time-domain integral:\[I_\text{reg}(\tau) \equiv I(\tau) - I_\text{sing}(\tau)\]where \(I_\text{sing}(\tau)\) is analytical and depends on the images. This regular part is then Fourier transformed (with a FFT) to obtain \(F_\text{reg}(w)\). Finally, we add back the (analytical) Fourier transform of the singular part, \(F_\text{sing}(w)\), to get the amplification factor:
\[F(w) = F_\text{reg}(w) + F_\text{sing}(w)\]Additional information: theory, default parameters.
(Only new parameters and attributes are documented. See
FwGeneral
for the internal information of the parent class)- Parameters:
- p_precdict, optional
Precision parameters. New keys:
wmin
,wmax
(float) – Minimum and maximum frequencies to be computed.window_transition
(float) – Width of the Tukey window function.smallest_tau_max
(float) – Ensure that \(I(\tau)\) is always computed, at least, up to this value.eval_mode
(str) – Behaviour ofeval_Fw()
, to compute \(F(w)=F_\text{reg}(w)+F_\text{sing}(w)\). In both cases, \(F_\text{reg}\) is computed with a FFT on a grid and then evaluated using an interpolation function. The two options control how \(F_\text{sing}\) is computed.'interpolate'
: \(F_\text{sing}(w)\) is precomputed on the same grid as \(F_\text{reg}\), and then evaluated using an interpolation function.'exact'
: \(F_\text{sing}(w)\) is evaluated analytically for each \(w\).
FFT type
(str) – Choose the FFT solver. The options are Numpy ('numpy'
) and Scipy ('scipy'
). The differences are minimal.FFT method
(str) – The options are:'standard'
: Perform a single FFT. When the frequency range is very large, this method can become very time-consuming and noisy.'multigrid'
,'multigrid_stack'
: Perform independent FFTs, with varying time resolution, and patch them together.
N_above_discard
,N_below_discard
,N_keep
(int) – Parameters used with the'multigrid'
option. In this mode, the frequency range is divided into \(n = \frac{1}{N_\text{keep}}\log(w_\text{max}/w_\text{min})\) intervals of frequency, logarithmically spaced. We then perform \(n\) independent FFTs in these intervals. To reduce the errors at high and low frequencies we actually perform the FFT in each interval starting from higher and lower frequencies (that are later discarded). The actual size of each of the FFTs is \(\log_2(N_{FFT}) = N_\text{below} + N_\text{keep} + N_\text{above}\).
- Attributes:
- w_gridarray
Grid of frequencies where the FFT has been computed.
- Fw_reg_gridarray
FFT of the regular part of the time-domain integral, i.e. \(F_\text{reg}(w)\).
- Fw_gridarray
If we are working in the inteporlation mode,
Fw_grid
stores the grid of values that will be used for interpolation. Otherwise it contains zeroes.
Methods
compute
(eval_It)Computation of \(F(w)\).
compute_FFT
(Is)Compute the FFT of an array.
compute_FFT_freq
(N_fft, dtau[, imin, imax])Compute the FFT of a quantity
compute_It_FFT
(fmin, fmax, eval_It)Compute the (windowed) FFT of a function in a frequency range.
compute_multigrid
(wmin, wmax, eval_It)Computation of \(F(w)\) patching together several FFTs.
compute_multigrid_stack
(wmin, wmax, eval_It)Computation of \(F(w)\) patching together several FFTs.
compute_standard
(wmin, wmax, eval_It)Computation of \(F(w)\) with a single FFT, between a maximum and minimum frequency.
(subclass defined) Initialize the default parameters.
get_freq_multigrid
(wmin, wmax)Compute the frequency ranges for the FFTs with the multigrid method.
get_window
(N_fft)Compute the Tukey window function.
tau_range
(fmin, fmax)Compute the time array for the FFT.
transform_Fw
(tau_min, dtau, f_fft, It_fft)Final transformations of the FFT of \(I(\tau)\) to get \(F(w)\).
- default_params()
(subclass defined) Initialize the default parameters.
- tau_range(fmin, fmax)
Compute the time array for the FFT.
Given a frequency range, we compute the times where we need to evaluate our function to perform the FFT. We include some corrections for the window size and the requirements set by
smallest_tau_max
.- Parameters:
- fmin, fmaxfloat
Minimum and maximum frequencies for the FFT.
- Returns:
- tau_min, tau_maxfloat
Minimum and maximum times of the time array (which will be equally spaced).
- N_fftint
Size of the array, i.e. size of the FFT.
- get_window(N_fft)
Compute the Tukey window function.
- Returns:
- windowarray
Tukey window function.
- compute_FFT(Is)
Compute the FFT of an array.
- Returns:
- I_fftarray
Real FFT of the input.
- compute_FFT_freq(N_fft, dtau, imin=0, imax=None)
Compute the FFT of a quantity
- compute_It_FFT(fmin, fmax, eval_It)
Compute the (windowed) FFT of a function in a frequency range.
- Parameters:
- fmin, fmaxfloat
Frequency range.
- eval_Itfunc(float or array) -> float or array
Function to be transformed.
- Returns:
- tau_minfloat
Minimum time sampled.
- dtaufloat
Spacing of the time array, i.e. temporal resolution.
- f_fftarray
Frequencies.
- It_fftarray
FFT of the input function in the frequency range.
- transform_Fw(tau_min, dtau, f_fft, It_fft)
Final transformations of the FFT of \(I(\tau)\) to get \(F(w)\).
- Parameters:
- tau_minfloat
Minimum time in the grid.
- dtaufloat
Time spacing.
- f_fft, It_fftarray
Frequency grid and FFT.
- Returns:
- warray
Angular frequency, \(w=2\pi f\).
- Fwarray
Amplification factor.
- compute_standard(wmin, wmax, eval_It)
Computation of \(F(w)\) with a single FFT, between a maximum and minimum frequency.
- Parameters:
- wmin, wmax: float
Minimum and maximum frequencies \(w\).
- eval_Itfunc(float or array) -> float or array
\(I(\tau)\).
- Returns:
- w_grid, Fw_gridarray
Grids with the frequencies and \(F(w)\).
- get_freq_multigrid(wmin, wmax)
Compute the frequency ranges for the FFTs with the multigrid method.
The length of the output corresponds to the number of different FFTs that will be computed.
- Parameters:
- wmin, wmaxfloat
Minimum and maximum angular frequencies, \(w=2\pi f\).
- Returns:
- fmin_batch, fmax_batcharray
Minimum and maximum frequencies that will be kept for each FFT.
- fmin_real, fmax_realarray
Minimum and maximum frequencies that will be actually computed for each FFT.
- compute_multigrid(wmin, wmax, eval_It)
Computation of \(F(w)\) patching together several FFTs.
- Parameters:
- wmin, wmax: float
Minimum and maximum frequencies \(w\).
- eval_Itfunc(float or array) -> float or array
\(I(\tau)\).
- Returns:
- w_grid, Fw_gridarray
Grids with the frequencies and \(F(w)\).
- compute_multigrid_stack(wmin, wmax, eval_It)
Computation of \(F(w)\) patching together several FFTs.
- Parameters:
- wmin, wmax: float
Minimum and maximum frequencies \(w\).
- eval_Itfunc(float or array) -> float or array
\(I(\tau)\).
- Returns:
- w_grid, Fw_gridarray
Grids with the frequencies and \(F(w)\).
- compute(eval_It)
Computation of \(F(w)\).
- Parameters:
- eval_Itfunc(float or array) -> float or array
\(I(\tau)\).
- Returns:
- w_grid, Fw_gridarray
Grids with the frequencies and \(F(w)\).
- class glow.freq_domain.Fw_SemiAnalyticSIS(y, p_prec={}, psi0=1)
Bases:
FwGeneral
Semi-analytic computation of the amplification factor for the SIS.
To arrive at this result, the radial integral is first solved analitically and then the angular integral is performed numerically.
Additional information: theory, default parameters.
(Only new parameters and attributes are documented. See
FwGeneral
for the internal information of the parent class)- Parameters:
- yfloat
Impact parameter.
- psi0float
Normalization of the SIS lensing potential, \(\psi(x)=\psi_0 x\).
Methods
compute
(w)Computation of \(F(w)\).
Warning
This implementation only allows for not very large frequencies (around \(w\) < 100) and it is pretty slow. Try
Fw_SemiAnalyticSIS_C
for a faster version.- compute(w)
Computation of \(F(w)\).
- Parameters:
- wfloat or array
Dimensionless frequency \(w\).
- Returns:
- Fwcomplex or array
\(F(w)\).
- class glow.freq_domain.Fw_AnalyticPointLens(y, p_prec={})
Bases:
FwGeneral
Analytic computation of the amplification factor for the point lens.
Additional information: theory, default parameters.
(Only new parameters and attributes are documented. See
FwGeneral
for the internal information of the parent class)- Parameters:
- yfloat
Impact parameter.
- p_precdict, optional
Precision parameters. New keys:
dps
(int) – Number of decimal places used by mpmath.
Methods
compute
(w)Computation of \(F(w)\).
(subclass defined) Initialize the default parameters.
Warning
Very slow. It requires the mpmath module since the hypergeometric function in Scipy does not allow for complex parameters (only argument). The alternative implementation
Fw_AnalyticPointLens_C
is several orders of magnitude faster. It uses several analytical approximations calibrated to achieve approximately single precision.- default_params()
(subclass defined) Initialize the default parameters.
- compute(w)
Computation of \(F(w)\).
- Parameters:
- wfloat or array
Dimensionless frequency \(w\).
- Returns:
- Fwcomplex or array
\(F(w)\).