From 39071b6a44b288fd8fb2386f4d97f6405f0d5cde Mon Sep 17 00:00:00 2001 From: Andrew Medlin Date: Thu, 13 Feb 2020 11:10:42 +1100 Subject: [PATCH 1/3] Squashed image size to 5 and removed unwanted plot elements --- seismic/receiver_fn/plot_ccp.py | 26 ++++++++++++++++++-------- seismic/receiver_fn/plot_ccp_batch.py | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/seismic/receiver_fn/plot_ccp.py b/seismic/receiver_fn/plot_ccp.py index 0ad1326f..6a079dc6 100644 --- a/seismic/receiver_fn/plot_ccp.py +++ b/seismic/receiver_fn/plot_ccp.py @@ -33,7 +33,8 @@ from seismic.receiver_fn.rf_util 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] @@ -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, 5)) interpolation = 'hanning' extent = (0, length, 0, max_depth) assert not np.any(np.isnan(matrx)) @@ -68,11 +71,15 @@ 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) @@ -100,8 +107,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 @@ -559,7 +566,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 @@ -584,6 +592,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) """ @@ -604,7 +614,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 diff --git a/seismic/receiver_fn/plot_ccp_batch.py b/seismic/receiver_fn/plot_ccp_batch.py index c22a4d7c..300c3f4e 100644 --- a/seismic/receiver_fn/plot_ccp_batch.py +++ b/seismic/receiver_fn/plot_ccp_batch.py @@ -114,7 +114,7 @@ def run_batch(transect_file, rf_waveform_file, fed_db_file, amplitude_filter=Fal 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') + background_model='ak135_60', colorlegend=False) metadata['transect_start'] = start metadata['transect_end'] = end From 3ad11a0b8f9115ffa520d6c51fbc7d4bfbe81b19 Mon Sep 17 00:00:00 2001 From: Andrew Medlin Date: Thu, 13 Feb 2020 11:23:23 +1100 Subject: [PATCH 2/3] Squashed image size to 4 to generate alternate, slimmer plots --- seismic/receiver_fn/plot_ccp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seismic/receiver_fn/plot_ccp.py b/seismic/receiver_fn/plot_ccp.py index 6a079dc6..0316b76f 100644 --- a/seismic/receiver_fn/plot_ccp.py +++ b/seismic/receiver_fn/plot_ccp.py @@ -61,7 +61,7 @@ def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title tickstep_x = 50 tickstep_y = 25 - fig = plt.figure(figsize=(16, 5)) + fig = plt.figure(figsize=(16, 4)) interpolation = 'hanning' extent = (0, length, 0, max_depth) assert not np.any(np.isnan(matrx)) From 3c889c874516b72ffd1cf6d985efc3b1b9d4d15a Mon Sep 17 00:00:00 2001 From: Andrew Medlin Date: Thu, 13 Feb 2020 13:07:32 +1100 Subject: [PATCH 3/3] Removed title for publication purposes. Reduced x-label padding to fix clipping of x-axis label text. --- seismic/receiver_fn/plot_ccp.py | 2 +- seismic/receiver_fn/plot_ccp_batch.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seismic/receiver_fn/plot_ccp.py b/seismic/receiver_fn/plot_ccp.py index 0316b76f..41edf1db 100644 --- a/seismic/receiver_fn/plot_ccp.py +++ b/seismic/receiver_fn/plot_ccp.py @@ -84,7 +84,7 @@ def plot_ccp(matrx, length, max_depth, spacing, vlims=None, metadata=None, title 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) diff --git a/seismic/receiver_fn/plot_ccp_batch.py b/seismic/receiver_fn/plot_ccp_batch.py index 300c3f4e..377ad79e 100644 --- a/seismic/receiver_fn/plot_ccp_batch.py +++ b/seismic/receiver_fn/plot_ccp_batch.py @@ -111,9 +111,9 @@ 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, + stacked_scale=stack_scale, colormap=colormap, background_model='ak135_60', colorlegend=False) metadata['transect_start'] = start