Laser Utils#
- lasy.utils.laser_utils.compute_laser_energy(dim, grid)[source]#
Compute the total laser energy that corresponds to the current envelope data.
This is used mainly for normalization purposes.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- energy: float (in Joules)
- lasy.utils.laser_utils.create_grid(array, axes, dim, is_envelope=True, position=0.0)[source]#
Create a lasy grid from a numpy array.
- Parameters:
- arrayndarray
The input field array.
- axesdict
Dictionary with the information of the array axes.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- Returns:
- gridGrid
A lasy grid containing the input array.
- lasy.utils.laser_utils.export_to_z(dim, grid, omega0, z_axis=None, z0=0.0, t0=0.0, backend='NP')[source]#
Export laser pulse to spatial domain from temporal domain (internal LASY representation).
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains a ndarrays (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- omega0scalar
Angular frequency at which the envelope is defined.
- z_axis1D ndarray of doubles (optional)
Spatial z axis along which the field should be reconstructed. If not provided, z_axis = c * t_axis is considered.
- z0scalar (optional)
Position from which the field is produced (emitted).
- t0scalar (optional)
Moment of time at which the field is produced.
- backendstring (optional)
Backend used by axiprop (see AVAILABLE_BACKENDS in axiprop documentation for more information).
- lasy.utils.laser_utils.field_to_envelope(grid, dim, omega0=None, phase_unwrap_nd=False)[source]#
Convert a field to its complex envelope representation by applying a Hilbert transform.
- Parameters:
- gridGrid
The Grid object on which the field is replaced with an envelope. This object is modified by the function.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- omega0scalar
Central frequency at which the envelope will be defined. If None, the central frequency measured from the field is used.
- phase_unwrap_ndboolean (optional)
If True, the phase unwrapping is n-dimensional (2- or 3-D depending on dim). If False, the phase unwrapping is done in t, treating each transverse cell separately. This should be less accurate but faster. If set to True, scikit-image must be installed.
- Returns:
- scalar
If input parameter omega0 was None, return the central angular frequency. Otherwise, return None.
- lasy.utils.laser_utils.field_to_vector_potential(grid, omega0)[source]#
Convert envelope from electric field (V/m) to normalized vector potential.
- Parameters:
- grida Grid object.
Contains the array of the electric field, to be converted to normalized vector potential, with corresponding metadata. The last axis must be the longitudinal dimension.
- omega0scalar
Angular frequency at which the envelope is defined.
- Returns:
- Normalized vector potential
- lasy.utils.laser_utils.get_bandwidth(grid, dim, method='sum', level=None, unit='rad/s', omega0=None)[source]#
Calculate the spectral width of a pulse in a given grid.
By default, the bandwidth is calculated as the rms width of the spatially summed spectrum, in rad/s. Optionally, the bandwidth can also be calculated on-axis, at a given intensity level or in meters.
- Parameters:
- gridGrid
The grid with the envelope to analyze.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- methodstring, optional
Method to calculate the bandwidth. Options are:
'sum': Calculates the width of the spatially summed spectrum.'on-axis': Calculates the width of the on-axis spectrum.
- levelfloat, optional
Intensity level at which the bandwidth is calculated. If None, i.e. by default, the bandwidth is calculated as the rms width of the spectral intensity.
- unitstring, optional
Unit in which the bandwidth should be returned. Options are:
'rad/s': Radians per second.'m': meters.
- omega0float, optional
Central angular frequency of the pulse. Only required if
unit='m', i.e. the bandwidth should be converted to meters.
- Returns:
- float
Spectral bandwidth of the pulse in the specified units and calculation method.
- lasy.utils.laser_utils.get_beta(dim, grid, k0)[source]#
Calculate the angular dispersion of the laser.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- beta_x, beta_yAngular dispersion in :math:` beta = frac{dtheta_0}{domega}` (second)
- lasy.utils.laser_utils.get_dispersion(grid, dim, omega0, order, omega_eval=None, method='sum')[source]#
Calculate the n-th order dispersion polynomial of the laser.
\[\Phi^{(n)} = \frac{\partial^n \phi(\omega)}{\partial \omega^n}\]where n is the order to which the disperison is calculated (in s^n/rad).
E.g. order=1, calculates the group delay (GD), order=2 calculates group delay dispersion (GDD) and order=3 calculates the third-order dispersion (TOD).
- Parameters:
- gridGrid
The grid with the field to analyze.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- omega0float
Angular frequency at which the laser envelope is defined.
- orderinteger
Dispersion polynomial order that should be calculated.
- omega_evalfloat, optional
Central angular frequency at which the dispersion polynomial is calculated, if None, omega0 is used.
- methodstring, optional
Method of retrieving the phase that is used for calculating the dispersion. Options are:
'sum': Calculates the spectral phase of the spatially summed field (default).'on-axis': Calculates the on-axis spectral phase.
- Returns:
- disp: ndarray of floats (1D)
n-th order dispersion over the entire spectral range (in s^n/rad)
- disp0: float
n-th order dispersion at the center frequency (in s^n/rad)
- lasy.utils.laser_utils.get_duration(grid, dim)[source]#
Get duration of the intensity of the envelope, measured as RMS.
- Parameters:
- gridGrid
The grid with the envelope to analyze.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- Returns:
- float
RMS duration of the envelope intensity in seconds.
- lasy.utils.laser_utils.get_frequency(grid, dim=None, is_hilbert=False, omega0=None, phase_unwrap_nd=False, lower_bound=0.2, upper_bound=5.0)[source]#
Get the local and average frequency of a signal, either electric field or envelope.
- Parameters:
- grida Grid object.
It contains a ndarrays with the field data from which the frequency is computed, and the associated metadata. The last axis must be the longitudinal dimension. Can be the full electric field or the envelope.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- is_hilbertboolean (optional)
If True, the field argument is assumed to be a Hilbert transform, and is used through the computation. Otherwise, the Hilbert transform is calculated in the function.
- omega0scalar
Angular frequency at which the envelope is defined. Only used if grid.is_envelope is True.
- phase_unwrap_ndboolean (optional)
If True, the phase unwrapping is n-dimensional (2- or 3-D depending on dim). If False, the phase unwrapping is done in t, treating each transverse cell separately. This should be less accurate but faster. If set to True, scikit-image must be installed.
- lower_boundscalar (optional)
Relative lower bound for the local frequency Frequencies lower than lower_bound * central_omega are cut to lower_bound * central_omega.
- upper_boundscalar (optional)
Relative upper bound for the local frequency Frequencies larger than upper_bound * central_omega are cut to upper_bound * central_omega.
- Returns:
- omegand array of doubles
local angular frequency.
- central_omegascalar
Central angular frequency (averaged omega, weighted by the local envelope amplitude).
- lasy.utils.laser_utils.get_full_field(laser, theta=0, slice=0, slice_axis='x', Nt=None)[source]#
Reconstruct the laser pulse with carrier frequency on the default grid.
- Parameters:
- thetafloat (rad) (optional)
Azimuthal angle
- slicefloat (optional)
Normalised position of the slice from -0.5 to 0.5.
- Nt: int (optional)
Number of time points on which field should be sampled. If is None, the orignal time grid is used, otherwise field is interpolated on a new grid.
- Returns:
- Etndarray (V/m)
The reconstructed field, with shape (Nr, Nt) (for rt) or (Nx, Nt) (for xyt).
- extentndarray (Tmin, Tmax, Xmin, Xmax)
Physical extent of the reconstructed field.
- lasy.utils.laser_utils.get_grid_cell_volume(grid, dim)[source]#
Get the volume of the grid cells.
- Parameters:
- gridGrid
The grid form which to compute the cell volume
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- Returns:
- float or ndarray
A float with the cell volume (if dim==’xyt’) or a numpy array with the radial distribution of cell volumes (if dim==’rt’).
- lasy.utils.laser_utils.get_laser_fluence(grid)[source]#
Calculate the fluence of the laser in space.
- Parameters:
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- fluencendarray (J/m^2)
The fluence of the laser pulse in space.
- lasy.utils.laser_utils.get_laser_power(dim, grid)[source]#
Calculate the instantaneous power of the laser along the time axis.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- powerndarray (W)
The instantaneous laser power along the temporal axis.
- lasy.utils.laser_utils.get_pft(dim, grid)[source]#
Calculate the pulse front tilt (PFT) of the laser.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- pft_x, pft_yPulse front tilt in \(p=\frac{dt_0}{dx}\) (second * meter^-1).
- lasy.utils.laser_utils.get_phi2(dim, grid)[source]#
Calculate the second derivative of the temporal phase of the laser.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- phi2Second derivative of temporal phase \(\Phi^{(2)} = \frac{d\omega_0}{dt} = \frac{d^2\Phi(t)}{dt^2}\) in (second^-2)
- lasy.utils.laser_utils.get_propation_angle(dim, grid, k0)[source]#
Calculate the propagating angle of the laser.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- angle_x, angle_yPropagating angle in \(p = \frac{k_x}{k_z}\) or \(p = \frac{k_y}{k_z}\) (in radians).
- lasy.utils.laser_utils.get_spectral_phase(grid, dim, omega0, method='sum', ordering='zero_center')[source]#
Calculate the spectral phase of a pulse in a given grid.
Depending on the chosen calculation method, the spectral phase can be calculated in two different ways.
If method==sum (default), the spectral field of the laser is spatially integrated before extracting the phase, i.e.
\[\varphi(\omega) = \arg\left( \int E(x,y,\omega) dx dy \right)\]If method==on-axis, the on-axis spectral phase is calculated:
\[\varphi(\omega) = \arg\left( E(x=0,y=0,\omega) \right)\]- Parameters:
- gridGrid
The grid with the field to analyze.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- omega0float
Central angular frequency of the field
- methodstring, optional
Method of calculating the spectral phase. Options are:
'sum': Calculates the spectral phase of the spatially summed field (default).'on-axis': Calculates the on-axis spectral phase.
- orderingstring (optional)
Order of the frequency array and corresponding spectral phase. Options are: -
"zero_center": xp.fft.fftshift is applied so the frequency array is monotonous with 0 at the center. -"zero_first": The frequency array starts with positive frequencies, and negative frequencies are at the end. The array is not monotonous. This is the default with xp.fft.ifft.
- Returns:
- phase: ndarray of floats (1D)
Spectral phase of the pulse in the specified units and calculation method (in rad/s)
- omega: ndarray of floats (1D)
Angular frequencies at which the phase is defined (in rad/s)
- lasy.utils.laser_utils.get_spectrum(grid, dim, range=None, bins=20, omega0=None, method='sum', ordering='zero_center')[source]#
Get the frequency spectrum of an envelope or electric field.
The spectrum can be calculated in three different ways, depending on the method specified by the user:
Initially, the spectrum is calculated as the Fourier transform of the electric field \(E(t)\).
\[\int E(t) e^{-i \omega t} dt\]neglecting the negative frequencies. If
method=="raw", no further processing is done and the returned spectrum is a complex array with the same transverse dimensions as the input grid. The units are \(\mathrm{V / Hz}\).For the other methods, the spectral energy density is calculated as
\[\frac{\epsilon_0 c}{2\pi} |\int E(t) e^{-i \omega t} dt| ^ 2\]If
method=="on_axis", a 1D real array with on-axis value of the equation above is returned. The units are \(\mathrm{J / (rad Hz m^2)}\).Otherwise, if
method=="sum"(default), the transverse integral of the spectral energy density is calculated:\[\frac{\epsilon_0 c}{2\pi} \int |\int E(t) e^{-i \omega t} dt| ^ 2 dx dy\]The units of this array are \(\mathrm{J / (rad Hz)}\)
- Parameters:
- grida Grid object.
It contains an ndarray with the field data from which the spectrum is computed, and the associated metadata. The last axis must be the longitudinal dimension.
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- rangelist of float (optional)
List of two values indicating the minimum and maximum frequency of the spectrum. If provided, only the FFT spectrum within this range will be returned using interpolation.
- binsint (optional)
Number of bins into which to interpolate the spectrum if a range is given.
- omega0scalar (optional)
Angular frequency at which the envelope is defined. Only used if grid.is_envelope is True.
- method{‘sum’, ‘on_axis’, ‘raw’} (optional)
Determines the type of spectrum that is returned as described above. By default ‘sum’.
- orderingstring (optional)
Order of the frequency array and corresponding spectrum. Options are: -
"zero_center": xp.fft.fftshift is applied so the frequency array is monotonous with 0 at the center. -"zero_first": The frequency array starts with positive frequencies, and negative frequencies are at the end. The array is not monotonous. This is the default with xp.fft.ifft.
- Returns:
- spectrumndarray
Array with the spectrum (units and array type depend on
method).- omegandarray
Array with the angular frequencies of the spectrum.
- lasy.utils.laser_utils.get_w0(grid, dim)[source]#
Calculate the laser waist.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- sigmaStandard deviation of a**2 in m
- lasy.utils.laser_utils.get_zeta(dim, grid, k0)[source]#
Calculate the spatial chirp of the laser.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- Returns:
- zeta_x, zeta_ySpatial chirp in \(\zeta=\frac{dx_0}{d\omega}\) (meter * second)
- nu_x, nu_y: Spatial chirp in \(\nu=\frac{d\omega_0}{dx}\) (meter^-1 * second^-1)
- lasy.utils.laser_utils.hilbert_transform(field)[source]#
Make a hilbert transform of the field.
Currently the arrays need to be flipped along t (both the input field and its transform) to get the imaginary part (and thus the phase) with the correct sign.
- Parameters:
- field3d numpy array
The field whose field should be transformed.
- lasy.utils.laser_utils.import_from_z(dim, grid, omega0, field_z, z_axis, z0=0.0, t0=0.0, backend='NP')[source]#
Import laser pulse from spatial domain to temporal domain (internal LASY representation).
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- grida Grid object.
It contains an ndarray (V/m) with the value of the envelope field and the associated metadata that defines the points at which the laser is defined.
- omega0scalar
Angular frequency at which the envelope is defined.
- z_axis1D ndarray of doubles
Spatial z axis along which the field should be reconstructed.
- z0scalar (optional)
Position at which the field should be recorded
- t0scalar (optional)
Moment of time at which the field should be recorded
- backendstring (optional)
Backend used by axiprop (see AVAILABLE_BACKENDS in axiprop documentation for more information).
- lasy.utils.laser_utils.normalize_average_intensity(average_intensity, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching average laser intensity to an average intensity given as an input.
- Parameters:
- average_intensityscalar (W/m^2)
Average intensity of the laser pulse envelope after normalization.
- grida Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.normalize_energy(dim, energy, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching laser energy to an energy given as an input.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- energyscalar (J)
Energy of the laser pulse after normalization.
- grid: a Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.normalize_peak_field_amplitude(amplitude, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching laser field amplitude to a peak field amplitude given as an input.
- Parameters:
- amplitudescalar (V/m)
Peak field amplitude of the laser pulse after normalization.
- grida Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.normalize_peak_fluence(peak_fluence, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching laser fluence to a peak fluence given as an input.
- Parameters:
- peak_fluencescalar (J/m^2)
Peak fluence of the laser pulse after normalization.
- grida Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.normalize_peak_intensity(peak_intensity, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching laser intensity to a peak intensity given as an input.
- Parameters:
- peak_intensityscalar (W/m^2)
Peak intensity of the laser pulse after normalization.
- grida Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.normalize_peak_power(dim, peak_power, grid)[source]#
Normalize energy of the laser pulse contained in grid.
Normalizes by matching laser power to a peak power given as an input.
- Parameters:
- dimstring
Dimensionality of the array. Options are:
'xyt': The laser pulse is represented on a 3D grid:Cartesian (x,y) transversely, and temporal (t) longitudinally.
'rt'The laser pulse is represented on a 2D grid:Cylindrical (r) transversely, and temporal (t) longitudinally.
- peak_powerscalar (W)
Peak power of the laser pulse after normalization.
- grida Grid object
Contains value of the laser envelope and metadata.
- lasy.utils.laser_utils.vector_potential_to_field(grid, omega0, direct=False)[source]#
Convert envelope from normalized vector potential to electric field (V/m).
- Parameters:
- grida Grid object.
Contains the array of the normalized vector potential, to be converted to field, with corresponding metadata. The last axis must be the longitudinal dimension.
- omega0scalar
Angular frequency at which the envelope is defined.
- directboolean (optional)
If true, the conversion is done directly with derivative of vector potential. Otherwise, this is done using the local frequency.
- Returns:
- Envelope of the electric field (V/m).
- lasy.utils.laser_utils.weighted_std(values, weights=None)[source]#
Calculate the weighted standard deviation of the given values.
- Parameters:
- values: array
Contains the values to be analyzed
- weightsarray
Contains the weights of the values to analyze
- Returns:
- A float with the value of the standard deviation