Skip to content
Merged
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
10 changes: 4 additions & 6 deletions docs/rfpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Also, the following packages are required:

- `stdb <https://github.com/paudetseis/StDb>`_
- `spectrum <https://github.com/cokelaer/spectrum>`_
- `cartopy <https://scitools.org.uk/cartopy/docs/latest/>`_

Other required packages (e.g., ``obspy``)
will be automatically installed by ``stdb``.
Expand All @@ -49,7 +48,7 @@ where ``RfPy`` can be installed along with some of its dependencies.

.. sourcecode:: bash

conda create -n rfpy python=3.9 obspy cartopy -c conda-forge
conda create -n rfpy python=3.10 obspy spectrum -c conda-forge

Activate the newly created environment:

Expand All @@ -62,14 +61,13 @@ Install remaining dependencies using ``pip`` inside the ``rfpy`` environment:
.. sourcecode:: bash

pip install stdb
pip install spectrum

Installing from Pypi
--------------------
Installing from GitHub master branch
------------------------------------

.. sourcecode:: bash

pip install rfpy
pip install rfpy@git+https://github.com/paudetseis/rfpy

Installing from source
----------------------
Expand Down
2 changes: 1 addition & 1 deletion rfpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

__version__ = '0.1.3'
__version__ = '0.1.4'

__author__ = 'Pascal Audet'

Expand Down
11 changes: 7 additions & 4 deletions rfpy/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,20 @@ def bin(stream1, stream2=None, typ='baz', nbin=36+1, pws=False,
raise(Exception("Type has to be 'baz' or 'slow' or 'dist'"))

if typ == 'baz':
stat = [stream1[i].stats.baz for i in range(len(stream1))]
bmin = 0
bmax = 360
stat = [stream1[i].stats.baz for i in range(len(stream1))]
alt = np.mean([stream1[i].stats.slow for i in range(len(stream1))])
elif typ == 'slow':
stat = [stream1[i].stats.slow for i in range(len(stream1))]
bmin = np.min(np.array(stat))
bmax = np.max(np.array(stat))
alt = np.mean([stream1[i].stats.baz for i in range(len(stream1))])
elif typ == 'dist':
stat = [stream1[i].stats.gac for i in range(len(stream1))]
bmin = np.min(np.array(stat))
bmax = np.max(np.array(stat))
alt = np.mean([stream1[i].stats.baz for i in range(len(stream1))])

# Define bins
bins = np.linspace(bmin, bmax, nbin)
Expand Down Expand Up @@ -126,16 +129,16 @@ def bin(stream1, stream2=None, typ='baz', nbin=36+1, pws=False,
trace.stats.nbin = nb
if typ == 'baz':
trace.stats.baz = bins[i]
trace.stats.slow = None
trace.stats.slow = alt
trace.stats.nbin = nb
elif typ == 'slow':
trace.stats.slow = bins[i]
trace.stats.baz = None
trace.stats.baz = alt
trace.stats.nbin = nb
elif typ == 'dist':
trace.stats.dist = bins[i]
trace.stats.slow = None
trace.stats.baz = None
trace.stats.baz = alt
trace.stats.nbin = nb
if not pws:
weight = np.ones(len(stream[0].data))
Expand Down
97 changes: 49 additions & 48 deletions rfpy/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def wiggle(stream1, stream2=None, sort=None, tmin=0., tmax=30, normalize=True,

# PLot wiggles according to either baz or slowness
def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
btyp='baz', tmin=0., tmax=30., xtyp='time', scale=None,
norm=None, save=False, title=None, form='png'):
btyp='baz', trange=[0., 30.], xtyp='time',
norm=None, save=None, folder=None, show=True):
"""
Function to plot receiver function according to either baz or
slowness bins. By default,
Expand All @@ -167,16 +167,19 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
Trace to plot at the top of ``stream2``
btyp : str
Type of plot to produce (either 'baz', 'slow', or 'dist')
tmax : float
Maximum x-axis value displayed in the Figure.
trange : list of two floats
Range of x-axis values displayed in the Figure.
xtyp : str
Type of x-axis label (either 'time' or 'depth')
scale : float
Scale factor applied to trace amplitudes for plotting
save : bool
Whether or not to save the Figure
title : str
Title of plot
norm : float
Normalization value applied to all traces. If not specified,
default amplitude ranges will be set.
save : str
Filename of figure to be saved, including extension.
folder : str
Folder name where figure will be saved.
show : bool
Whether or not to show the figure upon execution.

"""

Expand All @@ -188,35 +191,31 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
raise(Exception("Cannot plot by slowness if data is migrated"))

# Figure out scaling here
if scale:
maxval = scale
maxvalT = maxval
else:
if norm:
for tr in stream1:
if norm is not None:
for tr in stream1:
tr.data /= norm
if stream2:
for tr in stream2:
tr.data /= norm
if stream2:
for tr in stream2:
tr.data /= norm
if btyp == 'baz':
maxval = 10.
maxvalT = maxval
elif btyp == 'slow':
maxval = 0.001
maxvalT = 2.*maxval
elif btyp == 'dist':
maxval = 1
maxvalT = maxval
else:
if btyp == 'baz':
maxval = 100
maxvalT = maxval
elif btyp == 'slow':
maxval = 0.02
maxvalT = maxval
elif btyp == 'dist':
maxval = 20
maxvalT = maxval
if btyp == 'baz':
maxval = 10.
maxvalT = maxval
elif btyp == 'slow':
maxval = 0.001
maxvalT = 2.*maxval
elif btyp == 'dist':
maxval = 1
maxvalT = maxval
else:
if btyp == 'baz':
maxval = 100
maxvalT = maxval
elif btyp == 'slow':
maxval = 0.02
maxvalT = maxval
elif btyp == 'dist':
maxval = 20
maxvalT = maxval

# Time axis
nn = stream1[0].stats.npts
Expand Down Expand Up @@ -270,7 +269,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
ax1.set_yticks(())
ax1.set_xticks(())
ax1.set_title('Radial')
ax1.set_xlim(tmin, tmax)
ax1.set_xlim(trange[0], trange[1])

# Plot binned SV traces in back-azimuth on bottom left
for tr in stream1:
Expand Down Expand Up @@ -299,7 +298,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
ax2.plot(time, y+tr.data*maxval,
linewidth=0.25, c='k')

ax2.set_xlim(tmin, tmax)
ax2.set_xlim(trange[0], trange[1])

if btyp == 'baz':
ax2.set_ylim(-5, 370)
Expand Down Expand Up @@ -337,7 +336,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
linewidth=0)
ax3.plot(time, tr2.data,
linewidth=0.25, c='k')
ax3.set_xlim(tmin, tmax)
ax3.set_xlim(trange[0], trange[1])
ax3.set_ylim(-1.*ylimT, ylimT)
ax3.set_yticks(())
ax3.set_xticks(())
Expand Down Expand Up @@ -371,7 +370,7 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
ax4.plot(time, y+tr.data*maxvalT,
linewidth=0.25, c='k')

ax4.set_xlim(tmin, tmax)
ax4.set_xlim(trange[0], trange[1])

if btyp == 'baz':
ax4.set_ylim(-5, 370)
Expand All @@ -390,13 +389,15 @@ def wiggle_bins(stream1, stream2=None, tr1=None, tr2=None,
if not ax3:
ax4.set_title('Transverse')

if title:
plt.suptitle(title)

if save:
plt.savefig('RF_PLOTS/' + stream1[0].stats.station +
'.' + title + '.' + form, format=form)
else:
if folder is not None:
plt.savefig(folder + '/' + stream1[0].stats.station +
'.' + save, format=save.split('.')[-1], dpi=300)
else:
plt.savefig('RF_PLOTS/' + stream1[0].stats.station +
'.' + save, format=save.split('.')[-1], dpi=300)

if show:
plt.show()

plt.close()
Expand Down
Loading
Loading