mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 06:40:24 +01:00
feat: spaghetti_plot method for monitoring exceptional configurations added to Corr class, tests added.
This commit is contained in:
parent
e5d7271a2b
commit
8d0bfafaab
2 changed files with 40 additions and 3 deletions
|
@ -794,7 +794,34 @@ class Corr:
|
|||
else:
|
||||
raise Exception("'save' has to be a string.")
|
||||
|
||||
return
|
||||
def spaghetti_plot(self, logscale=True):
|
||||
"""Produces a spaghetti plot of the correlator suited to monitor exceptional configurations.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
logscale : bool
|
||||
Determines whether the scale of the y-axis is logarithmic or standard.
|
||||
"""
|
||||
if self.N != 1:
|
||||
raise Exception("Correlator needs to be projected first.")
|
||||
|
||||
mc_names = list(set([item for sublist in [o[0].mc_names for o in self.content if o is not None] for item in sublist]))
|
||||
x0_vals = [n for (n, o) in zip(np.arange(self.T), self.content) if o is not None]
|
||||
|
||||
for name in mc_names:
|
||||
data = np.array([o[0].deltas[name] + o[0].r_values[name] for o in self.content if o is not None]).T
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111)
|
||||
for dat in data:
|
||||
ax.plot(x0_vals, dat, ls='-', marker='')
|
||||
|
||||
if logscale is True:
|
||||
ax.set_yscale('log')
|
||||
|
||||
ax.set_xlabel(r'$x_0 / a$')
|
||||
plt.title(name)
|
||||
plt.draw()
|
||||
|
||||
def dump(self, filename, datatype="json.gz", **kwargs):
|
||||
"""Dumps the Corr into a file of chosen type
|
||||
|
|
|
@ -325,10 +325,20 @@ def test_corr_vector_operations():
|
|||
assert np.all([o == 0 for o in ((my_corr * my_vec) / my_vec) - my_corr])
|
||||
assert np.all([o == 0 for o in ((my_corr / my_vec) * my_vec) - my_corr])
|
||||
|
||||
def _gen_corr(val):
|
||||
|
||||
def test_spaghetti_plot():
|
||||
corr = _gen_corr(12, 50)
|
||||
corr += pe.pseudo_Obs(0.0, 0.1, 'another_ensemble')
|
||||
corr += pe.cov_Obs(0.0, 0.01 ** 2, 'covobs')
|
||||
|
||||
corr.spaghetti_plot(True)
|
||||
corr.spaghetti_plot(False)
|
||||
|
||||
|
||||
def _gen_corr(val, samples=2000):
|
||||
corr_content = []
|
||||
for t in range(16):
|
||||
corr_content.append(pe.pseudo_Obs(val, 0.1, 't', 2000))
|
||||
corr_content.append(pe.pseudo_Obs(val, 0.1, 't', samples))
|
||||
|
||||
return pe.correlators.Corr(corr_content)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue