mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-16 15:20:24 +01:00
linting...
This commit is contained in:
parent
f9fe5c7ec9
commit
3fdbc371b2
1 changed files with 48 additions and 40 deletions
|
@ -990,7 +990,7 @@ def read_qtop_sector(path, prefix, c, target=0, **kwargs):
|
||||||
return qtop_projection(qtop, target=target)
|
return qtop_projection(qtop, target=target)
|
||||||
|
|
||||||
|
|
||||||
def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
def read_ms5_xsf(path, prefix, qc, corr, sep="r", **kwargs):
|
||||||
"""
|
"""
|
||||||
Read data from files in the specified directory with the specified prefix and quark combination extension, and return a `Corr` object containing the data.
|
Read data from files in the specified directory with the specified prefix and quark combination extension, and return a `Corr` object containing the data.
|
||||||
|
|
||||||
|
@ -1025,17 +1025,19 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
struct.error
|
struct.error
|
||||||
If there is an error unpacking binary data.
|
If there is an error unpacking binary data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
found = []
|
found = []
|
||||||
files = []
|
files = []
|
||||||
names = []
|
names = []
|
||||||
for (dirpath, dirnames, filenames) in os.walk(path + "/"):
|
for (dirpath, dirnames, filenames) in os.walk(path + "/"):
|
||||||
found.extend(filenames)
|
found.extend(filenames)
|
||||||
break
|
break
|
||||||
|
|
||||||
for f in found:
|
for f in found:
|
||||||
if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_"+qc+".dat"):
|
if fnmatch.fnmatch(f, prefix + "*.ms5_xsf_" + qc + ".dat"):
|
||||||
files.append(f)
|
files.append(f)
|
||||||
if not sep == "":
|
if not sep == "":
|
||||||
names.append(prefix+"|r"+f.split(".")[0].split(sep)[1])
|
names.append(prefix + "|r" + f.split(".")[0].split(sep)[1])
|
||||||
else:
|
else:
|
||||||
names.append(prefix)
|
names.append(prefix)
|
||||||
files = sorted(files)
|
files = sorted(files)
|
||||||
|
@ -1050,7 +1052,7 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
imagsamples = []
|
imagsamples = []
|
||||||
repnum = 0
|
repnum = 0
|
||||||
for file in files:
|
for file in files:
|
||||||
with open(path+"/"+file, "rb") as fp:
|
with open(path + "/" + file, "rb") as fp:
|
||||||
|
|
||||||
t = fp.read(8)
|
t = fp.read(8)
|
||||||
kappa = struct.unpack('d', t)[0]
|
kappa = struct.unpack('d', t)[0]
|
||||||
|
@ -1064,8 +1066,7 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
t = fp.read(4)
|
t = fp.read(4)
|
||||||
tmax = struct.unpack('i', t)[0]
|
tmax = struct.unpack('i', t)[0]
|
||||||
t = fp.read(4)
|
t = fp.read(4)
|
||||||
bnd = struct.unpack('i', t)[0]
|
# bnd = struct.unpack('i', t)[0]
|
||||||
|
|
||||||
|
|
||||||
placesBI = ["gS", "gP",
|
placesBI = ["gS", "gP",
|
||||||
"gA", "gV",
|
"gA", "gV",
|
||||||
|
@ -1078,8 +1079,8 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
# the chunks have the following structure:
|
# the chunks have the following structure:
|
||||||
# confignumber, 10x timedependent complex correlators as doubles, 2x timeindependent complex correlators as doubles
|
# confignumber, 10x timedependent complex correlators as doubles, 2x timeindependent complex correlators as doubles
|
||||||
|
|
||||||
chunksize = 4 +( 8 *2*tmax*10)+( 8 *2*2)
|
chunksize = 4 + (8 * 2 * tmax * 10) + (8 * 2 * 2)
|
||||||
packstr ='=i'+('d'*2*tmax*10)+('d'*2*2)
|
packstr = '=i' + ('d' * 2 * tmax * 10) + ('d' * 2 * 2)
|
||||||
cnfgs.append([])
|
cnfgs.append([])
|
||||||
realsamples.append([])
|
realsamples.append([])
|
||||||
imagsamples.append([])
|
imagsamples.append([])
|
||||||
|
@ -1091,24 +1092,28 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
cnfgt = fp.read(chunksize)
|
cnfgt = fp.read(chunksize)
|
||||||
if not cnfgt:
|
if not cnfgt:
|
||||||
break
|
break
|
||||||
asascii=struct.unpack(packstr, cnfgt)
|
asascii = struct.unpack(packstr, cnfgt)
|
||||||
cnfg = asascii[0]
|
cnfg = asascii[0]
|
||||||
cnfgs[repnum].append(cnfg)
|
cnfgs[repnum].append(cnfg)
|
||||||
|
|
||||||
if not corr in placesBB:
|
if corr not in placesBB:
|
||||||
tmpcorr = asascii[1+2*tmax*placesBI.index(corr):1+2*tmax*placesBI.index(corr)+2*tmax]
|
tmpcorr = asascii[1 + 2 * tmax * placesBI.index(corr):1 + 2 * tmax * placesBI.index(corr) + 2 * tmax]
|
||||||
else:
|
else:
|
||||||
tmpcorr = asascii[1+2*tmax*len(placesBI)+2*placesBB.index(corr):1+2*tmax*len(placesBI)+2*placesBB.index(corr)+2]
|
tmpcorr = asascii[1 + 2 * tmax * len(placesBI) + 2 * placesBB.index(corr):1 + 2 * tmax * len(placesBI) + 2 * placesBB.index(corr) + 2]
|
||||||
corrres = [[],[]]
|
|
||||||
for i in range(len(tmpcorr)): corrres[i%2].append(tmpcorr[i])
|
corrres = [[], []]
|
||||||
for t in range(int(len(tmpcorr)/2)): realsamples[repnum][t].append(corrres[0][t])
|
for i in range(len(tmpcorr)):
|
||||||
for t in range(int(len(tmpcorr)/2)): imagsamples[repnum][t].append(corrres[1][t])
|
corrres[i % 2].append(tmpcorr[i])
|
||||||
|
for t in range(int(len(tmpcorr) / 2)):
|
||||||
|
realsamples[repnum][t].append(corrres[0][t])
|
||||||
|
for t in range(int(len(tmpcorr) / 2)):
|
||||||
|
imagsamples[repnum][t].append(corrres[1][t])
|
||||||
repnum += 1
|
repnum += 1
|
||||||
|
|
||||||
s = "Read correlator "+ corr+ " from "+ str(repnum)+ " replika with "+str(len(realsamples[0][t]))
|
s = "Read correlator " + corr + " from " + str(repnum) + " replika with " + str(len(realsamples[0][t]))
|
||||||
for rep in range(1,repnum):
|
for rep in range(1, repnum):
|
||||||
s+=", "+str(len(realsamples[rep][t]))
|
s += ", " + str(len(realsamples[rep][t]))
|
||||||
s+=" samples"
|
s += " samples"
|
||||||
print(s)
|
print(s)
|
||||||
print("Asserted run parameters:\n T:", tmax, "kappa:", kappa, "csw:", csw, "dF:", dF, "zF:", zF)
|
print("Asserted run parameters:\n T:", tmax, "kappa:", kappa, "csw:", csw, "dF:", dF, "zF:", zF)
|
||||||
|
|
||||||
|
@ -1118,7 +1123,10 @@ def read_ms5_xsf(path, prefix, qc, corr, sep = "r", **kwargs):
|
||||||
imagObs = []
|
imagObs = []
|
||||||
compObs = []
|
compObs = []
|
||||||
|
|
||||||
for t in range(int(len(tmpcorr)/2)): realObs.append(Obs([realsamples[rep][t] for rep in range(repnum)], names = names, idl = cnfgs))
|
for t in range(int(len(tmpcorr) / 2)):
|
||||||
for t in range(int(len(tmpcorr)/2)): imagObs.append(Obs([imagsamples[rep][t] for rep in range(repnum)], names = names, idl = cnfgs))
|
realObs.append(Obs([realsamples[rep][t] for rep in range(repnum)], names=names, idl=cnfgs))
|
||||||
for t in range(int(len(tmpcorr)/2)): compObs.append(CObs(realObs[t], imagObs[t]))
|
for t in range(int(len(tmpcorr) / 2)):
|
||||||
|
imagObs.append(Obs([imagsamples[rep][t] for rep in range(repnum)], names=names, idl=cnfgs))
|
||||||
|
for t in range(int(len(tmpcorr) / 2)):
|
||||||
|
compObs.append(CObs(realObs[t], imagObs[t]))
|
||||||
return Corr(compObs)
|
return Corr(compObs)
|
Loading…
Add table
Reference in a new issue