Skip to content

Commit

Permalink
fix delta me in report
Browse files Browse the repository at this point in the history
  • Loading branch information
rizac committed Jul 14, 2023
1 parent 328f6ab commit 6d7f756
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mecompute/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def main(segment, config):
'station': segment.station.station,
'location': segment.channel.location,
'channel': segment.channel.channel,
'event_db_id': segment.event.id,
'event_db_id': segment.event_id,
'station_event_distance_deg': distance_deg,
'station_latitude': segment.station.latitude,
'station_longitude': segment.station.longitude,
Expand Down
12 changes: 9 additions & 3 deletions mecompute/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,19 @@ def _get_report_rows(hdf_path_or_df, db_session):
for (net, sta), sta_df in group_sta:
lat = np.round(sta_df['station_latitude'].iat[0], 3)
lon = np.round(sta_df['station_longitude'].iat[0], 3)
res = np.nan if invalid_me else \
sta_df['station_energy_magnitude'].iat[0] - me_st_mean
delta_me = None
station_me = sta_df['station_energy_magnitude'].iat[0]
if not invalid_me:
with pd.option_context('mode.use_inf_as_na', True):
if not pd.isna(station_me):
delta_me = station_me - me_st_mean
# res = np.nan if invalid_me else \
# sta_df['station_energy_magnitude'].iat[0] - me_st_mean
dist_deg = np.round(sta_df['station_event_distance_deg'].iat[0], 3)
stas.append([lat if np.isfinite(lat) else None,
lon if np.isfinite(lon) else None,
net + '.' + sta,
res if np.isfinite(res) else None,
delta_me,
dist_deg if np.isfinite(dist_deg) else None])

yield event, stas
Expand Down

0 comments on commit 6d7f756

Please sign in to comment.