This commit is contained in:
Noe Brucy
2020-02-29 10:16:27 +01:00
parent 8d7c5296cc
commit 1c2750a7bd
4 changed files with 1669 additions and 32 deletions
+51 -1
View File
@@ -1,5 +1,5 @@
# coding: utf-8
import pandas as pd
from baseprocessor import *
mass_func = lambda dset: dset["rho"] * dset["dx"] ** 3 # Mass function
@@ -141,6 +141,7 @@ class PostProcessor(HDF5Container):
for key in cells_pymses.fields:
self.cells[key] = cells_pymses[key]
self.cells["dx"] = cells_pymses.get_sizes()
self.cells["pos"] = cells_pymses.points
if self.pp_params.process.save_cells:
cells_hdf5 = tables.open_file(self.cells_filename, mode="w")
@@ -195,6 +196,7 @@ class PostProcessor(HDF5Container):
):
"""
Map of the average of a quantity (given by getter) along an axis (ax_los)
Return 2D array
"""
if mass_weighted:
@@ -216,6 +218,38 @@ class PostProcessor(HDF5Container):
datamap = rt.process(self._cam[ax_los], surf_qty=surf_qty)
return datamap.map.T
def _get_axis(self, axis):
if isinstance(axis, str):
axis = self._ax_nb[axis]
self.load_cells()
return np.sort(np.unique(self.cells["pos"][:, axis]))
def _plane_avg_uniform(
self, getter, axis, unit=cst.none, mass_weighted=True, surf_qty=False
):
"""
Profile of the average of a quantity (given by getter) perpendicular to an axis
WARNING : This version only works on an uniform grid, need of a box version for AMR
"""
self.load_cells()
if isinstance(axis, str):
axis = self._ax_nb[axis]
axis_data = self.cells["pos"][:, axis]
value = getter(self.cells)
df = pd.DataFrame({"axis": axis_data})
if mass_weighted:
mass = mass_func(self.cells)
tot_mass = np.sum(mass)
df["value"] = value * mass / tot_mass
else:
df["value"] = value
df.sort_values("axis", inplace=True)
return df.groupby("axis").mean().values[:, 0]
def _vol_avg(self, getter, mass_weighted=True):
self.load_cells()
value = getter(self.cells)
@@ -685,6 +719,22 @@ class PostProcessor(HDF5Container):
"/hist",
unit=self.info["unit_pressure"],
),
# Profiles
"axis": Rule(
self,
partial(self._get_axis),
"Axis",
"/profile",
unit=self.info["unit_length"],
),
"rho_prof": Rule(
self,
partial(self._plane_avg_uniform, partial(simple_getter, "rho")),
"Rho profile",
"/profile",
unit=self.info["unit_density"],
dependencies=["axis"],
),
# globals
"time_num": Rule(
self,