From b029b1985d4c22dd7a80d38b20c2e4238f4ade2a Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Thu, 28 Jan 2021 20:45:42 +0100 Subject: [PATCH] [postprocessor] [refactoring] Add radial_centers rule (issue #8) --- postprocessor.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/postprocessor.py b/postprocessor.py index 6314f7b..74a080f 100644 --- a/postprocessor.py +++ b/postprocessor.py @@ -926,6 +926,11 @@ class PostProcessor(HDF5Container): rad_bins = np.concatenate(([0.0], rad_bins, [rad_of_box])) return rad_bins + def _radial_centers(self, ax_los="z"): + radial_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read() + bin_centers = 0.5 * (radial_bins[1:] + radial_bins[:-1]) + return bin_centers + def _rr(self, ax_los="z"): """ Computes the radius from the center @@ -1483,7 +1488,19 @@ class PostProcessor(HDF5Container): }, ), # Helpers - "radial_bins": Rule(self, self._radial_bins, "Radial bins", "/radial"), + "radial_bins": Rule( + self, + self._radial_bins, + "Radial bins", + "/radial", + ), + "radial_centers": Rule( + self, + self._radial_centers, + "Centers of radial bins", + "/radial", + dependencies=["radial_bins"], + ), "rr": Rule(self, self._rr, "Coordinate map", "/maps"), "bins_on_map": Rule( self, @@ -1634,7 +1651,7 @@ class PostProcessor(HDF5Container): partial(self._rad_avg, name), "Azimuthal average of {}".format(name), "/radial", - dependencies=["radial_bins", "bins_on_map", name], + dependencies=["radial_centers", "bins_on_map", name], ) self.rules["avg_map_" + name] = Rule( @@ -1642,7 +1659,7 @@ class PostProcessor(HDF5Container): partial(self._rad_avg_map, name), "Interpolated map of azimuthal average of {}".format(name), "/maps", - dependencies=["radial_bins", "bins_on_map", "rr", "rad_avg_" + name], + dependencies=["radial_centers", "bins_on_map", "rad_avg_" + name], ) self.rules["fluct_" + name] = Rule( self,