mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-16 12:33:41 +02:00
generalized read_mesons, added ylabel to Corr.show
This commit is contained in:
parent
f2b8a9580b
commit
b901dce582
2 changed files with 8 additions and 3 deletions
|
@ -293,7 +293,7 @@ class Corr:
|
||||||
#quick and dirty plotting function to view Correlator inside Jupyter
|
#quick and dirty plotting function to view Correlator inside Jupyter
|
||||||
#If one would not want to import pyplot, this could easily be replaced by a call to pe.plot_corrs
|
#If one would not want to import pyplot, this could easily be replaced by a call to pe.plot_corrs
|
||||||
#This might be a bit more flexible later
|
#This might be a bit more flexible later
|
||||||
def show(self, x_range=None, comp=None, logscale=False, plateau=None, fit_res=None, save=None):
|
def show(self, x_range=None, comp=None, logscale=False, plateau=None, fit_res=None, save=None, ylabel=None):
|
||||||
"""Plots the correlator, uses tag as label if available.
|
"""Plots the correlator, uses tag as label if available.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -345,6 +345,8 @@ class Corr:
|
||||||
, ls='-', marker=',', lw=2)
|
, ls='-', marker=',', lw=2)
|
||||||
|
|
||||||
ax1.set_xlabel(r'$x_0 / a$')
|
ax1.set_xlabel(r'$x_0 / a$')
|
||||||
|
if ylabel:
|
||||||
|
ax1.set_ylabel(ylabel)
|
||||||
ax1.set_xlim([x_range[0] - 0.5, x_range[1] + 0.5])
|
ax1.set_xlim([x_range[0] - 0.5, x_range[1] + 0.5])
|
||||||
|
|
||||||
handles, labels = ax1.get_legend_handles_labels()
|
handles, labels = ax1.get_legend_handles_labels()
|
||||||
|
|
|
@ -7,7 +7,7 @@ import numpy as np
|
||||||
from ..pyerrors import Obs
|
from ..pyerrors import Obs
|
||||||
from ..correlators import Corr
|
from ..correlators import Corr
|
||||||
|
|
||||||
def read_meson_hd5(path, filestem, ens_id, meson='meson_0'):
|
def read_meson_hd5(path, filestem, ens_id, meson='meson_0', tree='meson'):
|
||||||
"""Read hadrons meson hdf5 file and extract the meson labeled 'meson'
|
"""Read hadrons meson hdf5 file and extract the meson labeled 'meson'
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -28,6 +28,9 @@ def read_meson_hd5(path, filestem, ens_id, meson='meson_0'):
|
||||||
if l.startswith(filestem):
|
if l.startswith(filestem):
|
||||||
files.append(l)
|
files.append(l)
|
||||||
|
|
||||||
|
if not files:
|
||||||
|
raise Exception('No files starting with', filestem, 'in folder', path)
|
||||||
|
|
||||||
# Sort according to configuration number
|
# Sort according to configuration number
|
||||||
get_cnfg_number = lambda x : int(x[len(filestem) + 1:-3])
|
get_cnfg_number = lambda x : int(x[len(filestem) + 1:-3])
|
||||||
files.sort(key=get_cnfg_number)
|
files.sort(key=get_cnfg_number)
|
||||||
|
@ -44,7 +47,7 @@ def read_meson_hd5(path, filestem, ens_id, meson='meson_0'):
|
||||||
for hd5_file in files:
|
for hd5_file in files:
|
||||||
file = h5py.File(path + '/' + hd5_file, "r")
|
file = h5py.File(path + '/' + hd5_file, "r")
|
||||||
|
|
||||||
raw_data = list(file['meson/' + meson + '/corr'])
|
raw_data = list(file[tree + '/' + meson + '/corr'])
|
||||||
real_data = [o[0] for o in raw_data]
|
real_data = [o[0] for o in raw_data]
|
||||||
corr_data.append(real_data)
|
corr_data.append(real_data)
|
||||||
corr_data = np.array(corr_data)
|
corr_data = np.array(corr_data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue