mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
Merge branch 'develop' into feature/v2.0
This commit is contained in:
commit
d78254937b
13 changed files with 1893 additions and 1724 deletions
14
README.md
14
README.md
|
@ -11,7 +11,7 @@ It is based on the gamma method [arXiv:hep-lat/0306017](https://arxiv.org/abs/he
|
|||
* implementation of the matrix-pencil-method [IEEE Trans. Acoust. 38, 814-824 (1990)](https://ieeexplore.ieee.org/document/56027) for the extraction of energy levels, especially suited for noisy data and excited states
|
||||
|
||||
There exist similar implementations of gamma method error analysis suites in
|
||||
- [Fortran](https://gitlab.ift.uam-csic.es/alberto/aderrors).
|
||||
- [Fortran](https://gitlab.ift.uam-csic.es/alberto/aderrors)
|
||||
- [Julia](https://gitlab.ift.uam-csic.es/alberto/aderrors.jl)
|
||||
- [Python 3](https://github.com/mbruno46/pyobs)
|
||||
|
||||
|
@ -34,15 +34,15 @@ The basic objects of a pyerrors analysis are instances of the class `Obs`. They
|
|||
import numpy as np
|
||||
import pyerrors as pe
|
||||
|
||||
observable1 = pe.Obs([samples1], ['ensemble1'])
|
||||
observable1.gamma_method()
|
||||
observable1.print()
|
||||
obs1 = pe.Obs([samples1], ['ensemble1'])
|
||||
obs1.gamma_method()
|
||||
obs1.print()
|
||||
```
|
||||
Often one is interested in secondary observables which can be arbitrary functions of primary observables. `pyerrors` overloads most basic math operations and numpy functions such that the user can work with `Obs` objects as if they were floats
|
||||
```python
|
||||
observable3 = 12.0 / observable1 ** 2 - np.exp(-1.0 / observable2)
|
||||
observable3.gamma_method()
|
||||
observable3.print()
|
||||
obs3 = 12.0 / obs1 ** 2 - np.exp(-1.0 / obs2)
|
||||
obs3.gamma_method()
|
||||
obs3.print()
|
||||
```
|
||||
|
||||
More detailed examples can be found in the `/examples` folder:
|
||||
|
|
File diff suppressed because one or more lines are too long
397
examples/02_correlators.ipynb
Normal file
397
examples/02_correlators.ipynb
Normal file
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
599
examples/03_pcac_example.ipynb
Normal file
599
examples/03_pcac_example.ipynb
Normal file
File diff suppressed because one or more lines are too long
782
examples/04_fit_example.ipynb
Normal file
782
examples/04_fit_example.ipynb
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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,
|
30
examples/base_style.mplstyle
Normal file
30
examples/base_style.mplstyle
Normal 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
|
BIN
examples/data/correlator_test.p
Normal file
BIN
examples/data/correlator_test.p
Normal file
Binary file not shown.
|
@ -354,7 +354,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
|
||||
|
@ -367,7 +367,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)
|
||||
|
@ -378,12 +378,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]:
|
||||
|
|
|
@ -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([])
|
||||
|
|
Loading…
Add table
Reference in a new issue