From 85f0712755afeb2bcd9709a069f0d1003ffd202c Mon Sep 17 00:00:00 2001 From: Marta Han Date: Fri, 7 Jun 2024 16:11:18 +0200 Subject: [PATCH] adding sorting by time to Catalog.estimate_b() when b-positive method is applied --- seismostats/seismicity/catalog.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/seismostats/seismicity/catalog.py b/seismostats/seismicity/catalog.py index c3ef4d6..1c553f9 100644 --- a/seismostats/seismicity/catalog.py +++ b/seismostats/seismicity/catalog.py @@ -362,7 +362,16 @@ def estimate_b( if delta_m is None: delta_m = self.delta_m - b_estimate = estimate_b(self.magnitude, + if method == "positive": + # dataframe needs 'time' column to be sorted + if 'time' not in self.columns: + raise ValueError('"time" column needs to be set in order to use \ + b-positive method') + mags = self.sort_values("time").magnitude + else: + mags = self.magnitude + + b_estimate = estimate_b(mags, mc, delta_m, weights,