This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadfiles.py
48 lines (43 loc) · 1.88 KB
/
readfiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from os import path
from pathlib import Path
from simulation import Simulation
from simulation_list import SimulationList
simulation_sets = {
"winter": sorted(Path("../../tmp/winter/").glob("*"))
# "original": sorted(glob("../data/*")),
# "cloud": sorted(glob("../../Bachelorarbeit_data/results/*"))
# "benchmark": sorted(glob("../../Bachelorarbeit_benchmark/results/*"))
}
simulations = SimulationList()
for set_type, directories in simulation_sets.items():
for dir in directories:
print(dir)
spheres_file = dir / "spheres_ini.log"
aggregates_file = sorted(dir.glob("frames/aggregates.*"))[-1]
if not path.exists(spheres_file) or not path.exists(aggregates_file):
print(f"skipping {dir}")
continue
sim = Simulation()
sim.load_params_from_setup_txt(dir / "cfg.txt")
sim.type = set_type
sim.load_params_from_spheres_ini_log(spheres_file)
sim.load_params_from_aggregates_txt(aggregates_file)
# sim.assert_all_loaded()
if sim.rel_velocity < 0 or sim.distance < 0:
# Sometimes in the old dataset the second object wasn't detected.
# To be save, we'll exclude them
print(vars(sim))
continue
if sim.largest_aggregate_water_fraction < 0:
# a handful of simulations had a typo in the aggregates simulations.
# to fix those rerun aggregates on all of them
print(vars(sim))
raise ValueError("invalid aggregate data. Please rerun postprocessing")
if sim.water_retention_both < 0 or sim.water_retention_both > 1:
print(vars(sim))
print(sim.water_retention_both)
raise ValueError("water retention is invalid")
simulations.append(sim)
# print(vars(sim))
print(len(simulations.simlist))
simulations.jsonlines_save(Path("winter.jsonl"))