Skip to content

Commit

Permalink
fix case of missing reference site amplifications in source command
Browse files Browse the repository at this point in the history
  • Loading branch information
trichter committed Jan 17, 2023
1 parent ed58f48 commit fd3ccf0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion qopen/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,12 @@ def _tw_utc2s(tw_utc, otime):
'for frequency band')
log.warning(msg, pair)
continue
if fix_sites and np.isnan(
fix_sites_params[freq_band].get(pair[1], np.nan)):
msg = ('%s: Reference site amplification not available '
'-> skip pair for frequency band')
log.warning(msg, pair)
continue
filter_ = copy(filter)
if freqmax > 0.495 * sr:
fu = {'freq': freqmin, 'type': 'highpass'}
Expand Down Expand Up @@ -796,14 +802,15 @@ def _get_velocity(st):
for i, B in enumerate(Ecoda + [[_] for _ in Ebulk]):
A = np.zeros((Ne, len(B)))
evid, st = event_station_pairs[i % len(event_station_pairs)]
site_resp = fix_sites_params[freq_band].get(st, 1)
site_resp = fix_sites_params[freq_band][st]
R_fix_sites.append(site_resp)
B_fix_sites.append(np.ones(len(B)) * np.log(site_resp))
idx = eventids.index(evid)
A[idx, :] = 1
As.append(A)
B_fix_sites = np.hstack(B_fix_sites)
R_fix_sites = R_fix_sites[:Ns]
assert not np.any(np.isnan(B_fix_sites))
del st, evid
else:
for i, B in enumerate(Ecoda + [[_] for _ in Ebulk]):
Expand Down
4 changes: 4 additions & 0 deletions qopen/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ def plot_fits(energies, g0, b, W, R, v0, info, G_func,
evid, station = get_pair(energy)
ax = plt.subplot(gs[i // n, i % n], sharex=share, sharey=share)
plot = ax.semilogy
if np.isnan(R[station]):
# can happen with fixed site amplifications
# and reference site not avaiable
continue

def get_Emod(G, t):
return R[station] * W[evid] * G * np.exp(-b * t)
Expand Down

0 comments on commit fd3ccf0

Please sign in to comment.