From 125f62a5cc4e1692466da59910f6c63321fe583d Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Mon, 8 May 2023 17:54:46 +0200 Subject: [PATCH] fix --- galsec.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/galsec.py b/galsec.py index a640c34..7a5fa93 100644 --- a/galsec.py +++ b/galsec.py @@ -330,14 +330,16 @@ class Galsec: spacing between two x bins delta_y : Quantity[u.kpc] spacing between two y bins + delta_z : Quantity[u.kpc] + spacing between two y bins """ for fluid in self.fluids: - x_bin = np.floor(self.data[fluid]["position"][:, 0] / delta_x) - y_bin = np.floor(self.data[fluid]["position"][:, 1] / delta_y) - z_bin = np.floor(self.data[fluid]["position"][:, 2] / delta_z) - self.data[fluid]["x_bin"] = (x_bin + 0.5) * delta_x # Store the middle value - self.data[fluid]["y_bin"] = (y_bin + 0.5) * delta_y # Store the middle value - self.data[fluid]["z_bin"] = (z_bin + 0.5) * delta_z # Store the middle value + for i, (delta, name) in enumerate(zip([delta_x, delta_y, delta_z], ["x", "y", "z"])): + pos = self.data[fluid]["position"][:, i] + minval = np.min(pos) + bin = np.floor((pos + minval) / delta) + # Store the middle value + self.data[fluid][f"{name}_bin"] = (bin + 0.5) * delta + minval def sector_analysis( self,