Skip to content

Commit

Permalink
Fix use of np.trapezoid
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Oct 23, 2024
1 parent 6caaff6 commit d5f79b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion openpmd_viewer/addons/pic/lpa_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,12 @@ def get_spectrogram( self, t=None, iteration=None, pol=None,
T = tmax - tmin
dt = T / Nz
# Normalize the Envelope
env /= np.sqrt(np.trapezoid(env ** 2, dx=dt))
# Note that np.trapz has been deprecated and is replaced by np.trapezoid in numpy2
try:
trapezoid = np.trapezoid
except AttributeError:
trapezoid = np.trapz
env /= np.sqrt(trapezoid(env ** 2, dx=dt))
# Allocate array for the gating function and the spectrogran
E_shift = np.zeros_like(E)
spectrogram = np.zeros((2 * Nz, Nz))
Expand Down

0 comments on commit d5f79b4

Please sign in to comment.