Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions PulseShape/PulseShape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from scipy.interpolate import interp1d, pchip_interpolate
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid
from .modulations import AmplitudeModulations, FrequencyModulations
from .utils import sop, pulse_propagation, transmitter

Expand Down Expand Up @@ -205,12 +205,12 @@ def bw_comp(self):
if self.fm_func.__name__ == 'uniformq' or self.shape == 'sech/tanh':
profile *= A0

int = cumtrapz(profile ** -2, nu0, initial=0)
int = cumulative_trapezoid(profile ** -2, nu0, initial=0)
tf = self.time[-1] * int / int[-1]
nu_adapted = pchip_interpolate(tf, nu0, self.time)

self.frequency_modulation = nu_adapted
self.phase = 2 * np.pi * cumtrapz(self.frequency_modulation, self.time, initial=0)
self.phase = 2 * np.pi * cumulative_trapezoid(self.frequency_modulation, self.time, initial=0)
self.phase += np.abs(np.min(self.phase))

if self.fm_func.__name__ == 'uniformq' or self.shape == 'sech/tanh':
Expand All @@ -223,7 +223,7 @@ def _compute_flip_amp(self):
"""Compute flip angle if not supplied by user"""

if self.fm_func.__name__ == 'none':
self.amp = self.flip / (2 * np.pi * np.trapz(self.amplitude_modulation, self.time))
self.amp = self.flip / (2 * np.pi * np.trapezoid(self.amplitude_modulation, self.time))
else:
if self.Qcrit is None:
with np.errstate(divide='ignore'):
Expand Down Expand Up @@ -282,7 +282,7 @@ def estimate_timestep(self):
# perform FFT and calculate bandwidth
A0fft = np.abs(np.fft.fftshift(np.fft.fft(tpulse.amplitude_modulation, zf)))
f = np.fft.fftshift(np.fft.fftfreq(zf, dt))
intg = cumtrapz(A0fft, initial=0)
intg = cumulative_trapezoid(A0fft, initial=0)
idx = np.argmin(np.abs(intg - 0.5 * np.max(intg)))
indbw = np.squeeze(np.argwhere(A0fft[idx:] > 0.1 * max(A0fft)))
AM_BW = 2 * (f[idx + indbw[-1] + 1] - f[idx])
Expand Down
6 changes: 3 additions & 3 deletions PulseShape/modulations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import wraps
import numpy as np
from scipy.integrate import cumtrapz
from scipy.integrate import cumulative_trapezoid

AmplitudeModulations = {}
FrequencyModulations = {}
Expand Down Expand Up @@ -387,8 +387,8 @@ def uniformq(Pulse):
------
None"""

freq = cumtrapz(Pulse.amplitude_modulation**2, Pulse.ti, initial=0) / np.trapz(Pulse.amplitude_modulation**2, Pulse.ti, )
freq = cumulative_trapezoid(Pulse.amplitude_modulation**2, Pulse.ti, initial=0) / np.trapezoid(Pulse.amplitude_modulation**2, Pulse.ti, )
freq = (Pulse.freq[1] - Pulse.freq[0]) * (freq - 1/2)
phase = 2 * np.pi * cumtrapz(freq, Pulse.ti, initial=0)
phase = 2 * np.pi * cumulative_trapezoid(freq, Pulse.ti, initial=0)
phase += np.abs(min(phase))
return freq, phase
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

setup(
name='PulseShape',
version='0.1.4',
version='0.1.5',
packages=['PulseShape'],
python_requires='>=3.6',
install_requires=['numpy>=1.19', 'scipy>=1.5', 'matplotlib>=3.0'],
install_requires=['numpy>=2.0', 'scipy>=1.6', 'matplotlib>=3.0'],
url='https://gitlab.com/mtessmer/PulseShape',
project_urls = {'Source': 'https://gitlab.com/mtessmer/PulseShape'},
license='GNU GPLv3',
Expand Down