diff --git a/comparator.py b/comparator.py index 7907f6e..4e2e5a2 100644 --- a/comparator.py +++ b/comparator.py @@ -127,14 +127,14 @@ class Comparator(Aggregator, HDF5Container): return series def _comp(self, getter, use_num=True): - prop = np.zeros(len(self.runs)) + prop = [] for i, run in enumerate(self.runs): if use_num: num = self.nums[run][0] - prop[i] = getter(run, num) + prop.append(getter(run, num)) else: - prop[i] = getter(run) - return prop + prop.append(getter(run)) + return np.array(prop) def _time_avg(self, name, start=None, end=None, span=None, group="/series"): mean = np.zeros(len(self.runs)) diff --git a/plotter.py b/plotter.py index 3452190..f00acd9 100644 --- a/plotter.py +++ b/plotter.py @@ -805,6 +805,10 @@ class Plotter(Aggregator, BaseProcessor): def def_rules(self): self.rules = { + # Generic rules + "plot": PlotRule( + self, lambda arg, **kwargs: self._plot(*arg, **kwargs), kind="comp" + ), "coldens": PlotRule( self, partial(self._plot_map, "coldens", label=r"$\Sigma$", unit=cst.coldens), @@ -1037,9 +1041,6 @@ class Plotter(Aggregator, BaseProcessor): kind="series", dependencies={"time_max_fluct_coldens": "z"}, ), - "plot": PlotRule( - self, lambda arg, **kwargs: self._plot(*arg, **kwargs), kind="comp" - ), } ) diff --git a/postprocessor.py b/postprocessor.py index 2aa5fce..1efef2b 100644 --- a/postprocessor.py +++ b/postprocessor.py @@ -245,7 +245,11 @@ class PostProcessor(HDF5Container): else: df["value"] = value + if self.pp_params.process.unload_cells: + self.unload_cells() + df.sort_values("axis", inplace=True) + return df.groupby("axis").mean().values[:, 0] def _vol_avg(self, getter, mass_weighted=True): @@ -254,9 +258,13 @@ class PostProcessor(HDF5Container): if mass_weighted: mass = mass_func(self.cells) # Transpose (.T) is for vectorial values - return np.sum((mass * value.T).T, axis=0) / np.sum(mass) + data = np.sum((mass * value.T).T, axis=0) / np.sum(mass) else: - return np.sum(value, axis=0) + data = np.sum(value, axis=0) + + if self.pp_params.process.unload_cells: + self.unload_cells() + return data def _vol_pdf(self, getter, bins=100, logbins=False, weight_func=vol_func): self.load_cells() @@ -264,6 +272,8 @@ class PostProcessor(HDF5Container): if logbins: data = np.log10(data) weights = weight_func(self.cells) + if self.pp_params.process.unload_cells: + self.unload_cells() values, edges = np.histogram(data, bins, weights=weights) centers = 0.5 * (edges[1:] + edges[:-1]) diff --git a/pp_params.yml b/pp_params.yml index a714a8e..a7fce44 100644 --- a/pp_params.yml +++ b/pp_params.yml @@ -66,6 +66,7 @@ process: # General setting of the post-processor module verbose : True # Give more infos on what is going on num_process : 1 # Number of forks save_cells : True # Save cells structure on disk + unload_cells : True # Save memory usage rules: # Specific rules parameters turb_energy_threshold : -1 # Remove invalid data (<0 = no threshold)