Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Andrew medlin/pv 86 revise ccp crosssections #195

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions seismic/receiver_fn/plot_ccp.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
from seismic.units_utils import KM_PER_DEG


def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title=None, colormap='seismic'):
def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title=None,
colormap='seismic', colorlegend=True):
"""Plot results of CCP stacking procedure.

:param matrx: [description]
Expand All @@ -52,13 +53,15 @@ def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title
:type title: str, optional
:param colormap: Color map to use for the CCP intensity shading.
:type colormap: str
:param colorlegend: Whether to add color legend to plot.
:type colorlegend: boolean
:return: Figure handle
:rtype: matplotlib.pyplot.Figure
"""
tickstep_x = 50
tickstep_y = 25

fig = plt.figure(figsize=(16, 9))
fig = plt.figure(figsize=(16, 4))
interpolation = 'hanning'
extent = (0, length, 0, max_depth)
assert not np.any(np.isnan(matrx))
Expand All @@ -68,16 +71,20 @@ def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title
else:
im = plt.imshow(matrx, cmap=colormap, aspect='auto', extent=extent, interpolation=interpolation, origin='lower')
# end if
cb = plt.colorbar(im)
cb.set_label('Stacked amplitude (arb. units)')

if colorlegend:
cb = plt.colorbar(im)
cb.set_label('Stacked amplitude (arb. units)')
# end if

if title is not None:
plt.title(title, fontsize=16, y=1.02)
# end if

plt.xlim(0, length)
plt.ylim(max_depth*1.0001, 0)

plt.xlabel('Distance (km)', fontsize=12)
plt.xlabel('Distance (km)', fontsize=12, labelpad=1.0)
plt.ylabel('Depth (km)', fontsize=12)

plt.xticks(np.arange(0.0, length*1.0001, tickstep_x), fontsize=12)
Expand Down Expand Up @@ -105,8 +112,8 @@ def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title
for stn, meta in stn_labels:
x = meta['sta_offset']
y = 1.0 + (i%2)*2.5
plt.text(x, y, "{} ({})".format(stn, meta['event_count']), horizontalalignment='center',
verticalalignment='top', fontsize=9, backgroundcolor='#ffffffa0')
plt.text(x, y, stn, horizontalalignment='center', verticalalignment='top', fontsize=9,
backgroundcolor='#ffffffa0')
i += 1
# end for
# end if
Expand Down Expand Up @@ -564,7 +571,8 @@ def ccp_generate(rf_stream, startpoint, endpoint, width, spacing, max_depth, cha


def run(rf_stream, start_latlon, end_latlon, width, spacing, max_depth, channels,
background_model='ak135', stacked_scale=None, title=None, colormap=None):
background_model='ak135', stacked_scale=None, title=None, colormap=None,
colorlegend=True):
"""Run CCP generation on a given dataset of RFs.

:param rf_stream: Set of RFs to use for CCP plot
Expand All @@ -589,6 +597,8 @@ def run(rf_stream, start_latlon, end_latlon, width, spacing, max_depth, channels
:type title: str
:param colormap: Color map to use for the CCP intensity shading. Suggest 'seismic', 'coolwarm' or 'jet'.
:type colormap: str
:param colorlegend: Whether to add color legend to plot.
:type colorlegend: boolean
:return: Figure handles: Main figure, map figure, dict of station parameters
:rtype: (matplotlib.pyplot.Figure, matplotlib.pyplot.Figure, dict)
"""
Expand All @@ -609,7 +619,7 @@ def run(rf_stream, start_latlon, end_latlon, width, spacing, max_depth, channels
vlims = None
# endif
fig = plot_ccp(matrix_norm, length, max_depth, spacing, vlims=vlims, metadata=stn_params,
title=title, colormap=colormap)
title=title, colormap=colormap, colorlegend=colorlegend)
# end if

return fig, fig_map, stn_params
Expand Down
6 changes: 3 additions & 3 deletions seismic/receiver_fn/plot_ccp_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def run_batch(transect_file, rf_waveform_file, fed_db_file, amplitude_filter=Fal
start_latlon = (start[1], start[0])
end_latlon = (end[1], end[0])

title = 'Network {} CCP R-stacking (profile {}-{})'.format(net, sta_start, sta_end)
# title = 'Network {} CCP R-stacking (profile {}-{})'.format(net, sta_start, sta_end)
hf_main, hf_map, metadata = run(rf_stream, start_latlon, end_latlon, width, spacing, max_depth, channel,
stacked_scale=stack_scale, title=title, colormap=colormap,
background_model='ak135_60')
stacked_scale=stack_scale, colormap=colormap,
background_model='ak135_60', colorlegend=False)

metadata['transect_start'] = start
metadata['transect_end'] = end
Expand Down