From 6ef081acef0b76498429332648c10d3b733d8374 Mon Sep 17 00:00:00 2001 From: jkuhl-uni Date: Fri, 16 Dec 2022 13:02:59 +0100 Subject: [PATCH] first version of skript to read xsf data --- pyerrors/input/hadrons.py | 4 ++- pyerrors/input/openQCD.py | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/pyerrors/input/hadrons.py b/pyerrors/input/hadrons.py index dc8429e1..0892bf57 100644 --- a/pyerrors/input/hadrons.py +++ b/pyerrors/input/hadrons.py @@ -1,4 +1,5 @@ import os +import warnings from collections import Counter import h5py from pathlib import Path @@ -47,8 +48,9 @@ def _get_files(path, filestem, idl): idx = range(cnfg_numbers[0], cnfg_numbers[-1] + dc[0], dc[0]) elif idl: idx = idl + warnings.warn("Configurations are not evenly spaced.", RuntimeWarning) else: - raise Exception("Configurations are not evenly spaced. Provide an idl if you want to proceed with this set of configurations.") + raise Exception("Configurations are not evenly spaced.") return filtered_files, idx diff --git a/pyerrors/input/openQCD.py b/pyerrors/input/openQCD.py index 840ffc0e..0cf4762b 100644 --- a/pyerrors/input/openQCD.py +++ b/pyerrors/input/openQCD.py @@ -985,3 +985,63 @@ def read_qtop_sector(path, prefix, c, target=0, **kwargs): qtop = read_qtop(path, prefix, c, **kwargs) return qtop_projection(qtop, target=target) + + +def read_ms5_xsf(path, prefix, qc, corr): + + found = [] + files = [] + for (dirpath, dirnames, filenames) in os.walk(path + "/"): + found.extend(filenames) + break + for f in found: + if fnmatch.fnmatch(f, prefix + ".ms5_xsf_"+qc+".dat"): + files.append(f) + + files = sorted(files) + for file in files: + with open(path+"/"+file, "rb") as fp: + t = fp.read(8) + kappa = struct.unpack('d', t)[0] + t = fp.read(8) + csw = struct.unpack('d', t)[0] + t = fp.read(8) + dF = struct.unpack('d', t)[0] + t = fp.read(8) + zF = struct.unpack('d', t)[0] + + print("Parameters:\n kappa:",kappa, "csw:",csw,"dF:", dF,"zF:", zF) + + t = fp.read(4) + tmax = struct.unpack('i', t)[0] + t = fp.read(4) + bnd = struct.unpack('i', t)[0] + + print("T:", tmax) + t = fp.read(4) + cnfg = struct.unpack('i', t)[0] + print(cnfg) + placesBI = ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", + "lT", "lTt"] + 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) + tmpcorr = struct.unpack('d'*2*tmax, t) + corrres = [[],[]] + for i in range(len(tmpcorr)): + corrres[i%2].append(tmpcorr[i]) + else: + # boundary to boundary correlators + for i in range(len(placesBI)): + t = fp.read(8*2*tmax) + for i in range(placesBB.index(corr)): + t = fp.read(8*2) + t = fp.read(8*2) + corrres = list(struct.unpack('d'*2, t)) + + + print(corrres) +