Skip to content
Merged
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
20 changes: 10 additions & 10 deletions examples/plot_input_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# peak power [W]
Pmax = 100

# Amplitude envelope of gaussina pulse
# Amplitude envelope of gaussian pulse
A1 = gnlse.GaussianEnvelope(Pmax, FWHM).A(T)
# Amplitude envelope of hiperbolic secans pulse
# Amplitude envelope of hyperbolic secant pulse
A2 = gnlse.SechEnvelope(Pmax, FWHM).A(T)
# Amplitude envelope of lorentzian pulse
A3 = gnlse.LorentzianEnvelope(Pmax, FWHM).A(T)
Expand All @@ -29,19 +29,19 @@

plt.figure(figsize=(12, 8))
plt.subplot(1, 2, 1)
plt.plot(T, A1, label='gauss')
plt.plot(T, A2, label='sech')
plt.plot(T, A3, label='lorentz')
plt.plot(T, A4, label='cw')
plt.plot(T, np.abs(A1), label='gauss')
plt.plot(T, np.abs(A2), label='sech')
plt.plot(T, np.abs(A3), label='lorentz')
plt.plot(T, np.abs(A4), label='cw')
plt.xlabel("Time [ps]")
plt.ylabel("Amplitude [sqrt(W)]")
plt.legend()

plt.subplot(1, 2, 2)
plt.plot(T, A1**2, label='gauss')
plt.plot(T, A2**2, label='sech')
plt.plot(T, A3**2, label='lorentz')
plt.plot(T, A4**2, label='cw')
plt.plot(T, np.abs(A1)**2, label='gauss')
plt.plot(T, np.abs(A2)**2, label='sech')
plt.plot(T, np.abs(A3)**2, label='lorentz')
plt.plot(T, np.abs(A4)**2, label='cw')
plt.xlabel("Time [ps]")
plt.ylabel("Power [W]")
plt.legend()
Expand Down
4 changes: 2 additions & 2 deletions examples/test_Dudley.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@

plt.subplot(2, count, i + 1)
plt.title(pulse_model.name)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])
gnlse.plot_wavelength_vs_distance_logarithmic(solution, WL_range=[400, 1400])

plt.subplot(2, count, i + 1 + count)
gnlse.plot_delay_vs_distance(solution, time_range=[-0.5, 5])
gnlse.plot_delay_vs_distance_logarithmic(solution, time_range=[-0.5, 5])

plt.tight_layout()
plt.show()
4 changes: 2 additions & 2 deletions examples/test_raman.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@

plt.subplot(2, count, i + 1)
plt.title(name)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[500, 1250])
gnlse.plot_wavelength_vs_distance_logarithmic(solution, WL_range=[500, 1250])

plt.subplot(2, count, i + 1 + count)
gnlse.plot_delay_vs_distance(solution, time_range=[-0.5, 4])
gnlse.plot_delay_vs_distance_logarithmic(solution, time_range=[-0.5, 4])
plt.tight_layout()
plt.show()
3 changes: 2 additions & 1 deletion gnlse/dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

"""
import numpy as np
import math
from scipy import interpolate

from gnlse.common import c
Expand Down Expand Up @@ -67,7 +68,7 @@ def D(self, V):
self.calc_loss()
# Taylor series for subsequent derivatives
# of constant propagation
B = sum(beta / np.math.factorial(i + 2) * V**(i + 2)
B = sum(beta / math.factorial(i + 2) * V**(i + 2)
for i, beta in enumerate(self.betas))
L = 1j * B - self.alpha / 2
return L
Expand Down
2 changes: 1 addition & 1 deletion gnlse/gnlse.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def run(self):
plan_forward = pyfftw.FFTW(x, X)
plan_inverse = pyfftw.FFTW(X, x, direction="FFTW_BACKWARD")

progress_bar = tqdm.tqdm(total=self.fiber_length, unit='m')
progress_bar = tqdm.tqdm(total=round(self.fiber_length, 3), unit='m')

def rhs(z, AW):
"""
Expand Down
15 changes: 10 additions & 5 deletions gnlse/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import numpy as np
import matplotlib.pyplot as plt

from scipy.interpolate import interp2d
#from scipy.interpolate import interp2d - deprecated since SciPy version 1.14.0
from scipy.interpolate import RegularGridInterpolator

from gnlse.common import c

Expand Down Expand Up @@ -582,9 +583,11 @@ def plot_wavelength_vs_distance(solver, WL_range=None, ax=None,
WL_asc = WL_asc[iis]
IW = IW[:, iis]

interpolator = interp2d(WL_asc, solver.Z, IW)
interpolator = RegularGridInterpolator((WL_asc, solver.Z),
IW.T, method='cubic')
newWL = np.linspace(np.min(WL_asc), np.max(WL_asc), IW.shape[1])
toshow = interpolator(newWL, solver.Z)
WL_new_grid, Z_new_grid = np.meshgrid(newWL, solver.Z, indexing='ij')
toshow = interpolator((WL_new_grid, Z_new_grid)).T

ax.imshow(toshow, origin='lower', aspect='auto', cmap=cmap,
extent=[np.min(WL_asc), np.max(WL_asc), 0, np.max(solver.Z)],
Expand Down Expand Up @@ -637,9 +640,10 @@ def plot_wavelength_vs_distance_logarithmic(solver, WL_range=None,
WL_asc = WL_asc[iis]
lIW = lIW[:, iis]

interpolator = interp2d(WL_asc, solver.Z, lIW)
interpolator = RegularGridInterpolator((WL_asc, solver.Z), lIW.T)
newWL = np.linspace(np.min(WL_asc), np.max(WL_asc), lIW.shape[1])
toshow = interpolator(newWL, solver.Z)
WL_new_grid, Z_new_grid = np.meshgrid(newWL, solver.Z, indexing='ij')
toshow = interpolator((WL_new_grid, Z_new_grid)).T

ax.imshow(toshow, origin='lower', aspect='auto', cmap=cmap,
extent=[np.min(WL_asc), np.max(WL_asc), 0, np.max(solver.Z)],
Expand Down Expand Up @@ -667,3 +671,4 @@ def quick_plot(solution):
plot_delay_vs_distance(solution)

plt.show()

8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
matplotlib>=2.2.2
numpy>=1.14.3
scipy>=1.1.0
matplotlib>=3.0.0
numpy>=2.0.0
scipy>=1.10.0
pyfftw>=0.10.0
hdf5storage>=0.1.15
hdf5storage>=0.2.0
tqdm>=4.11.2
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pkg_resources

from setuptools import find_packages
from setuptools import setup

with open('requirements.txt', 'r') as fh:
reqs = [str(requirement)
for requirement in pkg_resources.parse_requirements(fh)]
reqs = [
line.strip()
for line in fh
if line.strip() and not line.strip().startswith('#')
]

with open("README.md", "r") as fh:
long_description = fh.read()
Expand All @@ -23,9 +24,14 @@
packages=find_packages(),
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Operating System :: OS Independent',
],
license='MIT',
python_requires='>=3.7',
install_requires=reqs,
)
Loading