""" 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