black without mortimer

This commit is contained in:
Noe Brucy
2022-11-28 18:01:18 +01:00
parent 7548ef7e0a
commit fa396178c6
14 changed files with 371 additions and 304 deletions
+22 -11
View File
@@ -9,6 +9,7 @@ from utils.runselector import RunSelector
from plotter import Plotter, U
import os
def prep_mcons(study):
study.coarse_step_from_log()
@@ -22,36 +23,46 @@ def time_mcons(study, run, target=0.2):
def find_nums(study, prep_function, time_function, time_min=0):
"""
"""
Once other filter are applied, select one output based on the time given by time function
Args:
prep_function (study:studyProcessor -> None): prepare a study object
time_function (study:studyProcessor, run:str -> time:float): compute selected time from the object
time_function (study:studyProcessor, run:str -> time:float): compute selected time from the object
"""
nums = {}
prep_function(study)
for run in study.runs:
time_target = max(time_min, time_function(study, run))
rs = RunSelector(path_in=study.path, in_runs=run, time_min=time_min, time=time_target, unit_time=U.Myr)
rs = RunSelector(
path_in=study.path,
in_runs=run,
time_min=time_min,
time=time_target,
unit_time=U.Myr,
)
nums.update(rs.nums)
return nums
def write_paths(nums, path_from_home, filename="~/list_file"):
paths = []
for key in nums:
for num in self.nums[run]:
if os.path.exists("{prefix}/{run}/output_{num:05}/output_{num:05}\n"):
paths.append(f"{prefix}/{run}/output_{num:05}/output_{num:05}\n")
else:
paths.append(f"{prefix}/{run}/output_{num:05}\n")
for run in nums:
for num in nums[run]:
if os.path.exists(
"{path_from_home}/{run}/output_{num:05}/output_{num:05}\n"
):
paths.append(
f"{path_from_home}/{run}/output_{num:05}/output_{num:05}\n"
)
else:
paths.append(f"{path_from_home}/{run}/output_{num:05}\n")
f = open(os.path.expanduser(filename), "w")
f.writelines(paths)
f.close()
if __name__ == '__main__':
if __name__ == "__main__":
path_from_home = "simus/ismfeed/allmode"
names = "n6_st_2e5_seed3_T5Myr_nsink1e3_comp*"
@@ -63,4 +74,4 @@ if __name__ == '__main__':
tag="select",
).study
nums = find_nums(study, prep_mcons, time_mcons)
write_paths(nums, ".")
write_paths(nums, ".")