Read boxsize

This commit is contained in:
Noe Brucy
2023-05-10 08:46:13 +02:00
parent 304a8b9e84
commit 7429fb8181
3 changed files with 14 additions and 8 deletions

View File

@@ -229,6 +229,7 @@ class Galsec:
A dataset of cells in the following format:
header:
time float [Myr] time since the start of the simulation
box_size float [kpc] size of the box
fluids str list list of fluids included
gas:
position float array (Ngas, 3) [kpc], centered
@@ -259,6 +260,7 @@ class Galsec:
self.data[fluid] = QTable(data[fluid], units=self.units[fluid], copy=copy)
self.time = data["header"]["time"] * u.Myr
self.box_size = data["header"]["box_size"] * u.kpc
self.compute_derived_values()
@@ -333,13 +335,13 @@ class Galsec:
delta_z : Quantity[u.kpc]
spacing between two y bins
"""
boxsize = self.box_size
for fluid in self.fluids:
for i, (delta, name) in enumerate(zip([delta_x, delta_y, delta_z], ["x", "y", "z"])):
pos = self.data[fluid]["position"][:, i]
minval = np.floor(np.min(pos) / delta)
bin = np.floor((pos - minval) / delta)
pos = self.data[fluid]["position"][:, i] + 0.5 * boxsize # stay positive
bin = np.floor(pos / delta)
# Store the middle value
self.data[fluid][f"{name}_bin"] = (bin + 0.5) * delta + minval
self.data[fluid][f"{name}_bin"] = (bin + 0.5) * delta - 0.5 * boxsize
def sector_analysis(
self,