Skip to content

Commit

Permalink
Examples updated, minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fjosw committed Oct 11, 2021
1 parent e7ea0df commit 1d74e8c
Show file tree
Hide file tree
Showing 12 changed files with 1,886 additions and 1,717 deletions.
107 changes: 54 additions & 53 deletions examples/01_basic_example.ipynb

Large diffs are not rendered by default.

397 changes: 397 additions & 0 deletions examples/02_correlators.ipynb

Large diffs are not rendered by default.

591 changes: 0 additions & 591 deletions examples/02_pcac_example.ipynb

This file was deleted.

774 changes: 0 additions & 774 deletions examples/03_fit_example.ipynb

This file was deleted.

599 changes: 599 additions & 0 deletions examples/03_pcac_example.ipynb

Large diffs are not rendered by default.

782 changes: 782 additions & 0 deletions examples/04_fit_example.ipynb

Large diffs are not rendered by default.

276 changes: 0 additions & 276 deletions examples/05_correlators.ipynb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
}
Expand Down Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
}
],
Expand Down Expand Up @@ -467,7 +465,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.11"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
30 changes: 30 additions & 0 deletions examples/base_style.mplstyle
Original file line number Diff line number Diff line change
@@ -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 added examples/data/correlator_test.p
Binary file not shown.
19 changes: 11 additions & 8 deletions pyerrors/correlators.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def set_prange(self, prange):
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
Expand All @@ -371,7 +371,7 @@ def show(self, x_range=None, comp=None, logscale=False, plateau=None, fit_res=No
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)
Expand All @@ -382,12 +382,15 @@ def show(self, x_range=None, comp=None, logscale=False, plateau=None, fit_res=No
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]:
Expand Down
2 changes: 1 addition & 1 deletion pyerrors/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([])
Expand Down

0 comments on commit 1d74e8c

Please sign in to comment.