From 890d27a4f08304c9e9a5078bd63b89d9fe53cd50 Mon Sep 17 00:00:00 2001 From: xumi1993 Date: Fri, 12 Jul 2024 16:36:17 -0400 Subject: [PATCH] debug update_num_rec --- pytomoatt/src_rec.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pytomoatt/src_rec.py b/pytomoatt/src_rec.py index ebebce0..9f65780 100644 --- a/pytomoatt/src_rec.py +++ b/pytomoatt/src_rec.py @@ -66,6 +66,18 @@ def src_points(self): def src_points(self, value): if value is None or isinstance(value, pd.DataFrame): self._src_points = value + if not self._src_points.empty: + self._src_points = self._src_points.astype( + { + "evla": float, + "evlo": float, + "evdp": float, + "mag": float, + "num_rec": int, + "event_id": str, + "weight": float, + } + ) self._src_points.index.name = "src_index" else: raise TypeError("src_points should be in DataFrame") @@ -643,9 +655,11 @@ def update_num_rec(self): """ self.src_points["num_rec"] = self.rec_points.groupby("src_index").size() if not self.rec_points_cr.empty: - self.src_points["num_rec"] += self.rec_points_cr.groupby("src_index").size() + num = self.rec_points_cr.groupby("src_index").size() + self.src_points.loc[num.index, "num_rec"] += num if not self.rec_points_cs.empty: - self.src_points["num_rec"] += self.rec_points_cs.groupby("src_index").size() + num = self.rec_points_cs.groupby("src_index").size() + self.src_points.loc[num.index, "num_rec"] += num def update(self): """