working relative path for multi-fiber simulations

This commit is contained in:
Benoît Sierro
2022-07-19 15:32:49 +02:00
parent 1961ff9bfd
commit 24e38b143f
2 changed files with 6 additions and 2 deletions

View File

@@ -158,6 +158,9 @@ class SimulationSeries:
raise FileNotFoundError(f"No simulation in {path}") raise FileNotFoundError(f"No simulation in {path}")
self.fibers = [SimulatedFiber(self.path)] self.fibers = [SimulatedFiber(self.path)]
while (p := self.fibers[-1].params.prev_data_dir) is not None: while (p := self.fibers[-1].params.prev_data_dir) is not None:
p = Path(p)
if not p.is_absolute():
p = Path(self.fibers[-1].params.output_path) / p
self.fibers.append(SimulatedFiber(p)) self.fibers.append(SimulatedFiber(p))
self.fibers = self.fibers[::-1] self.fibers = self.fibers[::-1]
@@ -353,6 +356,7 @@ class SimulatedFiber:
def __init__(self, path: os.PathLike): def __init__(self, path: os.PathLike):
self.path = Path(path) self.path = Path(path)
self.params = Parameters(**translate_parameters(load_toml(self.path / PARAM_FN))) self.params = Parameters(**translate_parameters(load_toml(self.path / PARAM_FN)))
self.params.output_path = str(self.path.resolve())
self.t = self.params.t self.t = self.params.t
self.w = self.params.w self.w = self.params.w
self.z = self.params.z_targets self.z = self.params.z_targets

View File

@@ -21,7 +21,7 @@ import pkg_resources as pkg
import tomli import tomli
import tomli_w import tomli_w
from .const import PARAM_FN, PARAM_SEPARATOR, SPEC1_FN, SPECN_FN1, Z_FN, ROOT_PARAMETERS from .const import PARAM_FN, PARAM_SEPARATOR, SPEC1_FN, Z_FN, ROOT_PARAMETERS
from .logger import get_logger from .logger import get_logger
from .errors import DuplicateParameterError from .errors import DuplicateParameterError
@@ -489,7 +489,7 @@ def update_params(new_path: Path, file: Path):
params = load_toml(file) params = load_toml(file)
if (p := params.get("prev_data_dir")) is not None: if (p := params.get("prev_data_dir")) is not None:
p = Path(p) p = Path(p)
params["prev_data_dir"] = str(p.parent / update_path_name(p.name)) params["prev_data_dir"] = str(Path("../..") / p.parent.name / update_path_name(p.name))
params["output_path"] = str(new_path) params["output_path"] = str(new_path)
save_toml(new_path / PARAM_FN, params) save_toml(new_path / PARAM_FN, params)
file.unlink() file.unlink()