improve io checks
This commit is contained in:
+20
-20
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user