Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 27, 2023
1 parent ddef5ff commit 8c49414
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 102 deletions.
19 changes: 8 additions & 11 deletions lasy/laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@


class Laser:
"""
Top-level class that can evaluate a laser profile on a grid,
propagate it, and write it to a file.
"""Top-level class that can evaluate a laser profile on a grid, propagate
it, and write it to a file.
Parameters
----------
Expand Down Expand Up @@ -116,8 +115,8 @@ def __init__(self, dim, lo, hi, npoints, profile, n_azimuthal_modes=1):
self.field.field[...] = np.fft.ifft(envelope, axis=0)

def normalize(self, value, kind="energy"):
"""
Normalize the pulse either to the energy, peak field amplitude or peak intensity
"""Normalize the pulse either to the energy, peak field amplitude or
peak intensity.
Parameters
----------
Expand All @@ -138,8 +137,7 @@ def normalize(self, value, kind="energy"):
raise ValueError(f'kind "{kind}" not recognized')

def propagate(self, distance, nr_boundary=None, backend="NP"):
"""
Propagate the laser pulse by the distance specified
"""Propagate the laser pulse by the distance specified.
Parameters
----------
Expand Down Expand Up @@ -247,8 +245,7 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
self.field.field *= np.exp(1j * self.profile.omega0 * distance / scc.c)

def write_to_file(self, file_prefix="laser", file_format="h5"):
"""
Write the laser profile + metadata to file.
"""Write the laser profile + metadata to file.
Parameters
----------
Expand All @@ -268,8 +265,8 @@ def write_to_file(self, file_prefix="laser", file_format="h5"):
)

def get_full_field(self, theta=0, slice=0, slice_axis="x"):
"""
Reconstruct the laser pulse with carrier frequency on the default grid
"""Reconstruct the laser pulse with carrier frequency on the default
grid.
Parameters
----------
Expand Down
6 changes: 2 additions & 4 deletions lasy/profiles/combined_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


class CombinedLongitudinalTransverseProfile(Profile):
"""
Class that combines a longitudinal and transverse laser profile
"""Class that combines a longitudinal and transverse laser profile.
The combined profile is defined as the product of the longitudinal and transverse
profile.
Expand Down Expand Up @@ -53,8 +52,7 @@ def __init__(self, wavelength, pol, laser_energy, long_profile, trans_profile):
self.trans_profile = trans_profile

def evaluate(self, x, y, t):
"""
Returns the envelope field of the laser
"""Returns the envelope field of the laser.
Parameters
----------
Expand Down
3 changes: 1 addition & 2 deletions lasy/profiles/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class GaussianProfile(CombinedLongitudinalTransverseProfile):
"""
Derived class for the analytic profile of a Gaussian laser pulse.
"""Derived class for the analytic profile of a Gaussian laser pulse.
More precisely, the electric field corresponds to:
Expand Down
7 changes: 3 additions & 4 deletions lasy/profiles/longitudinal/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


class GaussianLongitudinalProfile(LongitudinalProfile):
"""
Derived class for the analytic profile of a longitudinally-Gaussian laser pulse.
"""Derived class for the analytic profile of a longitudinally-Gaussian
laser pulse.
More precisely, the longitudinal envelope
(to be used in the :class:CombinedLongitudinalTransverseProfile class)
Expand Down Expand Up @@ -41,8 +41,7 @@ def __init__(self, wavelength, tau, t_peak, cep_phase=0):
self.cep_phase = cep_phase

def evaluate(self, t):
"""
Returns the longitudinal envelope
"""Returns the longitudinal envelope.
Parameters
----------
Expand Down
11 changes: 5 additions & 6 deletions lasy/profiles/longitudinal/longitudinal_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@


class LongitudinalProfile(object):
"""
Base class for longitudinal profiles of laser pulses.
"""Base class for longitudinal profiles of laser pulses.
Any new longitudinal profile should inherit from this class, and define
its own `evaluate` method, using the same signature as the method below.
Any new longitudinal profile should inherit from this class, and
define its own `evaluate` method, using the same signature as the
method below.
"""

def __init__(self, wavelength):
self.lambda0 = wavelength
self.omega0 = 2 * scc.pi * scc.c / self.lambda0

def evaluate(self, t):
"""
Returns the longitudinal envelope
"""Returns the longitudinal envelope.
Parameters
----------
Expand Down
13 changes: 4 additions & 9 deletions lasy/profiles/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


class Profile(object):
"""
Base class for all laser profiles.
"""Base class for all laser profiles.
Any new laser profile should inherit from this class, and define its own
`evaluate` method, using the same signature as the method below.
Expand All @@ -24,7 +23,6 @@ class Profile(object):
- Linear polarization in y: pol = (0,1)
- Circular polarization: pol = (1,j)/sqrt(2) (j is the imaginary number)
The polarization vector is normalized to have a unitary magnitude.
"""

def __init__(self, wavelength, pol):
Expand All @@ -35,8 +33,7 @@ def __init__(self, wavelength, pol):
self.omega0 = 2 * np.pi * c / self.lambda0

def evaluate(self, x, y, t):
"""
Returns the envelope field of the laser
"""Returns the envelope field of the laser.
Parameters
----------
Expand Down Expand Up @@ -68,8 +65,7 @@ def __rmul__(self, factor):


class SummedProfile(Profile):
"""
Base class for profiles that are the sum of several other profiles.
"""Base class for profiles that are the sum of several other profiles.
Profile class that represents the sum of multiple profiles.
Expand Down Expand Up @@ -109,8 +105,7 @@ def evaluate(self, x, y, t):


class ScaledProfile(Profile):
"""
Base class for profiles that are scaled by a factor.
"""Base class for profiles that are scaled by a factor.
Profile class that represents scaled profiles.
Expand Down
6 changes: 2 additions & 4 deletions lasy/profiles/transverse/gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class GaussianTransverseProfile(TransverseProfile):
"""
Derived class for the analytic profile of a Gaussian laser pulse.
"""Derived class for the analytic profile of a Gaussian laser pulse.
More precisely, the transverse envelope
(to be used in the :class:CombinedLongitudinalTransverseLaser class)
Expand All @@ -26,8 +25,7 @@ def __init__(self, w0):
self.w0 = w0

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand Down
8 changes: 3 additions & 5 deletions lasy/profiles/transverse/hermite_gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@


class HermiteGaussianTransverseProfile(TransverseProfile):
"""
Derived class for an analytic profile of a high-order Gaussian
laser pulse expressed in the Hermite-Gaussian formalism.
"""Derived class for an analytic profile of a high-order Gaussian laser
pulse expressed in the Hermite-Gaussian formalism.
More precisely, the transverse envelope
(to be used in the :class:CombinedLongitudinalTransverseLaser class)
Expand Down Expand Up @@ -38,8 +37,7 @@ def __init__(self, w0, n_x, n_y):
self.n_y = n_y

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand Down
8 changes: 3 additions & 5 deletions lasy/profiles/transverse/laguerre_gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@


class LaguerreGaussianTransverseProfile(TransverseProfile):
"""
Derived class for an analytic profile of a high-order Gaussian
laser pulse expressed in the Laguerre-Gaussian formalism.
"""Derived class for an analytic profile of a high-order Gaussian laser
pulse expressed in the Laguerre-Gaussian formalism.
More precisely, the transverse envelope
(to be used in the :class:CombinedLongitudinalTransverseLaser class)
Expand Down Expand Up @@ -41,8 +40,7 @@ def __init__(self, w0, p, m):
self.m = m

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand Down
6 changes: 2 additions & 4 deletions lasy/profiles/transverse/super_gaussian_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class SuperGaussianTransverseProfile(TransverseProfile):
"""
Derived class for the analytic profile of a super-Gaussian laser pulse.
"""Derived class for the analytic profile of a super-Gaussian laser pulse.
More precisely, the transverse envelope corresponds to:
Expand All @@ -30,8 +29,7 @@ def __init__(self, w0, n_order):
self.n_order = n_order

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand Down
27 changes: 11 additions & 16 deletions lasy/profiles/transverse/transverse_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


class TransverseProfile(object):
"""
Base class for all transverse profiles.
"""Base class for all transverse profiles.
Any new transverse profile should inherit from this class, and define its own
`evaluate` method, using the same signature as the method below.
Any new transverse profile should inherit from this class, and
define its own `evaluate` method, using the same signature as the
method below.
"""

def __init__(self):
Expand All @@ -15,8 +15,7 @@ def __init__(self):
self.y_offset = 0

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand All @@ -35,9 +34,9 @@ def _evaluate(self, x, y):
return np.zeros(x.shape, dtype="complex128")

def evaluate(self, x, y):
"""
Returns the transverse envelope modified by any spatial offsets.
This is the public facing evaluate method, it calls the _evaluate function of the derived class.
"""Returns the transverse envelope modified by any spatial offsets.
This is the public facing evaluate method, it calls the _evaluate
function of the derived class.
Parameters
----------
Expand All @@ -55,19 +54,15 @@ def evaluate(self, x, y):
return self._evaluate(x + self.x_offset, y + self.y_offset)

def set_offset(self, x_offset, y_offset):
"""
Populates the x and y spatial offsets of the profile
The profile will be shifted by these according to
x+x_offset and y+y_offset prior to execution of
_evaluate
"""Populates the x and y spatial offsets of the profile The profile
will be shifted by these according to x+x_offset and y+y_offset prior
to execution of _evaluate.
Parameters
----------
x_offset, y_offset: floats (m)
Define spatial offsets to the beam. That is, how much
to shift the beam by transversely
"""

self.x_offset = x_offset
Expand Down
15 changes: 5 additions & 10 deletions lasy/profiles/transverse/transverse_profile_from_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@


class TransverseProfileFromData(TransverseProfile):
"""
Derived class for transverse laser profile created using
data from an experimental measurement or from the output
of another code.
"""
"""Derived class for transverse laser profile created using data from an
experimental measurement or from the output of another code."""

def __init__(self, intensity_data, lo, hi):
"""
Uses user supplied data to define the transverse profile
of the laser pulse.
"""Uses user supplied data to define the transverse profile of the
laser pulse.
The data must be supplied as a 2D numpy array of intensity
values (for example an imported cameran image from an
Expand Down Expand Up @@ -60,8 +56,7 @@ def __init__(self, intensity_data, lo, hi):
)

def _evaluate(self, x, y):
"""
Returns the transverse envelope
"""Returns the transverse envelope.
Parameters
----------
Expand Down
5 changes: 2 additions & 3 deletions lasy/utils/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@


class Box:
"""
Contain metadata on index and physical space for an array,
as well as handy methods.
"""Contain metadata on index and physical space for an array, as well as
handy methods.
Parameters
----------
Expand Down
4 changes: 1 addition & 3 deletions lasy/utils/exp_data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


def find_center_of_mass(img):
"""
Finds the center of mass of an image.
"""Finds the center of mass of an image.
Parameters:
-----------
Expand All @@ -15,7 +14,6 @@ def find_center_of_mass(img):
x0 , y0: floats
The center of mass of the image along the horizontal
and the vertical. The units are in pixels.
"""
rows, cols = np.shape(img)
x_data = np.linspace(0, cols - 1, cols)
Expand Down
4 changes: 2 additions & 2 deletions lasy/utils/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


class Grid:
"""
Contains data for fields (in position or Fourier space), including metadata
"""Contains data for fields (in position or Fourier space), including
metadata.
Parameters
----------
Expand Down
Loading

0 comments on commit 8c49414

Please sign in to comment.