[refactoring] and solve path_out bug
This commit is contained in:
+4
-4
@@ -52,7 +52,7 @@ class BaseProcessor:
|
|||||||
rules = {}
|
rules = {}
|
||||||
solve_self_dep = True
|
solve_self_dep = True
|
||||||
|
|
||||||
def __init__(self, path, path_out=None, params=None, tag=None):
|
def __init__(self, path, path_out=".", params=None, tag=None):
|
||||||
if params is None:
|
if params is None:
|
||||||
self.params = default_params()
|
self.params = default_params()
|
||||||
elif type(params) == str:
|
elif type(params) == str:
|
||||||
@@ -60,15 +60,15 @@ class BaseProcessor:
|
|||||||
else:
|
else:
|
||||||
self.params = copy.deepcopy(params)
|
self.params = copy.deepcopy(params)
|
||||||
|
|
||||||
if tag is not None:
|
|
||||||
self.params.out.tag = tag
|
|
||||||
|
|
||||||
# Determining output directory
|
# Determining output directory
|
||||||
if path_out is None:
|
if path_out is None:
|
||||||
self.path_out = path
|
self.path_out = path
|
||||||
else:
|
else:
|
||||||
self.path_out = path_out
|
self.path_out = path_out
|
||||||
|
|
||||||
|
if tag is not None:
|
||||||
|
self.params.out.tag = tag
|
||||||
|
|
||||||
def _log(self, string, status=""):
|
def _log(self, string, status=""):
|
||||||
if self.params.process.verbose:
|
if self.params.process.verbose:
|
||||||
if len(status) > 0:
|
if len(status) > 0:
|
||||||
|
|||||||
+10
-10
@@ -119,9 +119,9 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path,
|
path,
|
||||||
in_runs=None,
|
runs=None,
|
||||||
in_nums=None,
|
nums=None,
|
||||||
path_out=None,
|
path_out=".",
|
||||||
params=None,
|
params=None,
|
||||||
selector=None,
|
selector=None,
|
||||||
tag=None,
|
tag=None,
|
||||||
@@ -136,13 +136,13 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
path : path to the main folder of the simulations (ex '~/simus/myproject')
|
path : path to the main folder of the simulations (ex '~/simus/myproject')
|
||||||
in_runs : list of the runs to consider (ex ['run1', 'run2'])
|
runs : list of the runs to consider (ex ['run1', 'run2'])
|
||||||
in_nums : list or dict of the outputs numbers to consider (ex [3, 5]
|
nums : list or dict of the outputs numbers to consider (ex [3, 5]
|
||||||
or {'run1' : [3, 5], 'run2' : [4, 6])
|
or {'run1' : [3, 5], 'run2' : [4, 6])
|
||||||
path_out : Path where the plot will be saved. By default set to `path`
|
path_out : Path where the plot will be saved. By default set to `path`
|
||||||
params : Parameters for postprocessing. See params module.
|
params : Parameters for postprocessing. See params module.
|
||||||
selector : Existing instance of RunSelector, that selects runs and outputs. If set, in_runs and
|
selector : Existing instance of RunSelector, that selects runs and outputs. If set, runs and
|
||||||
in_nums will be ignored
|
nums will be ignored
|
||||||
tag : string to add in the output and data files.
|
tag : string to add in the output and data files.
|
||||||
kwargs : Keyword arguments for RunSelector.
|
kwargs : Keyword arguments for RunSelector.
|
||||||
"""
|
"""
|
||||||
@@ -152,7 +152,7 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
# Select runs
|
# Select runs
|
||||||
if selector is None:
|
if selector is None:
|
||||||
self.selector = RunSelector(
|
self.selector = RunSelector(
|
||||||
path, in_runs, in_nums, self.params.input.nml_filename, **kwargs
|
path, runs, nums, self.params.input.nml_filename, **kwargs
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.selector = selector
|
self.selector = selector
|
||||||
@@ -167,7 +167,7 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
path,
|
path,
|
||||||
self.runs,
|
self.runs,
|
||||||
self.nums,
|
self.nums,
|
||||||
path_out,
|
self.path_out,
|
||||||
self.params,
|
self.params,
|
||||||
unit_time=unit_time,
|
unit_time=unit_time,
|
||||||
selector=self.selector,
|
selector=self.selector,
|
||||||
@@ -305,7 +305,7 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
if rule.kind == "snapshot" or rule.kind == "cells":
|
if rule.kind == "snapshot" or rule.kind == "cells":
|
||||||
run_num = [(run, num) for run in runs for num in nums[run]]
|
run_num = [(run, num) for run in runs for num in nums[run]]
|
||||||
if movie:
|
if movie:
|
||||||
filenames = {run : [] for run in runs}
|
filenames = {run: [] for run in runs}
|
||||||
elif rule.kind == "comp":
|
elif rule.kind == "comp":
|
||||||
run_num = [(None, None)]
|
run_num = [(None, None)]
|
||||||
if movie:
|
if movie:
|
||||||
|
|||||||
@@ -283,9 +283,9 @@ class SnapshotProcessor(HDF5Container):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path=None,
|
path=".",
|
||||||
num=None,
|
num=None,
|
||||||
path_out=None,
|
path_out=".",
|
||||||
params=None,
|
params=None,
|
||||||
tag=None,
|
tag=None,
|
||||||
selector=None,
|
selector=None,
|
||||||
|
|||||||
+5
-5
@@ -22,8 +22,8 @@ class StudyProcessor(Aggregator, HDF5Container):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path,
|
path,
|
||||||
in_runs,
|
runs,
|
||||||
in_nums,
|
nums,
|
||||||
path_out=None,
|
path_out=None,
|
||||||
params=default_params(),
|
params=default_params(),
|
||||||
selector=None,
|
selector=None,
|
||||||
@@ -43,12 +43,12 @@ class StudyProcessor(Aggregator, HDF5Container):
|
|||||||
else:
|
else:
|
||||||
tag_name = ""
|
tag_name = ""
|
||||||
|
|
||||||
self.filename = path_out + "/comp" + tag_name + ".h5"
|
self.filename = self.path_out + "/comp" + tag_name + ".h5"
|
||||||
|
|
||||||
# Select runs
|
# Select runs
|
||||||
if selector is None:
|
if selector is None:
|
||||||
selector = RunSelector(
|
selector = RunSelector(
|
||||||
path, in_runs, in_nums, self.params.input.nml_filename, **kwargs
|
path, runs, nums, self.params.input.nml_filename, **kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
# Save infos
|
# Save infos
|
||||||
@@ -62,7 +62,7 @@ class StudyProcessor(Aggregator, HDF5Container):
|
|||||||
|
|
||||||
for run in self.runs:
|
for run in self.runs:
|
||||||
path_run = path + "/" + run
|
path_run = path + "/" + run
|
||||||
path_out_run = path_out + "/" + run
|
path_out_run = self.path_out + "/" + run
|
||||||
self.snaps[run] = {}
|
self.snaps[run] = {}
|
||||||
|
|
||||||
for num in self.nums[run]:
|
for num in self.nums[run]:
|
||||||
|
|||||||
Reference in New Issue
Block a user