diff --git a/corrlib/find.py b/corrlib/find.py index 2b9973f..0c5f9a6 100644 --- a/corrlib/find.py +++ b/corrlib/find.py @@ -148,7 +148,7 @@ def find_record(path, ensemble, correlator_name, code, project=None, parameters= results = _db_lookup(db, ensemble, correlator_name,code, project, parameters=parameters, created_before=created_before, created_after=created_after, updated_before=updated_before, updated_after=updated_after, revision=revision) if code == "sfcf": results = sfcf_filter(results, **kwargs) - print("Found " + str(len(results)) + " result" + ("s" if len(results)>1 else "")) + print("Found " + str(len(results)) + " results") return results.reset_index() diff --git a/corrlib/input/hadrons.py b/corrlib/input/hadrons.py new file mode 100644 index 0000000..b335138 --- /dev/null +++ b/corrlib/input/hadrons.py @@ -0,0 +1,48 @@ +import pyerrors.input.hadrons as input +import datalad.api as dl +import os + +# same as in Grid/qcd/spin/Gamma.h + +defd_gammas=[ + 'MinusGamma5', 'Gamma5', + 'MinusGammaT', 'GammaT', 'MinusGammaTGamma5', 'GammaTGamma5', + 'MinusGammaX', 'GammaX', 'MinusGammaXGamma5', 'GammaXGamma5', + 'MinusGammaY', 'GammaY', 'MinusGammaYGamma5', 'GammaYGamma5', + 'MinusGammaZ', 'GammaZ', 'MinusGammaZGamma5', 'GammaZGamma5', + 'MinusIdentity', 'Identity', + 'MinusSigmaXT', 'SigmaXT', + 'MinusSigmaXY', 'SigmaXY', + 'MinusSigmaXZ', 'SigmaXZ', + 'MinusSigmaYT', 'SigmaYT', + 'MinusSigmaYZ', 'SigmaYZ', + 'MinusSigmaZT', 'SigmaZT' + ] + + +def read_meson_hd5(path, project, dir_in_project, prefix, ensemble, gammas): + directory = os.path.join(path, "projects", project, dir_in_project) + measurements = {} + + dl.get(directory, dataset=path) + + if gammas == 'all': + for g1 in defd_gammas: + for g2 in defd_gammas: + try: + corr = input.read_meson_hd5(directory, prefix, ensemble, (g1, g2)) + measurements[g1][g2] = corr + except Exception: + raise Exception("Combination (" + g1 + "," + g2 + ") not in data.") + else: + for gs in gammas: + if len(gs) == 2: + if gs[0] not in defd_gammas: + raise ValueError(gammas[0] + " is none of the defined gammas.") + if gs[1] not in defd_gammas: + raise ValueError(gammas[1] + " is none of the defined gammas.") + corr = input.read_meson_hd5(directory, prefix, ensemble, gs) + measurements[gs[0]][gs[1]] = corr + else: + raise Exception("Each element in 'gammas' has to have length 2.") + return measurements