Skip to content

Commit

Permalink
Update laser_utils.py
Browse files Browse the repository at this point in the history
New function get_t_peak that calculates the average time of the intensity. Relevant for pulse-front tilt testing.
  • Loading branch information
spencerjolly authored Jan 12, 2024
1 parent a3b1a54 commit c830f08
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lasy/utils/laser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,31 @@ def get_frequency(
return omega, central_omega


def get_t_peak(grid, dim):
"""Get centraltime of the intensity of the envelope, measured as an average.
Parameters
----------
grid : Grid
The grid with the envelope to analyze.
dim : str
Dimensionality of the grid.
Returns
-------
float
average position of the envelope intensity in seconds.
"""
# Calculate weights of each grid cell (amplitude of the field).
dV = get_grid_cell_volume(grid, dim)
if dim == "xyt":
weights = np.abs(grid.field) ** 2 * dV
else: # dim == "rt":
weights = np.abs(grid.field) ** 2 * dV[np.newaxis, :, np.newaxis]
# project weights to longitudinal axes
weights = np.sum(weights, axis=(0, 1))
return np.average(grid.axes[-1], weights=weights)

def get_duration(grid, dim):
"""Get duration of the intensity of the envelope, measured as RMS.
Expand Down

0 comments on commit c830f08

Please sign in to comment.