Examples updated, minor bug fixes

This commit is contained in:
Fabian Joswig 2021-10-11 18:31:02 +01:00
parent e7ea0df660
commit 1d74e8c4f4
12 changed files with 1886 additions and 1717 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -6,8 +6,6 @@
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"import pyerrors as pe\n",
"import numpy as np\n",
"import scipy"
@ -169,7 +167,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[Obs[7.2(1.7)] Obs[-1.00(47)]]\n"
"[Obs[7.2(1.7)] Obs[-1.00(45)]]\n"
]
}
],
@ -229,7 +227,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"cond \t Obs[6.23(59)]\n",
"cond \t Obs[6.23(58)]\n",
"expm_cond \t Obs[4.45(19)]\n"
]
}
@ -261,7 +259,7 @@
"output_type": "stream",
"text": [
"[[Obs[2.025(49)] Obs[0.0]]\n",
" [Obs[-0.494(50)] Obs[0.870(29)]]]\n"
" [Obs[-0.494(51)] Obs[0.870(29)]]]\n"
]
}
],
@ -349,20 +347,20 @@
"output_type": "stream",
"text": [
"orth\n",
"[[Obs[-0.9592(75)] Obs[0.283(25)]]\n",
" [Obs[0.283(25)] Obs[0.9592(75)]]]\n",
"[[Obs[-0.9592(76)] Obs[0.283(26)]]\n",
" [Obs[0.283(26)] Obs[0.9592(76)]]]\n",
"expm\n",
"[[Obs[75(15)] Obs[-21.4(4.2)]]\n",
" [Obs[-21.4(4.2)] Obs[8.3(1.4)]]]\n",
"[[Obs[75(15)] Obs[-21.4(4.1)]]\n",
" [Obs[-21.4(4.1)] Obs[8.3(1.4)]]]\n",
"logm\n",
"[[Obs[1.334(57)] Obs[-0.496(61)]]\n",
" [Obs[-0.496(61)] Obs[-0.203(50)]]]\n",
"sinhm\n",
"[[Obs[37.3(7.4)] Obs[-10.8(2.1)]]\n",
" [Obs[-10.8(2.1)] Obs[3.94(69)]]]\n",
" [Obs[-10.8(2.1)] Obs[3.94(68)]]]\n",
"sqrtm\n",
"[[Obs[1.996(51)] Obs[-0.341(37)]]\n",
" [Obs[-0.341(37)] Obs[0.940(15)]]]\n"
" [Obs[-0.341(37)] Obs[0.940(14)]]]\n"
]
}
],
@ -397,8 +395,8 @@
"Eigenvalues:\n",
"[Obs[0.705(57)] Obs[4.39(19)]]\n",
"Eigenvectors:\n",
"[[Obs[-0.283(25)] Obs[-0.9592(75)]]\n",
" [Obs[-0.9592(75)] Obs[0.283(25)]]]\n"
"[[Obs[-0.283(26)] Obs[-0.9592(76)]]\n",
" [Obs[-0.9592(76)] Obs[0.283(26)]]]\n"
]
}
],
@ -467,7 +465,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.11"
"version": "3.6.9"
}
},
"nbformat": 4,

View file

@ -0,0 +1,30 @@
# Base mplstyle, Fabian Joswig, 2021
font.size: 12
lines.marker : o
lines.markersize : 6
lines.linewidth : 1.0
lines.linestyle : none
font.family: serif
axes.labelsize : 14
xtick.labelsize : 12
ytick.labelsize : 12
figure.dpi : 100
figure.figsize : 6.4, 3.9555 # figure size in inches, golden ratio
figure.subplot.left : 0.125 # the left side of the subplots of the figure
figure.subplot.right : 0.95 # the right side of the subplots of the figure
figure.subplot.bottom : 0.125 # the bottom of the subplots of the figure
figure.subplot.top : 0.95 # the top of the subplots of the figure
errorbar.capsize : 3.4641016 # sqrt(markersize * 2)
legend.fontsize : 12
legend.frameon : False
savefig.transparent : True
savefig.dpi : 300

Binary file not shown.

View file

@ -358,7 +358,7 @@ class Corr:
return
# Plotting routine for correlator
def show(self, x_range=None, comp=None, logscale=False, plateau=None, fit_res=None, save=None, ylabel=None):
def show(self, x_range=None, comp=None, y_range=None, logscale=False, plateau=None, fit_res=None, save=None, ylabel=None):
"""Plots the correlator, uses tag as label if available.
Parameters
@ -371,7 +371,7 @@ class Corr:
if self.N!=1:
raise Exception("Correlator must be projected before plotting")
if x_range is None:
x_range=[0, self.T]
x_range = [0, self.T]
fig = plt.figure()
ax1 = fig.add_subplot(111)
@ -382,12 +382,15 @@ class Corr:
ax1.set_yscale('log')
else:
# we generate ylim instead of using autoscaling.
try:
y_min=min([(x[0].value - x[0].dvalue) for x in self.content[x_range[0]:x_range[1]] if (x is not None) and x[0].dvalue < 2 * np.abs(x[0].value)])
y_max=max([(x[0].value + x[0].dvalue) for x in self.content[x_range[0]:x_range[1]] if (x is not None) and x[0].dvalue < 2 * np.abs(x[0].value)])
ax1.set_ylim([y_min - 0.1 * (y_max - y_min), y_max + 0.1 * (y_max - y_min)])
except:
pass
if y_range is None:
try:
y_min=min([(x[0].value - x[0].dvalue) for x in self.content[x_range[0]:x_range[1]] if (x is not None) and x[0].dvalue < 2 * np.abs(x[0].value)])
y_max=max([(x[0].value + x[0].dvalue) for x in self.content[x_range[0]:x_range[1]] if (x is not None) and x[0].dvalue < 2 * np.abs(x[0].value)])
ax1.set_ylim([y_min - 0.1 * (y_max - y_min), y_max + 0.1 * (y_max - y_min)])
except:
pass
else:
ax1.set_ylim(y_range)
if comp:
if isinstance(comp, Corr) or isinstance(comp, list):
for corr in comp if isinstance(comp, list) else [comp]:

View file

@ -575,7 +575,7 @@ def residual_plot(x, y, func, fit_res):
gs = gridspec.GridSpec(2, 1, height_ratios=[3, 1], wspace=0.0, hspace=0.0)
ax0 = plt.subplot(gs[0])
ax0.errorbar(x, [o.value for o in y], yerr=[o.dvalue for o in y], ls='none', fmt='o', capsize=3, markersize=5, label='Data')
ax0.plot(x_samples, func([o.value for o in fit_res], x_samples), label='Fit', zorder=10)
ax0.plot(x_samples, func([o.value for o in fit_res], x_samples), label='Fit', zorder=10, ls='-', ms=0)
ax0.set_xticklabels([])
ax0.set_xlim([xstart, xstop])
ax0.set_xticklabels([])