improve io checks

This commit is contained in:
Noe Brucy
2023-04-05 16:50:43 +02:00
parent 301d08dce7
commit bd520d7189
5 changed files with 105 additions and 83 deletions
+20 -20
View File
@@ -352,26 +352,6 @@ class RunSelector:
def try_load_info(num):
return True
# -- Time getter according to unit_time
if unit_time is None:
def get_time(num):
return self.info[run][num]["time"]
elif isinstance(unit_time, str):
factor = self.get_nml_value(unit_time, run)
def get_time(num):
time_code = self.info[run][num]["time"]
return time_code / factor
else:
def get_time(num):
time_code = self.info[run][num]["time"]
return time_code * self.info[run][num]["unit_time"].express(unit_time)
# -- A function to search a given time using dichotomy
def search(nums, time, position="closest"):
@@ -460,6 +440,26 @@ class RunSelector:
path = f"{self.path_in}/{run}/output_{nums[0]:05}/namelist.txt"
self.namelist[run] = self.load_namelist(run, path=path)
# -- Time getter according to unit_time
if unit_time is None:
def get_time(num):
return self.info[run][num]["time"]
elif isinstance(unit_time, str):
factor = self.get_nml_value(unit_time, run)
def get_time(num):
time_code = self.info[run][num]["time"]
return time_code / factor
else:
def get_time(num):
time_code = self.info[run][num]["time"]
return time_code * self.info[run][num]["unit_time"].express(unit_time)
# -- Select according to time --
if time_min is not None and len(nums) > 0:
imin = search(nums, time_min, "right")