51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
|
"""
|
||
|
============
|
||
|
Log-Gaussian
|
||
|
============
|
||
|
|
||
|
Example for Log-Gaussian distributions
|
||
|
"""
|
||
|
import matplotlib.pyplot as plt
|
||
|
import numpy as np
|
||
|
|
||
|
from nmreval.distributions import LogGaussian
|
||
|
|
||
|
x = np.logspace(-5, 5, num=101)
|
||
|
|
||
|
lg = LogGaussian
|
||
|
|
||
|
sigma_lg = [1, 3, 5]
|
||
|
|
||
|
fig, axes = plt.subplots(2, 3, constrained_layout=True)
|
||
|
|
||
|
lines = []
|
||
|
for s in sigma_lg:
|
||
|
axes[0, 0].plot(np.log10(x), lg.correlation(x, 1, s))
|
||
|
axes[1, 0].plot(np.log10(x), np.log10(lg.specdens(x, 1, s)))
|
||
|
axes[0, 1].plot(np.log10(x), np.log10(lg.susceptibility(x, 1, s).real))
|
||
|
axes[1, 1].plot(np.log10(x), np.log10(lg.susceptibility(x, 1, s).imag))
|
||
|
l, = axes[0, 2].plot(np.log10(x), lg.distribution(x, 1, s),
|
||
|
label=rf'$\sigma={s}$')
|
||
|
lines.append(l)
|
||
|
|
||
|
fig_titles = ('Correlation function', 'Susceptibility (real)', 'Distribution',
|
||
|
'Spectral density', 'Susceptibility (imag)')
|
||
|
fig_xlabel = (r'$\log(t/\tau_\mathrm{LG})$', r'$\log(\omega\tau_\mathrm{LG})$',
|
||
|
r'$\log(\tau/\tau_\mathrm{LG})$', r'$\log(\omega\tau_\mathrm{LG})$',
|
||
|
r'$\log(\omega\tau_\mathrm{LG})$')
|
||
|
fig_ylabel = (r'$C(t)$', r"$\log(\chi'(\omega))$", r'$G(\ln\tau)$',
|
||
|
r'$\log(J(\omega))$', r"$\log(\chi''(\omega))$")
|
||
|
|
||
|
for title, xlabel, ylabel, ax in zip(fig_titles, fig_xlabel, fig_ylabel, axes.ravel()):
|
||
|
ax.set_title(title)
|
||
|
ax.set_xlabel(xlabel)
|
||
|
ax.set_ylabel(ylabel)
|
||
|
|
||
|
labels = [l.get_label() for l in lines]
|
||
|
leg = fig.legend(lines, labels, loc='center left', bbox_to_anchor=(1.05, 0.50),
|
||
|
bbox_transform=axes[1, 1].transAxes)
|
||
|
|
||
|
fig.delaxes(axes[1, 2])
|
||
|
|
||
|
plt.show()
|