From eab9aafd79c80ca5bcf1a70fadeae7be8fa46960 Mon Sep 17 00:00:00 2001 From: xumi1993 Date: Wed, 28 Feb 2024 13:19:39 +0800 Subject: [PATCH] debug concat --- seispy/recalrf.py | 2 +- seispy/rf.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/seispy/recalrf.py b/seispy/recalrf.py index 5a6f226c..6c4cf25d 100644 --- a/seispy/recalrf.py +++ b/seispy/recalrf.py @@ -50,7 +50,7 @@ def match_eq(eq_lst, pathname, logger, ref_comp='Z', suffix='SAC', offset=0, this_eq.get_time_offset(results.iloc[0]['date']) this_df = pd.DataFrame([[this_eq, datestr]], columns=new_col, index=results.index.values) eq_match_lst.append(this_df) - eq_match = pd.concat(eq_match_lst) + eq_match = pd.concat(eq_match_lst) ind = eq_match.index.drop_duplicates(keep=False) eq_match = eq_match.loc[ind] return pd.concat([eq_lst, eq_match], axis=1, join='inner') diff --git a/seispy/rf.py b/seispy/rf.py index 0c4e15b4..c0b4997a 100644 --- a/seispy/rf.py +++ b/seispy/rf.py @@ -150,7 +150,10 @@ def fetch_waveform(eq_lst, para, model, logger): this_eq.get_time_offset(row['date']) this_df = pd.DataFrame([[daz.delta, daz.baz, this_eq, datestr]], columns=new_col, index=[i]) eqall.append(this_df) - eq_match = pd.concat(eqall) + if not eqall: + logger.RFlog.error('No waveforms fetched') + sys.exit(1) + eq_match = pd.concat(eqall) ind = eq_match.index.drop_duplicates(keep=False) eq_match = eq_match.loc[ind] return pd.concat([eq_lst, eq_match], axis=1, join='inner') @@ -220,7 +223,10 @@ def match_eq(eq_lst, pathname, stla, stlo, logger, ref_comp='Z', suffix='SAC', o daz = distaz(stla, stlo, results.iloc[0]['evla'], results.iloc[0]['evlo']) this_df = pd.DataFrame([[daz.delta, daz.baz, this_eq, datestr]], columns=new_col, index=results.index.values) eq_match_lst.append(this_df) - eq_match = pd.concat(eq_match_lst) + if not eq_match_lst: + logger.RFlog.error('No earthquakes matched') + sys.exit(1) + eq_match = pd.concat(eq_match_lst) ind = eq_match.index.drop_duplicates(keep=False) eq_match = eq_match.loc[ind] return pd.concat([eq_lst, eq_match], axis=1, join='inner')