Skip to content

Commit

Permalink
print_families: determine duration units based on average duration
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Apr 5, 2024
1 parent e3c82ad commit a464095
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Copyright (c) 2021-2024 Claudio Satriano <[email protected]>
- Filter catalog files on reading using the criteria in the config file
- Improved time axes in `plot_timespans` and `plot_slip` for short time
intervals
- `print_families`: autoset duration units based on the average duration

## v0.4.1 - 2024-03-11

Expand Down
17 changes: 15 additions & 2 deletions requake/families/print_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def print_families(config):
logger.error(msg)
rq_exit(1)

# determine duration units
average_duration = np.mean([f.duration for f in families])
avg_duration_in_days = average_duration * 365
if 30 < avg_duration_in_days < 365:
duration_multiplier = 12
duration_units = 'm'
elif 1 < avg_duration_in_days < 30:
duration_multiplier = 365
duration_units = 'd'
elif avg_duration_in_days < 1:
duration_multiplier = 365 * 24
duration_units = 'h'

headers = [
'family',
'nevents',
Expand All @@ -41,7 +54,7 @@ def print_families(config):
'depth (km)',
'start time',
'end time',
'duration (y)',
f'duration ({duration_units})',
'slip rate (cm/y)'
]
table = []
Expand All @@ -58,7 +71,7 @@ def print_families(config):
family.depth,
family.starttime,
family.endtime,
family.duration
family.duration*duration_multiplier
]
slip = [mag_to_slip_in_cm(config, ev.mag) for ev in family]
cum_slip = np.cumsum(slip)
Expand Down

0 comments on commit a464095

Please sign in to comment.