Skip to content

Commit

Permalink
Plot functions and example of their use.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafal-Cichowski committed Nov 30, 2022
1 parent b232c4e commit e0d42f4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
31 changes: 13 additions & 18 deletions examples/test_wl_del_freq.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
"""
This example is here to test new plot functions. This test is based on file
test_dispersion:
Example: Example of supercontinuum generation in anomalous dispersion regime
at a central wavelength of 835 nm in a 15 centimeter long fiber.
Comparision of results obtained with two dispersion input:
1. dispersion calculated from Taylor expansion
2. dispersion calculated from effective refractive indicies
The python code based on MATLAB code published in
'Supercontinuum Generation in Optical Fibers'
by J. M. Dudley and J. R. Taylor, available at http://scgbook.info/.
This example presents potential of new plot functions.
Especially:
-different scales(linear and logarithmic)
-different x arguments(delay, frequency, wavelength)
-color map as argument of plot function
-slice plot for chosen z(propagation) distances
or z=0 and z=end if no specific z were chosen.
Data used in this example are taken from test_Dudley.py file from examples.
"""

import numpy as np
import matplotlib.pyplot as plt

import gnlse

import os

if __name__ == '__main__':
setup = gnlse.GNLSESetup()

Expand Down Expand Up @@ -48,7 +43,7 @@
# pulse duration [ps]
tfwhm = 0.05
# hyperbolic secant
setup.pulse_model = gnlse.SechEnvelope(power, tfwhm)
setup.pulse_model = gnlse.SechEnvelope(power, tfwhm)
solver = gnlse.GNLSE(setup)
solution = solver.run()

Expand Down Expand Up @@ -88,12 +83,12 @@
gnlse.plot_wavelength_for_distance_slice(solution, WL_range=[400, 1400])

plt.subplot(4, 3, 10)
ax = gnlse.plot_delay_for_distance_slice_logarithmic(solution,
time_range=[-.5, 5])
gnlse.plot_delay_for_distance_slice_logarithmic(
solution, time_range=[-.5, 5])

plt.subplot(4, 3, 11)
gnlse.plot_frequency_for_distance_slice_logarithmic(solution,
frequency_range=[-300, 200])
gnlse.plot_frequency_for_distance_slice_logarithmic(
solution, frequency_range=[-300, 200])

plt.subplot(4, 3, 12)
gnlse.plot_wavelength_for_distance_slice_logarithmic(solution,
Expand Down
27 changes: 16 additions & 11 deletions gnlse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
from gnlse.nonlinearity import NonlinearityFromEffectiveArea
from gnlse.raman_response import (raman_blowwood, raman_holltrell,
raman_linagrawal)
from gnlse.visualization import (plot_delay_vs_distance,
plot_delay_vs_distance_logarithmic,
plot_delay_for_distance_slice,
plot_delay_for_distance_slice_logarithmic,
plot_frequency_vs_distance,
plot_frequency_vs_distance_logarithmic,
plot_frequency_for_distance_slice,
plot_frequency_for_distance_slice_logarithmic,
plot_wavelength_vs_distance,
plot_wavelength_vs_distance_logarithmic,
quick_plot)
from gnlse.visualization import (
plot_delay_vs_distance,
plot_delay_vs_distance_logarithmic,
plot_delay_for_distance_slice,
plot_delay_for_distance_slice_logarithmic,
plot_frequency_vs_distance,
plot_frequency_vs_distance_logarithmic,
plot_frequency_for_distance_slice,
plot_frequency_for_distance_slice_logarithmic,
plot_wavelength_vs_distance,
plot_wavelength_vs_distance_logarithmic,
plot_wavelength_for_distance_slice,
plot_wavelength_for_distance_slice_logarithmic,
quick_plot)

__all__ = [
'DispersionFiberFromTaylor', 'DispersionFiberFromInterpolation',
Expand All @@ -34,5 +37,7 @@
'plot_frequency_for_distance_slice_logarithmic',
'plot_wavelength_vs_distance',
'plot_wavelength_vs_distance_logarithmic',
'plot_wavelength_for_distance_slice',
'plot_wavelength_for_distance_slice_logarithmic',
'quick_plot', 'NonlinearityFromEffectiveArea', 'CWEnvelope'
]
4 changes: 2 additions & 2 deletions gnlse/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def plot_frequency_vs_distance_logarithmic(solver, ax=None, norm=None,
frequency <= frequency_range[1])
# indices of interest

frequency= frequency[iis]
frequency = frequency[iis]
lIW = lIW[:, iis]

ax.imshow(lIW, origin='lower', aspect='auto', cmap=cmap,
Expand Down Expand Up @@ -96,7 +96,7 @@ def plot_frequency_vs_distance(solver, frequency_range=None,
frequency <= frequency_range[1])
# indices of interest

frequency= frequency[iis]
frequency = frequency[iis]
IW = IW[:, iis]

ax.imshow(IW, origin='lower', aspect='auto', cmap=cmap,
Expand Down

0 comments on commit e0d42f4

Please sign in to comment.