Skip to content

Commit

Permalink
Update Gallery (#217)
Browse files Browse the repository at this point in the history
- Replace LaTeX in figures by unicode symbols
- Replace implicit by explicit pyplot (OO)
- Use by default coordinate system with positive z upwards
- Update for Jupyterlab
  - Replace %matplotlib notebook by %matplotlib widget
  - Document ipympl along with matplotlib

for frequency domain, reproducing, and published. Missing are time domain and educational.
  • Loading branch information
prisae authored Jul 4, 2024
1 parent 6ef2b45 commit a500f4b
Show file tree
Hide file tree
Showing 32 changed files with 679 additions and 843 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ docs/savefig/
docs/gallery/*/
docs/my*.json
docs/my*.txt
docs/sg_execution_times.rst

# Pytest and coverage related
htmlcov
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ v2.3.x
""""""


latest
------

- Gallery Update Part I:
- Update for Jupyterlab (ipympl/widget)
- Replaced implicit by explicit pyplots
- Use by default a positiv z-upwards coordinate system
- Part I: frequency domain; reproducing; published


v2.3.1: Julia wrapper
---------------------

Expand Down
7 changes: 3 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import time
import warnings
from empymod import __version__
from sphinx_gallery.sorting import FileNameSortKey

# ==== 1. Extensions ====

Expand Down Expand Up @@ -51,17 +50,17 @@
'gallery/reproducing',
'gallery/published',
],
'capture_repr': ('_repr_html_', '__repr__'),
'capture_repr': ('_repr_html_', ),
# Patter to search for example files
"filename_pattern": r"\.py",
# Sort gallery example by file name instead of number of lines (default)
"within_subsection_order": FileNameSortKey,
"within_subsection_order": "FileNameSortKey",
# Remove the settings (e.g., sphinx_gallery_thumbnail_number)
'remove_config_comments': True,
# Show memory
'show_memory': True,
# Custom first notebook cell
'first_notebook_cell': '%matplotlib notebook',
'first_notebook_cell': '%matplotlib widget',
}

# https://github.com/sphinx-gallery/sphinx-gallery/pull/521/files
Expand Down
3 changes: 2 additions & 1 deletion docs/manual/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Requirements are the modules ``scipy``, ``numba``, and ``libdlf``.
The modeller empymod comes with add-ons (``empymod.scripts``). These add-ons
provide some very specific, additional functionalities. Some of these add-ons
have additional, optional dependencies such as matplotlib. See the
*Add-ons*-section for their documentation.
*Add-ons*-section for their documentation. For interactive plots you will need
ipympl in addition to matplotlib.

If you are new to Python we recommend using a Python distribution, which will
ensure that all dependencies are met, specifically properly compiled versions
Expand Down
16 changes: 2 additions & 14 deletions examples/educational/coordinate_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def repeated(ax, pm):
###############################################################################

# Create figure
fig = plt.figure(figsize=(8, 3.5))
fig = plt.figure(figsize=(8, 3.5), constrained_layout=True)

# Left-handed system
ax1 = fig.add_subplot(121, projection=Axes3D.name, facecolor='w')
Expand All @@ -211,9 +211,6 @@ def repeated(ax, pm):

repeated(ax2, 1)

plt.tight_layout()
plt.show()


###############################################################################
# Dipole
Expand Down Expand Up @@ -274,7 +271,7 @@ def repeated(ax, pm):
# Plotting the two confirms that the results agree, no matter if we use the LHS
# or the RHS definition.

plt.figure(figsize=(9, 4))
plt.figure(figsize=(9, 4), constrained_layout=True)

ax1 = plt.subplot(121)
plt.title('Real')
Expand All @@ -300,9 +297,6 @@ def repeated(ax, pm):
ax2.yaxis.set_label_position("right")
ax2.yaxis.tick_right()

plt.tight_layout()
plt.show()


###############################################################################
# Bipole [x1, x2, y1, y2, z1, z2]
Expand Down Expand Up @@ -338,9 +332,6 @@ def repeated(ax, pm):
plt.ylabel('$E_x$ (V/m)')
plt.legend()

plt.show()


###############################################################################
# Bipole [x, y, z, azimuth, dip]
# ------------------------------
Expand Down Expand Up @@ -373,9 +364,6 @@ def repeated(ax, pm):
plt.ylabel('$E_x$ (V/m)')
plt.legend()

plt.show()


###############################################################################

empymod.Report()
5 changes: 1 addition & 4 deletions examples/educational/dipoles_and_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
fs = 16 # Fontsize

# Figure
fig = plt.figure(figsize=(12, 8))
fig = plt.figure(figsize=(12, 8), constrained_layout=True)

# Frequency Domain
plt.subplot(231)
Expand Down Expand Up @@ -200,8 +200,6 @@
fig.text(-0.01, 0.5, 'Amplitude; e-rec (V/m); m-rec (A/m)',
va='center', rotation='vertical', fontsize=fs, color='.4')

plt.tight_layout()
plt.show()

###############################################################################
# The figure shows the main points of Equations (2) and (3):
Expand Down Expand Up @@ -300,7 +298,6 @@ def setplot(name):

# Title
fig.suptitle(title, y=.95, fontsize=20)
plt.show()


###############################################################################
Expand Down
2 changes: 0 additions & 2 deletions examples/educational/dlf_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def plotresult(depth, res, zsrc, zrec):
plt.xlim([0, 20e3])
plt.ylim([1e-14, 1])

plt.show()


###############################################################################
# Plot the individual models
Expand Down
20 changes: 2 additions & 18 deletions examples/educational/dlf_standard_lagged_splined.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import empymod
import numpy as np
import matplotlib.pyplot as plt
from copy import deepcopy as dc
plt.style.use('ggplot')
# sphinx_gallery_thumbnail_number = 3

Expand Down Expand Up @@ -143,7 +142,7 @@
[f'{i:G}' for i in np.round(relerror*100, 1)]), '%')

# Figure
plt.figure(figsize=(10, 4))
plt.figure(figsize=(10, 4), constrained_layout=True)
plt.suptitle(r'DLF example for $J_0$ Hankel transform using 5 pt filter',
y=1.05)

Expand Down Expand Up @@ -171,9 +170,6 @@
plt.xlabel(r'$x$')
plt.xlim([x_x.min(), x_x.max()])

plt.tight_layout()
plt.show()

###############################################################################
# 3. Difference between standard, lagged convolution, and splined DLF
# -------------------------------------------------------------------
Expand Down Expand Up @@ -252,8 +248,6 @@
plt.ylabel('Fourier transform')
plt.ylim([-0.1, 1.1])

plt.show()

###############################################################################
# 3.2 Lagged Convolution DLF
# --------------------------
Expand Down Expand Up @@ -330,8 +324,6 @@
plt.ylabel('Fourier transform')
plt.ylim([-0.1, 1.1])

plt.show()

###############################################################################
# 3.3 Splined DLF
# ---------------
Expand Down Expand Up @@ -408,8 +400,6 @@
plt.ylabel('Fourier transform')
plt.ylim([-0.1, 1.1])

plt.show()

###############################################################################
# 4. Example for the Hankel transform
# -----------------------------------
Expand Down Expand Up @@ -499,9 +489,6 @@
plt.semilogy(x/1000, np.abs((splin100-resp)/resp), label='Splined 100/dec')
plt.xlabel('Offset (km)')

plt.tight_layout()
plt.show()

###############################################################################
# Runtimes and number of required wavenumbers for each method:
#
Expand Down Expand Up @@ -554,7 +541,7 @@
t = np.logspace(0, 2, 100)
xt = 2000

tparam = dc(params)
tparam = params.copy()
tparam['rec'] = [xt, 0, 200]
tparam['freqtime'] = t
tparam['signal'] = 0 # Impulse response
Expand Down Expand Up @@ -610,9 +597,6 @@
plt.semilogy(t, np.abs((tspline10-tresp)/tresp), label='Splined 10/dec')
plt.xlabel('Time (s)')

plt.tight_layout()
plt.show()

###############################################################################
# Runtimes and number of required frequencies for each method:
#
Expand Down
8 changes: 0 additions & 8 deletions examples/educational/halfspace_vs_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dhs', ab=ab, signal=0)
plot_t(EM, HS, 'Impulse HS', i)
plt.suptitle('Impulse HS')
plt.show()

###############################################################################
# Switch-on HS
Expand All @@ -69,7 +68,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dhs', ab=ab, signal=1)
plot_t(EM, HS, 'Switch-on HS', i)
plt.suptitle('Switch-on HS')
plt.show()

###############################################################################
# Switch-off HS
Expand All @@ -82,7 +80,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dhs', ab=ab, signal=-1)
plot_t(EM, HS, 'Switch-off HS', i)
plt.suptitle('Switch-off HS')
plt.show()

###############################################################################
# Impulse FS
Expand All @@ -95,7 +92,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dfs', ab=ab, signal=0)
plot_t(EM, HS, 'Impulse FS', i)
plt.suptitle('Impulse FS')
plt.show()

###############################################################################
# Switch-on FS
Expand All @@ -108,7 +104,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dfs', ab=ab, signal=1)
plot_t(EM, HS, 'Switch-on FS', i)
plt.suptitle('Switch-on FS')
plt.show()

###############################################################################
# Switch-off FS
Expand All @@ -123,7 +118,6 @@ def plot_t(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dfs', ab=ab, signal=-1)
plot_t(EM, HS, 'Switch-off FS', i)
plt.suptitle('Switch-off FS')
plt.show()

###############################################################################
# Frequency domain
Expand Down Expand Up @@ -153,7 +147,6 @@ def plot_f(EM, HS, title, i):
plot_f(EM, HS, 'Frequency HS', i)
plt.figure('Frequency HS')
plt.suptitle('Frequency HS')
plt.show()

###############################################################################
# Fullspace
Expand All @@ -166,7 +159,6 @@ def plot_f(EM, HS, title, i):
HS = empymod.analytical(**inpEM, **modFS, solution='dfs', ab=ab)
plot_f(EM, HS, 'Frequency FS', i)
plt.suptitle('Frequency FS')
plt.show()

###############################################################################

Expand Down
4 changes: 0 additions & 4 deletions examples/educational/ht_ft_with_other_modellers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
plt.xlabel('Frequency (Hz)')
plt.ylabel('$E_x$ (nV/m)')

plt.show()

###############################################################################
# Fourier transform
# -----------------
Expand Down Expand Up @@ -106,8 +104,6 @@
plt.xlabel('Time (s)')
plt.ylabel('$E_x$ (uV/m)')

plt.show()

###############################################################################

empymod.Report()
2 changes: 0 additions & 2 deletions examples/educational/random_noise_f_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ def stack(n, data, ntype, **kwargs):
ax.set_xlim([-4, 10])
ax2.set_xlabel('Real part')

# fig.tight_layout()
fig.show()

###############################################################################
#
Expand Down
4 changes: 0 additions & 4 deletions examples/educational/tmte_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@
plt.ylim([1e-17, 1e-9])
plt.xlim([0, 15])

plt.show()

###############################################################################
# The result shows that mainly the TM-mode contributions are sensitive to the
# reservoir. For TM, all modes contribute significantly except $T^{+-}$, which
Expand Down Expand Up @@ -124,8 +122,6 @@
plt.ylim([1e-17, 1e-9])
plt.xlim([0, 15])

plt.show()

###############################################################################

empymod.Report()
Loading

0 comments on commit a500f4b

Please sign in to comment.