Fix snapshot directory.

这个提交包含在:
craig-warren
2020-04-21 09:24:04 +01:00
父节点 5f8c7580ce
当前提交 768843f76f
共有 2 个文件被更改,包括 11 次插入8 次删除

查看文件

@@ -91,9 +91,6 @@ class ModelConfig:
self.appendmodelnumber = '' if sim_config.single_model else str(model_num + 1) # Indexed from 1
self.set_output_file_path()
# Specify a snapshot directory
self.set_snapshots_dir()
# Numerical dispersion analysis parameters
# highestfreqthres: threshold (dB) down from maximum power (0dB) of main frequency used
# to calculate highest frequency for numerical dispersion analysis
@@ -167,9 +164,15 @@ class ModelConfig:
self.output_file_path_ext = self.output_file_path.with_suffix('.h5')
def set_snapshots_dir(self):
"""Set directory to store any snapshots."""
"""Set directory to store any snapshots.
Returns:
snapshot_dir (Path): directory to store snapshot files in.
"""
parts = self.output_file_path.with_suffix('').parts
self.snapshot_dir = Path(*parts[:-1], parts[-1] + '_snaps')
snapshot_dir = Path(*parts[:-1], parts[-1] + '_snaps')
return snapshot_dir
class SimulationConfig:

查看文件

@@ -216,11 +216,11 @@ class ModelBuildRun:
# Write any snapshots to file
if self.G.snapshots:
# Create directory for snapshots
config.get_model_config().set_snapshots_file_path()
snapshotdir = config.get_model_config().snapshot_file_path
snapshotdir = config.get_model_config().set_snapshots_dir()
snapshotdir.mkdir(exist_ok=True)
logger.info('')
logger.info(f'Snapshot directory: {snapshotdir.resolve()}')
for i, snap in enumerate(self.G.snapshots):
fn = snapshotdir / Path(snap.filename)
snap.filename = fn.with_suffix('.vti')