add a pipeline for arepo

This commit is contained in:
Noe Brucy
2023-05-10 15:37:38 +02:00
parent 7429fb8181
commit aaf5c2cb2d
4 changed files with 107 additions and 12 deletions

View File

@@ -113,24 +113,35 @@ def aggregate(
assert weight_field in extensive_fields
for field in weighted_fields:
# Multiply weighted field by the weight v*m
grouped_data[field] *= grouped_data[weight_field]
# Compute the sum of all fields
binned_data = grouped_data[extensive_fields + weighted_fields].groups.aggregate(
np.add
)
for field in weighted_fields:
binned_data[field] /= binned_data[weight_field] # weighted mean
# For weighted field, divided by the total mass
# We obtain the weighted mean vmean = 𝚺 (m*v) / 𝚺 m
binned_data[field] /= binned_data[weight_field]
# Veocity dispersion
# We allso compute the weighted dispersion around the weighted mean
# Restart from the unweighted data v
grouped_data[field] /= grouped_data[weight_field]
for i in range(len(grouped_data.groups)):
# retrieve the indices of each group
slice = grouped_data.groups.indices[i], grouped_data.groups.indices[i + 1]
# Compute the fluctuations wrt the weighted mean (v - vmean)
grouped_data[slice[0] : slice[1]][field] -= binned_data[i][field]
# Compute m * (v - vmean)^2
grouped_data[field] = grouped_data[weight_field] * grouped_data[field] ** 2
# Compute 𝚺 m * (v - vmean)^2
binned_data[f"sigma_{field}"] = grouped_data[field,].groups.aggregate(
np.add
)[field]
# Compute sigma = 𝚺 (m * (v - vmean)^2) / 𝚺 m
binned_data[f"sigma_{field}"] = np.sqrt(
binned_data[f"sigma_{field}"] / binned_data[weight_field]
)
@@ -462,7 +473,7 @@ class Galsec:
self,
delta_r: Quantity[u.kpc] = u.kpc,
rmin: Quantity[u.kpc] = 1 * u.kpc,
rmax: Quantity[u.kpc] = 12 * u.kpc,
rmax: Quantity[u.kpc] = 30 * u.kpc,
zmin: Quantity[u.kpc] = -0.5 * u.kpc,
zmax: Quantity[u.kpc] = 0.5 * u.kpc,
):
@@ -475,7 +486,7 @@ class Galsec:
rmin : Quantity[u.kpc], optional
filter out bin below that radius, by default 1*u.kpc
rmax : Quantity[u.kpc], optional
filter out bin beyond that radius, by default 12*u.kpc
filter out bin beyond that radius, by default 30*u.kpc
"""
self.ring_binning(delta_r)