new idea for reading ms5_xsf data

This commit is contained in:
jkuhl-uni 2022-12-19 18:29:51 +01:00
parent 6ef081acef
commit 3399b72bfb

View file

@ -1001,6 +1001,7 @@ def read_ms5_xsf(path, prefix, qc, corr):
files = sorted(files) files = sorted(files)
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]
t = fp.read(8) t = fp.read(8)
@ -1018,29 +1019,62 @@ def read_ms5_xsf(path, prefix, qc, corr):
bnd = struct.unpack('i', t)[0] bnd = struct.unpack('i', t)[0]
print("T:", tmax) print("T:", tmax)
t = fp.read(4)
cnfg = struct.unpack('i', t)[0] placesBI = ["gS", "gP",
print(cnfg) "gA", "gV",
placesBI = ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", "gVt", "lA",
"lV", "lVt",
"lT", "lTt"] "lT", "lTt"]
placesBB = ["g1", "l1"] placesBB = ["g1", "l1"]
if not corr in placesBB:
for i in range(placesBI.index(corr)):
t = fp.read(8*2*tmax)
t = fp.read(8*2*tmax) # bytes per config
tmpcorr = struct.unpack('d'*2*tmax, t) # the chunks have the following structure:
# confignumber, 10x timedependent complex correlators, 2x timeindependent complex correlators
chunksize = 4 +( 8 *2*tmax*10)+( 8 *2*2)
print(chunksize)
packstr ='i'+('d'*2*tmax*10)+('d'*2*2)
while True:
cnfgt = fp.read(chunksize)
if not cnfgt:
break
asascii=struct.unpack(packstr, cnfgt)
cnfg = asascii[0]
#cnfg = struct.unpack('i', t)[0]
print(cnfg)
if not corr in placesBB:
#for i in range(placesBI.index(corr)):
# t = fp.read(8*2*tmax)
tmpcorr = asascii[1+2*tmax*placesBI.index(corr):1+2*tmax*placesBI.index(corr)+2*tmax]
#t = fp.read(8*2*tmax)
#tmpcorr = struct.unpack('d'*2*tmax, t)
corrres = [[],[]] corrres = [[],[]]
for i in range(len(tmpcorr)): for i in range(len(tmpcorr)):
corrres[i%2].append(tmpcorr[i]) corrres[i%2].append(tmpcorr[i])
# jump to next config
#t = fp.read(chunksize-(4+placesBI.index(corr)*8*2*tmax+2*8*2))
else: else:
#for i in range(placesBI.index(corr)):
# t = fp.read(8*2*tmax)
tmpcorr = asascii[1+2*tmax*len(placesBI):1+2*tmax*len(placesBI)+2]
#t = fp.read(8*2*tmax)
#tmpcorr = struct.unpack('d'*2*tmax, t)
corrres = [[],[]]
for i in range(len(tmpcorr)):
corrres[i%2].append(tmpcorr[i])
# jump to next config
#t = fp.read(chunksize-(4+placesBI.index(corr)*8*2*tmax+2*8*2))
# boundary to boundary correlators # boundary to boundary correlators
for i in range(len(placesBI)): #for i in range(len(placesBI)):
t = fp.read(8*2*tmax) # t = fp.read(8*2*tmax)
for i in range(placesBB.index(corr)): #for i in range(placesBB.index(corr)):
t = fp.read(8*2) # t = fp.read(8*2)
t = fp.read(8*2) #t = fp.read(8*2)
corrres = list(struct.unpack('d'*2, t)) #corrres = list(struct.unpack('d'*2, t))
# jump to next config
#t = fp.read(chunksize-(4+len(placesBI)*8*2*tmax+(2-placesBB.index(corr))*8*2))
print(corrres) print(corrres)