Fourier

class emg3d.utils.Fourier(time, fmin, fmax, signal=0, ft='dlf', ftarg=None, **kwargs)[source]

Bases: object

Time-domain CSEM computation.

Class to carry out time-domain modelling with the frequency-domain code emg3d. Instances of the class take care of computing the required frequencies, the interpolation from coarse, limited-band frequencies to the required frequencies, and carrying out the actual transform.

Everything related to the Fourier transform is done by utilising the capabilities of the 1D modeller empymod. The input parameters time, signal, ft, and ftarg are passed to the function empymod.utils.check_time() to obtain the required frequencies. The actual transform is subsequently carried out by calling empymod.model.tem(). See these functions for more details about the exact implementations of the Fourier transforms and its parameters. Note that also the verb-argument follows the definition in empymod.

The mapping from computed frequencies to the frequencies required for the Fourier transform is done in three steps:

  • Data for \(f>f_\mathrm{max}\) is set to 0+0j.
  • Data for \(f<f_\mathrm{min}\) is interpolated by adding an additional data point at a frequency of 1e-100 Hz. The data for this point is data.real[0]+0j, hence the real part of the lowest computed frequency and zero imaginary part. Interpolation is carried out using PCHIP scipy.interpolate.pchip_interpolate().
  • Data for \(f_\mathrm{min}\le f \le f_\mathrm{max}\) is computed with cubic spline interpolation (on a log-scale) scipy.interpolate.InterpolatedUnivariateSpline.

Note that fmin and fmax should be chosen wide enough such that the mapping for \(f>f_\mathrm{max}\) \(f<f_\mathrm{min}\) does not matter that much.

Parameters:
time : ndarray

Desired times (s).

fmin, fmax : float

Minimum and maximum frequencies (Hz) to compute:

  • Data for freq > fmax is set to 0+0j.
  • Data for freq < fmin is interpolated, using an extra data-point at f = 1e-100 Hz, with value data.real[0]+0j. (Hence zero imaginary part, and the lowest computed real value.)
signal : {0, 1, -1}, optional
Source signal, default is 0:
  • None: Frequency-domain response
  • -1 : Switch-off time-domain response
  • 0 : Impulse time-domain response
  • +1 : Switch-on time-domain response
ft : {‘sin’, ‘cos’, ‘fftlog’}, optional

Flag to choose either the Digital Linear Filter method (Sine- or Cosine-Filter) or the FFTLog for the Fourier transform. Defaults to ‘sin’.

ftarg : dict, optional

Depends on the value for ft:

  • If ft=’dlf’:

  • If ft=’fftlog’:

    • pts_per_dec: sampels per decade (default: 10)
    • add_dec: additional decades [left, right] (default: [-2, 1])
    • q: exponent of power law bias (default: 0); -1 <= q <= 1
freq_inp : array

Frequencies to use for computation. Mutually exclusive with every_x_freq.

every_x_freq : int

Every every_x_freq-th frequency of the required frequency-range is used for computation. Mutually exclusive with freq_calc.

Attributes Summary

every_x_freq If set, freq_coarse is every_x_freq-frequency of freq_req.
fmax Maximum frequency (Hz) to compute.
fmin Minimum frequency (Hz) to compute.
freq_calc Frequencies at which the model has to be computed.
freq_calc_i Indices of freq_coarse which have to be computed.
freq_coarse Coarse frequency range, can be different from freq_req.
freq_extrapolate These are the frequencies to extrapolate.
freq_extrapolate_i Indices of the frequencies to extrapolate.
freq_inp If set, freq_coarse is set to freq_inp.
freq_interpolate These are the frequencies to interpolate.
freq_interpolate_i Indices of the frequencies to interpolate.
freq_req Frequencies required to carry out the Fourier transform.
ft Type of Fourier transform.
ftarg Fourier transform arguments.
signal Signal in time domain {0, 1, -1}.
time Desired times (s).

Methods Summary

fourier_arguments(ft, ftarg) Set Fourier type and its arguments.
freq2time(fdata, off) Compute corresponding time-domain signal.
interpolate(fdata) Interpolate from computed data to required data.

Attributes Documentation

every_x_freq

If set, freq_coarse is every_x_freq-frequency of freq_req.

fmax

Maximum frequency (Hz) to compute.

fmin

Minimum frequency (Hz) to compute.

freq_calc

Frequencies at which the model has to be computed.

freq_calc_i

Indices of freq_coarse which have to be computed.

freq_coarse

Coarse frequency range, can be different from freq_req.

freq_extrapolate

These are the frequencies to extrapolate.

In fact, it is dow via interpolation, using an extra data-point at f = 1e-100 Hz, with value data.real[0]+0j. (Hence zero imaginary part, and the lowest computed real value.)

freq_extrapolate_i

Indices of the frequencies to extrapolate.

freq_inp

If set, freq_coarse is set to freq_inp.

freq_interpolate

These are the frequencies to interpolate.

If freq_req is equal freq_coarse, then this is eual to freq_calc.

freq_interpolate_i

Indices of the frequencies to interpolate.

If freq_req is equal freq_coarse, then this is eual to freq_calc_i.

freq_req

Frequencies required to carry out the Fourier transform.

ft

Type of Fourier transform. Set via fourier_arguments(ft, ftarg).

ftarg

Fourier transform arguments. Set via fourier_arguments(ft, ftarg).

signal

Signal in time domain {0, 1, -1}.

time

Desired times (s).

Methods Documentation

fourier_arguments(ft, ftarg)[source]

Set Fourier type and its arguments.

freq2time(fdata, off)[source]

Compute corresponding time-domain signal.

Carry out the actual Fourier transform.

Parameters:
fdata : ndarray

Frequency-domain data corresponding to freq_calc.

off : float

Corresponding offset (m).

Returns:
tdata : ndarray

Time-domain data corresponding to Fourier.time.

interpolate(fdata)[source]

Interpolate from computed data to required data.

Parameters:
fdata : ndarray

Frequency-domain data corresponding to freq_calc.

Returns:
full_data : ndarray

Frequency-domain data corresponding to freq_req.