From 9fe745b0b4b54eecd2e73ca13ff091607dd9cc54 Mon Sep 17 00:00:00 2001 From: rstiskalek Date: Fri, 25 Nov 2022 10:54:09 +0000 Subject: [PATCH] add center of mass --- csiborgtools/fits/halo.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/csiborgtools/fits/halo.py b/csiborgtools/fits/halo.py index 596e8ef..c79a60a 100644 --- a/csiborgtools/fits/halo.py +++ b/csiborgtools/fits/halo.py @@ -425,8 +425,7 @@ class Clump: Returns ------- - m : 1-dimensional array - Array of shape `(n_particles, )`. + m : 1-dimensional array of shape `(n_particles, )` """ return self._m @@ -437,6 +436,17 @@ class Clump: raise TypeError("`r` and `m` must be equal size 1-dim arrays.") self._m = m + @property + def center_mass(self): + """ + Clump center of mass. + + Returns + ------- + cm : 1-dimensional array + """ + return numpy.average(self.pos, axis=0, weights=self.m) + @property def index(self): """