diff --git a/baseprocessor.py b/baseprocessor.py index 25522c5..185ed41 100644 --- a/baseprocessor.py +++ b/baseprocessor.py @@ -52,7 +52,7 @@ class BaseProcessor: rules = {} 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: self.params = default_params() elif type(params) == str: @@ -60,15 +60,15 @@ class BaseProcessor: else: self.params = copy.deepcopy(params) - if tag is not None: - self.params.out.tag = tag - # Determining output directory if path_out is None: self.path_out = path else: self.path_out = path_out + if tag is not None: + self.params.out.tag = tag + def _log(self, string, status=""): if self.params.process.verbose: if len(status) > 0: diff --git a/plotter.py b/plotter.py index 3939f0c..4af07f3 100644 --- a/plotter.py +++ b/plotter.py @@ -119,9 +119,9 @@ class Plotter(Aggregator, BaseProcessor): def __init__( self, path, - in_runs=None, - in_nums=None, - path_out=None, + runs=None, + nums=None, + path_out=".", params=None, selector=None, tag=None, @@ -136,13 +136,13 @@ class Plotter(Aggregator, BaseProcessor): ---------- path : path to the main folder of the simulations (ex '~/simus/myproject') - in_runs : list of the runs to consider (ex ['run1', 'run2']) - in_nums : list or dict of the outputs numbers to consider (ex [3, 5] + runs : list of the runs to consider (ex ['run1', 'run2']) + nums : list or dict of the outputs numbers to consider (ex [3, 5] or {'run1' : [3, 5], 'run2' : [4, 6]) path_out : Path where the plot will be saved. By default set to `path` params : Parameters for postprocessing. See params module. - selector : Existing instance of RunSelector, that selects runs and outputs. If set, in_runs and - in_nums will be ignored + selector : Existing instance of RunSelector, that selects runs and outputs. If set, runs and + nums will be ignored tag : string to add in the output and data files. kwargs : Keyword arguments for RunSelector. """ @@ -152,7 +152,7 @@ class Plotter(Aggregator, BaseProcessor): # Select runs if selector is None: self.selector = RunSelector( - path, in_runs, in_nums, self.params.input.nml_filename, **kwargs + path, runs, nums, self.params.input.nml_filename, **kwargs ) else: self.selector = selector @@ -167,7 +167,7 @@ class Plotter(Aggregator, BaseProcessor): path, self.runs, self.nums, - path_out, + self.path_out, self.params, unit_time=unit_time, selector=self.selector, @@ -305,7 +305,7 @@ class Plotter(Aggregator, BaseProcessor): if rule.kind == "snapshot" or rule.kind == "cells": run_num = [(run, num) for run in runs for num in nums[run]] if movie: - filenames = {run : [] for run in runs} + filenames = {run: [] for run in runs} elif rule.kind == "comp": run_num = [(None, None)] if movie: diff --git a/snapshotprocessor.py b/snapshotprocessor.py index 1f38b7e..73601cf 100644 --- a/snapshotprocessor.py +++ b/snapshotprocessor.py @@ -283,9 +283,9 @@ class SnapshotProcessor(HDF5Container): def __init__( self, - path=None, + path=".", num=None, - path_out=None, + path_out=".", params=None, tag=None, selector=None, diff --git a/studyprocessor.py b/studyprocessor.py index ea558d7..7d83eba 100644 --- a/studyprocessor.py +++ b/studyprocessor.py @@ -22,8 +22,8 @@ class StudyProcessor(Aggregator, HDF5Container): def __init__( self, path, - in_runs, - in_nums, + runs, + nums, path_out=None, params=default_params(), selector=None, @@ -43,12 +43,12 @@ class StudyProcessor(Aggregator, HDF5Container): else: tag_name = "" - self.filename = path_out + "/comp" + tag_name + ".h5" + self.filename = self.path_out + "/comp" + tag_name + ".h5" # Select runs if selector is None: selector = RunSelector( - path, in_runs, in_nums, self.params.input.nml_filename, **kwargs + path, runs, nums, self.params.input.nml_filename, **kwargs ) # Save infos @@ -62,7 +62,7 @@ class StudyProcessor(Aggregator, HDF5Container): for run in self.runs: path_run = path + "/" + run - path_out_run = path_out + "/" + run + path_out_run = self.path_out + "/" + run self.snaps[run] = {} for num in self.nums[run]: