# epsproc.efield.efields module¶

ePSproc Efield class

class epsproc.efield.efields.Efield(Edef=None, units=None, verbose=True)[source]

Bases: object

Basic class for handling E-field generation, data and related functions.

Currently set for field creation based on Gaussian defined in time-domain. Defaults to a single (E,t) point if no parameters are supplied - this can be used with epsproc.geomFunc.EPR()

Starting to look a bit top-heavy… passing directly to Xarray might save some structural overhead here?

Define Gaussian field in the time-domain, with amplitude $E_0$, width $sigma$ and carrier frequency $omega_0$:

\begin{align}\begin{aligned}E(\omega_0,t)=E_{0}e^{-(t^2/2\sigma^{2})}e^{i\omega_0 t}\\Carrier frequency in rad/s:\end{aligned}\end{align}
\begin{align}\begin{aligned}\omega_0 = 2\pi \Omega_0\\FWHM and Gaussian width (see https://en.wikipedia.org/wiki/Gaussian_function for full definitions):\end{aligned}\end{align}
\begin{align}\begin{aligned}FWHM = 2\sigma\sqrt{2ln2}\\Parameters ---------- If no parameters are passed, return single point with E0 = 1 For a time-dependent field, pass at least sigma.\\E0 : float, optional, default = None Set (relative) field strength. If None, set E0 = 1\\sigma : float, optional, default = None Set Gaussian width :math:\sigma, where :math:FWHM=2\sigma\sqrt{2ln2}\\t : array, optional, default = None Set time axis for E-field. If None, defaults to np.arange(-(5*sigma), 5*sigma, self.dt), and self.dt = 0.01*sigma\\dt : float, optional, default = None Set time-step. Default will set from t-axis, or self.dt = 0.01*sigma if sigma only passed. Pass here to override.\\l0 : float, optional, default = None Central wavelength in wavelength working units. If supplied this will be used to set f0 and w0.\\f0, w0 : float, optional, default = None Carrier frequency in freq. units, and :math:\omega_0 in (rad/s). If only f0 supplied, w0 will be calculated. If f0 and w0 supplied, w0 will be used directly. If None, this will be ignored.\\units : dictionary, optional, default = None Set units. If not passed, default dict will be created with units (THz, nm, fs) set.\\ TODO: - best way to handle unit conversions? Did some of this for FROG code already? Yes, see python est_codes\E_fields_redux_231118_class.py - Consider other structures here, dataclass or namedtuple? https://stackoverflow.com/questions/354883/how-do-i-return-multiple-values-from-a-function - Xarray conversion? Use Xarray directly in class? - Bug with FFT/iFFT code? If shift=True and ishift=True then get extra freq components on iFFT - must be bug in axis assignment/conversion? OK if shift = False.\end{aligned}\end{align}
ECalc()[source]
EFFT()[source]
EiFFT(Emod=None, Ninput=None, comment='')[source]
FWHMGau()[source]
Gau()[source]
calcSpectrogram(signal=None, gate=None, fType='blind', N=None, verbose=False)[source]
chirp(A, resetPhase=False, comment=None)[source]

Add quadratic phase (chirp) in spectral domain. Requires an E-field object, and chirp parameter A.

TODO: check Diels for nomenclature here.

fConv()[source]

Convert freq. domain axis to lenght & energy units. and set fields.

finst()[source]

Calculate f(t) as instantaneous freq.

phaseMask(domain=None, thres=None)[source]

Mask pulse phase away from main features. Should convert to use masked arrays for reversibility, or just return a mask (currently overwrites Ef).

plot(plotType='phaseUW', Nplot=None, domainList=None, thres=0.01)[source]

Basic plot with Matplotlib

plotSpectrogram()[source]

VERY basic spectrogram plotter from old code - for quick testing only.

TODO: fix axes for with/withou fft shift.

BETTER: use plotSpectrogramHV() instead, this uses full axes as set.

plotSpectrogramHV(N=None)[source]
printDef()[source]
removePhase(domain=None)[source]

Remove imaginary field terms (reset phase).

setEf()[source]

Calculate pulse properties and E-fields based on Edef.

setPhase(phaseVec=None, domain=None)[source]

Set imaginary field terms (set phase) for specified domain & recalculated FFT.

toXarrayDS(N=None)[source]