Prepare refactoring

This commit is contained in:
Noe Brucy
2020-04-01 09:17:19 +02:00
parent b8f85b1386
commit 77676ec9a4
4 changed files with 21 additions and 9 deletions
+4 -4
View File
@@ -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))
+4 -3
View File
@@ -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"
),
}
)
+12 -2
View File
@@ -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])
+1
View File
@@ -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)