Compare commits
No commits in common. "8736755feaa8d51ca91eb181ed5f11457a637cbd" and "f98521b5a1f6839d1624579186677ee8ce5cbf5d" have entirely different histories.
8736755fea
...
f98521b5a1
7 changed files with 7 additions and 186 deletions
|
|
@ -4,12 +4,9 @@ import os
|
||||||
import fnmatch
|
import fnmatch
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from ..pars.openQCD import ms1
|
|
||||||
from ..pars.openQCD import qcd2
|
|
||||||
|
|
||||||
|
|
||||||
|
def read_ms1_param(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
||||||
def load_ms1_infile(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
|
||||||
"""
|
"""
|
||||||
Read the parameters for ms1 measurements from a parameter file in the project.
|
Read the parameters for ms1 measurements from a parameter file in the project.
|
||||||
|
|
||||||
|
|
@ -73,7 +70,7 @@ def load_ms1_infile(path: Path, project: str, file_in_project: str) -> dict[str,
|
||||||
return param
|
return param
|
||||||
|
|
||||||
|
|
||||||
def load_ms3_infile(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
def read_ms3_param(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Read the parameters for ms3 measurements from a parameter file in the project.
|
Read the parameters for ms3 measurements from a parameter file in the project.
|
||||||
|
|
||||||
|
|
@ -307,51 +304,3 @@ def extract_t1(path: Path, project: str, dir_in_project: str, param: dict[str, A
|
||||||
t1_dict[param["type"]] = {}
|
t1_dict[param["type"]] = {}
|
||||||
t1_dict[param["type"]][pars] = t0
|
t1_dict[param["type"]][pars] = t0
|
||||||
return t1_dict
|
return t1_dict
|
||||||
|
|
||||||
|
|
||||||
def load_qcd2_pars(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Thin wrapper around read_qcd2_par_file, getting the file before reading.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
path: Path
|
|
||||||
Path of the corrlib repository.
|
|
||||||
project: str
|
|
||||||
UUID of the project of the parameter-file.
|
|
||||||
file_in_project: str
|
|
||||||
The loaction of the file in the project directory.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
par_dict: dict
|
|
||||||
The dict with the parameters read from the .par-file.
|
|
||||||
"""
|
|
||||||
fname = path / "projects" / project / file_in_project
|
|
||||||
ds = os.path.join(path, "projects", project)
|
|
||||||
dl.get(fname, dataset=ds)
|
|
||||||
return qcd2.read_qcd2_par_file(fname)
|
|
||||||
|
|
||||||
|
|
||||||
def load_ms1_parfile(path: Path, project: str, file_in_project: str) -> dict[str, Any]:
|
|
||||||
"""
|
|
||||||
Thin wrapper around read_qcd2_ms1_par_file, getting the file before reading.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
path: Path
|
|
||||||
Path of the corrlib repository.
|
|
||||||
project: str
|
|
||||||
UUID of the project of the parameter-file.
|
|
||||||
file_in_project: str
|
|
||||||
The loaction of the file in the project directory.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
par_dict: dict
|
|
||||||
The dict with the parameters read from the .par-file.
|
|
||||||
"""
|
|
||||||
fname = path / "projects" / project / file_in_project
|
|
||||||
ds = os.path.join(path, "projects", project)
|
|
||||||
dl.get(fname, dataset=ds)
|
|
||||||
return ms1.read_qcd2_ms1_par_file(fname)
|
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,7 @@ def write_measurement(path: Path, ensemble: str, measurement: dict[str, dict[str
|
||||||
ms_type = list(measurement.keys())[0]
|
ms_type = list(measurement.keys())[0]
|
||||||
if ms_type == 'ms1':
|
if ms_type == 'ms1':
|
||||||
if parameter_file is not None:
|
if parameter_file is not None:
|
||||||
if parameter_file.endswith(".ms1.in"):
|
parameters = openQCD.read_ms1_param(path, uuid, parameter_file)
|
||||||
parameters = openQCD.load_ms1_infile(path, uuid, parameter_file)
|
|
||||||
elif parameter_file.endswith(".ms1.par"):
|
|
||||||
parameters = openQCD.load_ms1_parfile(path, uuid, parameter_file)
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Need parameter file for this code!")
|
raise Exception("Need parameter file for this code!")
|
||||||
pars = {}
|
pars = {}
|
||||||
|
|
@ -91,7 +88,7 @@ def write_measurement(path: Path, ensemble: str, measurement: dict[str, dict[str
|
||||||
pars[subkey] = json.dumps(parameters["rw_fcts"][i])
|
pars[subkey] = json.dumps(parameters["rw_fcts"][i])
|
||||||
elif ms_type in ['t0', 't1']:
|
elif ms_type in ['t0', 't1']:
|
||||||
if parameter_file is not None:
|
if parameter_file is not None:
|
||||||
parameters = openQCD.load_ms3_infile(path, uuid, parameter_file)
|
parameters = openQCD.read_ms3_param(path, uuid, parameter_file)
|
||||||
else:
|
else:
|
||||||
parameters = {}
|
parameters = {}
|
||||||
for rwp in ["integrator", "eps", "ntot", "dnms"]:
|
for rwp in ["integrator", "eps", "ntot", "dnms"]:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
from . import ms1 as ms1
|
|
||||||
from . import qcd2 as qcd2
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
"""
|
|
||||||
Reconstruct the outputs of flags.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import struct
|
|
||||||
from typing import Any, BinaryIO
|
|
||||||
|
|
||||||
# lat_parms.c
|
|
||||||
def lat_parms_write_lat_parms(fp: BinaryIO) -> dict[str, Any]:
|
|
||||||
"""
|
|
||||||
NOTE: This is a duplcation from qcd2.
|
|
||||||
Unpack the lattice parameters written by write_lat_parms.
|
|
||||||
"""
|
|
||||||
lat_pars = {}
|
|
||||||
t = fp.read(16)
|
|
||||||
lat_pars["N"] = list(struct.unpack('iiii', t)) # lattice extends
|
|
||||||
t = fp.read(8)
|
|
||||||
nk, isw = struct.unpack('ii', t) # number of kappas and isw parameter
|
|
||||||
lat_pars["nk"] = nk
|
|
||||||
lat_pars["isw"] = isw
|
|
||||||
t = fp.read(8)
|
|
||||||
lat_pars["beta"] = struct.unpack('d', t)[0] # beta
|
|
||||||
t = fp.read(8)
|
|
||||||
lat_pars["c0"] = struct.unpack('d', t)[0]
|
|
||||||
t = fp.read(8)
|
|
||||||
lat_pars["c1"] = struct.unpack('d', t)[0]
|
|
||||||
t = fp.read(8)
|
|
||||||
lat_pars["csw"] = struct.unpack('d', t)[0] # csw factor
|
|
||||||
kappas = []
|
|
||||||
m0s = []
|
|
||||||
# read kappas
|
|
||||||
for ik in range(nk):
|
|
||||||
t = fp.read(8)
|
|
||||||
kappas.append(struct.unpack('d', t)[0])
|
|
||||||
t = fp.read(8)
|
|
||||||
m0s.append(struct.unpack('d', t)[0])
|
|
||||||
lat_pars["kappas"] = kappas
|
|
||||||
lat_pars["m0s"] = m0s
|
|
||||||
return lat_pars
|
|
||||||
|
|
||||||
|
|
||||||
def lat_parms_write_bc_parms(fp: BinaryIO) -> dict[str, Any]:
|
|
||||||
"""
|
|
||||||
NOTE: This is a duplcation from qcd2.
|
|
||||||
Unpack the boundary parameters written by write_bc_parms.
|
|
||||||
"""
|
|
||||||
bc_pars: dict[str, Any] = {}
|
|
||||||
t = fp.read(4)
|
|
||||||
bc_pars["type"] = struct.unpack('i', t)[0] # type of hte boundaries
|
|
||||||
t = fp.read(104)
|
|
||||||
bc_parms = struct.unpack('d'*13, t)
|
|
||||||
bc_pars["cG"] = list(bc_parms[:2]) # boundary gauge field improvement
|
|
||||||
bc_pars["cF"] = list(bc_parms[2:4]) # boundary fermion field improvement
|
|
||||||
phi: list[list[float]] = [[], []]
|
|
||||||
phi[0] = list(bc_parms[4:7])
|
|
||||||
phi[1] = list(bc_parms[7:10])
|
|
||||||
bc_pars["phi"] = phi
|
|
||||||
bc_pars["theta"] = list(bc_parms[10:])
|
|
||||||
return bc_pars
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
from . import flags
|
|
||||||
|
|
||||||
from typing import Any
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
def read_qcd2_ms1_par_file(fname: Path) -> dict[str, dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
The subroutines written here have names according to the openQCD programs and functions that write out the data.
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
fname: Path
|
|
||||||
Location of the parameter file.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
par_dict: dict
|
|
||||||
Dictionary holding the parameters specified in the given file.
|
|
||||||
"""
|
|
||||||
|
|
||||||
with open(fname, "rb") as fp:
|
|
||||||
lat_par_dict = flags.lat_parms_write_lat_parms(fp)
|
|
||||||
bc_par_dict = flags.lat_parms_write_bc_parms(fp)
|
|
||||||
fp.close()
|
|
||||||
par_dict = {}
|
|
||||||
par_dict["lat"] = lat_par_dict
|
|
||||||
par_dict["bc"] = bc_par_dict
|
|
||||||
return par_dict
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
from . import flags
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
def read_qcd2_par_file(fname: Path) -> dict[str, dict[str, Any]]:
|
|
||||||
"""
|
|
||||||
The subroutines written here have names according to the openQCD programs and functions that write out the data.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
fname: Path
|
|
||||||
Location of the parameter file.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
par_dict: dict
|
|
||||||
Dictionary holding the parameters specified in the given file.
|
|
||||||
"""
|
|
||||||
|
|
||||||
with open(fname, "rb") as fp:
|
|
||||||
lat_par_dict = flags.lat_parms_write_lat_parms(fp)
|
|
||||||
bc_par_dict = flags.lat_parms_write_bc_parms(fp)
|
|
||||||
fp.close()
|
|
||||||
par_dict = {}
|
|
||||||
par_dict["lat"] = lat_par_dict
|
|
||||||
par_dict["bc"] = bc_par_dict
|
|
||||||
return par_dict
|
|
||||||
|
|
@ -192,16 +192,12 @@ def import_toml(path: Path, file: str, copy_file: bool=True) -> None:
|
||||||
|
|
||||||
elif project['code'] == 'openQCD':
|
elif project['code'] == 'openQCD':
|
||||||
if md['measurement'] == 'ms1':
|
if md['measurement'] == 'ms1':
|
||||||
parameter_file = md['param_file']
|
param = openQCD.read_ms1_param(path, uuid, md['param_file'])
|
||||||
if parameter_file.endswith(".ms1.in"):
|
|
||||||
param = openQCD.load_ms1_infile(path, uuid, parameter_file)
|
|
||||||
elif parameter_file.endswith(".ms1.par"):
|
|
||||||
param = openQCD.load_ms1_parfile(path, uuid, parameter_file)
|
|
||||||
param['type'] = 'ms1'
|
param['type'] = 'ms1'
|
||||||
measurement = openQCD.read_rwms(path, uuid, md['path'], param, md["prefix"], version=md["version"], names=md['names'], files=md['files'])
|
measurement = openQCD.read_rwms(path, uuid, md['path'], param, md["prefix"], version=md["version"], names=md['names'], files=md['files'])
|
||||||
elif md['measurement'] == 't0':
|
elif md['measurement'] == 't0':
|
||||||
if 'param_file' in md:
|
if 'param_file' in md:
|
||||||
param = openQCD.load_ms3_infile(path, uuid, md['param_file'])
|
param = openQCD.read_ms3_param(path, uuid, md['param_file'])
|
||||||
else:
|
else:
|
||||||
param = {}
|
param = {}
|
||||||
for rwp in ["integrator", "eps", "ntot", "dnms"]:
|
for rwp in ["integrator", "eps", "ntot", "dnms"]:
|
||||||
|
|
@ -211,7 +207,7 @@ def import_toml(path: Path, file: str, copy_file: bool=True) -> None:
|
||||||
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
||||||
elif md['measurement'] == 't1':
|
elif md['measurement'] == 't1':
|
||||||
if 'param_file' in md:
|
if 'param_file' in md:
|
||||||
param = openQCD.load_ms3_infile(path, uuid, md['param_file'])
|
param = openQCD.read_ms3_param(path, uuid, md['param_file'])
|
||||||
param['type'] = 't1'
|
param['type'] = 't1'
|
||||||
measurement = openQCD.extract_t1(path, uuid, md['path'], param, str(md["prefix"]), int(md["dtr_read"]), int(md["xmin"]), int(md["spatial_extent"]),
|
measurement = openQCD.extract_t1(path, uuid, md['path'], param, str(md["prefix"]), int(md["dtr_read"]), int(md["xmin"]), int(md["spatial_extent"]),
|
||||||
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
fit_range=int(md.get('fit_range', 5)), postfix=str(md.get('postfix', '')), names=md.get('names', []), files=md.get('files', []))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue