split simulating and evaluating and stuff
This commit is contained in:
@ -54,23 +54,11 @@ def run_sims(
|
||||
subprocess.run(arguments)
|
||||
|
||||
|
||||
def find_config_file(motion: str, distribution: str, var_params: dict) -> pathlib.Path:
|
||||
# TODO handle situation if multiple files fit
|
||||
p_file = None
|
||||
if var_params:
|
||||
var_string = '|'.join(([f'{k}={v:1.6e}' for (k, v) in var_params.items()])).replace('.', '\.').replace('+', '\+')
|
||||
pattern = re.compile(var_string)
|
||||
for p_file in pathlib.Path('.').glob('*_parameter.txt'):
|
||||
if len(re.findall(pattern, str(p_file))) == len(var_params) and re.search(f'{motion}_{distribution}', str(p_file)):
|
||||
return p_file
|
||||
raise ValueError(f'No parameter file found for {motion}, {distribution}, {var_params}')
|
||||
else:
|
||||
for p_file in pathlib.Path('.').glob('*_parameter.txt'):
|
||||
if re.search(f'{motion}_{distribution}', str(p_file)):
|
||||
return p_file
|
||||
raise ValueError(f'No parameter file found for {motion}, {distribution}, {var_params}')
|
||||
|
||||
def find_config_file(config_path: str | pathlib.Path, varied_params: dict[str, float]) -> dict[str, float]:
|
||||
parameter = read_parameter_file(config_path)
|
||||
parameter.update(varied_params)
|
||||
|
||||
return parameter
|
||||
|
||||
|
||||
def read_parameter_file(path: str | pathlib.Path) -> dict[str, float]:
|
||||
@ -81,8 +69,9 @@ def read_parameter_file(path: str | pathlib.Path) -> dict[str, float]:
|
||||
parameter_dict = {}
|
||||
with path.open('r') as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
k, v = line.split('=')
|
||||
parameter_dict[k] = float(v)
|
||||
|
||||
k, v = line.split('=')
|
||||
return parameter_dict
|
||||
|
@ -74,7 +74,7 @@ def fit_ste(
|
||||
# make evolution times
|
||||
tevo = np.linspace(parameter['tevo_start'], parameter['tevo_stop'], num=int(parameter['tevo_steps']))
|
||||
|
||||
raw_data = np.loadtxt(f'{prefix}_{varied_string}.dat')
|
||||
raw_data = np.loadtxt(parameter_file.with_name(f'{prefix}_{varied_string}.dat'))
|
||||
|
||||
t_mix = raw_data[:, 0]
|
||||
decay = raw_data[:, 1:]
|
||||
|
Reference in New Issue
Block a user