[misc] May last round of bug corrections
This commit is contained in:
+80
-63
@@ -56,39 +56,38 @@ class RunSelector:
|
||||
Select runs and outputs with several filter options.
|
||||
By default, all runs and outputs within path_in are considered
|
||||
|
||||
Parameters
|
||||
---------
|
||||
Args:
|
||||
|
||||
1. Define the set of runs and outputs considered
|
||||
1. Define the set of runs and outputs considered
|
||||
|
||||
path_in : str, path to the folder of the runs
|
||||
path_in : str, path to the folder of the runs
|
||||
|
||||
2. Filter runs and outputs
|
||||
2. Filter runs and outputs
|
||||
|
||||
in_runs : str or list of str. The name runs to consider. Default: all.
|
||||
in_nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
in_runs : str or list of str. The name runs to consider. Default: all.
|
||||
in_nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
|
||||
nml_filename : str name of the namelist (should be the same for all outputs)
|
||||
nml_filename : str name of the namelist (should be the same for all outputs)
|
||||
|
||||
filter_name : str, filter runs by name. Default "*"
|
||||
filter_nml : tuple or list of tupple.
|
||||
Filter runs by namelist.
|
||||
tuples are in the following form:
|
||||
(nml_key, operator, nml_value)
|
||||
with nml_key a key from the namelist (eg. "cloud_params/dens0")
|
||||
operator within ("=", "!=", "<", ">", "in")
|
||||
and nml_value a string, float or int
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
filter_name : str, filter runs by name. Default "*"
|
||||
filter_nml : tuple or list of tupple.
|
||||
Filter runs by namelist.
|
||||
tuples are in the following form:
|
||||
(nml_key, operator, nml_value)
|
||||
with nml_key a key from the namelist (eg. "cloud_params/dens0")
|
||||
operator within ("=", "!=", "<", ">", "in")
|
||||
and nml_value a string, float or int
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
|
||||
3. Sort the runs
|
||||
3. Sort the runs
|
||||
|
||||
sort_run_by : str, a key from the namelist used to sort the runs (by ascending order)
|
||||
sort_run_by : str, a key from the namelist used to sort the runs (by ascending order)
|
||||
|
||||
"""
|
||||
|
||||
@@ -146,37 +145,35 @@ class RunSelector:
|
||||
"""
|
||||
Sub-select runs and outputs from already selected runs and outputs
|
||||
|
||||
Parameters
|
||||
---------
|
||||
runs : str or list of str. The name runs to consider. Default: all.
|
||||
nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
Args:
|
||||
|
||||
filter_name : str.
|
||||
glob pattern used to filter run names.
|
||||
default is "*" (all runs)
|
||||
runs : str or list of str. The name runs to consider. Default: all.
|
||||
nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
|
||||
filter_nml : tuple or list of tupple.
|
||||
Filter runs by namelist.
|
||||
tuples are in the following form:
|
||||
(nml_key, operator, nml_value)
|
||||
with nml_key a key from the namelist (eg. "cloud_params/dens0")
|
||||
operator within ("=", "!=", "<", ">", "in")
|
||||
and nml_value a string, float or int
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
filter_name : str.
|
||||
glob pattern used to filter run names.
|
||||
default is "*" (all runs)
|
||||
|
||||
filter_nml : tuple or list of tupple.
|
||||
Filter runs by namelist.
|
||||
tuples are in the following form:
|
||||
(nml_key, operator, nml_value)
|
||||
with nml_key a key from the namelist (eg. "cloud_params/dens0")
|
||||
operator within ("=", "!=", "<", ">", "in")
|
||||
and nml_value a string, float or int
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
|
||||
|
||||
sort_run_by : str, a key from the namelist used to sort the runs (by ascending order)
|
||||
sort_run_by : str, a key from the namelist used to sort the runs (by ascending order)
|
||||
|
||||
Returns
|
||||
-------
|
||||
|
||||
(selected_runs, selected_nums)
|
||||
Returns:
|
||||
(selected_runs, selected_nums)
|
||||
"""
|
||||
|
||||
if runs is None:
|
||||
@@ -301,20 +298,19 @@ class RunSelector:
|
||||
"""
|
||||
Select snapshots from the disk
|
||||
|
||||
Parameters
|
||||
---------
|
||||
Args:
|
||||
|
||||
in_nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
in_nums : int or list of int or str.
|
||||
The output numbers to consider.
|
||||
"last" select only the last output.
|
||||
"all" preselect all outputs (default)
|
||||
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
time_min : float, select output where time >= time_min (in code units)
|
||||
time_max : float, select output where time <= time_min (in code units)
|
||||
time : float or list of float. For each value, select the output closer to it.
|
||||
unit_time : astrophysix.Unit, unit for the time above. None is code unit.
|
||||
|
||||
do_tests : test if the snapshots are actually on disk. Not needed when subselecting snapshots.
|
||||
do_tests : test if the snapshots are actually on disk. Not needed when subselecting snapshots.
|
||||
"""
|
||||
|
||||
# -- Initialize info loader --
|
||||
@@ -382,7 +378,7 @@ class RunSelector:
|
||||
if position == "left":
|
||||
return ileft
|
||||
elif position == "right":
|
||||
return nums[iright]
|
||||
return iright
|
||||
else:
|
||||
dleft = np.abs(get_time(nums[ileft]) - time)
|
||||
dright = np.abs(get_time(nums[iright]) - time)
|
||||
@@ -457,3 +453,24 @@ class RunSelector:
|
||||
nums = list(filter(try_load_info, nums))
|
||||
|
||||
return nums
|
||||
|
||||
def write_paths(self, prefix=None, filename="~/list_file"):
|
||||
"""
|
||||
Write the paths of the selected runs on a file
|
||||
|
||||
Args:
|
||||
prefix (str, optional): Prefix for the pathscd si. Defaults to path_in.
|
||||
filename (str, optional): F. Defaults to "~/list_file".
|
||||
"""
|
||||
if prefix is None:
|
||||
prefix = self.path_in
|
||||
paths = []
|
||||
for run in self.nums:
|
||||
for num in nums[run]:
|
||||
paths.append(f"{prefix}/{run}/output_{num:05}\n")
|
||||
f = open(os.path.expanduser(filename), "w")
|
||||
f.writelines(paths)
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user