Skip to content

Commit

Permalink
add key of order in plotrt
Browse files Browse the repository at this point in the history
  • Loading branch information
xumi1993 committed Nov 22, 2023
1 parent 4b084a3 commit befb1f0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
16 changes: 16 additions & 0 deletions seispy/plotR.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ def set_fig(axr, axb, axs, stadata, xmin=-2, xmax=80):


def plotr(rfsta, out_path='./', xlim=[-2, 80], key='bazi', enf=6, outformat='g', show=False):
""" Plot receiver function in R component
:param rfsta: receiver function data
:type rfsta: sespy.rfcorrect.RFStation
:param out_path: output path
:type out_path: str
:param xlim: xlim
:type xlim: list
:param key: sort key
:type key: str
:param enf: enhancement factor
:type enf: float
:param outformat: output format
:type outformat: str
:param show: show figure
:type show: bool
"""
h, axr, axb, axs = init_figure()
rfsta.sort(key)
plot_waves(axr, axb, axs, rfsta, enf=enf)
Expand Down
25 changes: 23 additions & 2 deletions seispy/plotRT.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ def init_figure():


def plot_waves(axr, axt, axb, axr_sum, axt_sum, stadata, enf=3):
"""Plot PRFs with R and T components
:param axr: The axis of R component
:type axr: matplotlib.axes
:param axt: The axis of T component
:type axt: matplotlib.axes
:param axb: The axis of back-azimuth
:type axb: matplotlib.axes
:param axr_sum: The axis of R component sum
:type axr_sum: matplotlib.axes
:param axt_sum: The axis of T component sum
:type axt_sum: matplotlib.axes
:param stadata: The PRFs data
:type stadata: seispy.core.StaData
:param enf: The enlarge factor, defaults to 3
:type enf: int, optional
"""

bound = np.zeros(stadata.rflength)
for i in range(stadata.ev_num):
datar = stadata.datar[i] * enf + (i + 1)
Expand Down Expand Up @@ -111,12 +129,15 @@ def set_fig(axr, axt, axb, axr_sum, axt_sum, stadata, station, xmin=-2, xmax=30,
def plotrt(rfsta, enf=3, out_path='./', key='bazi', outformat='g', xlim=[-2, 30], show=False):
"""Plot PRFs with R and T components
:param rfpath: Path to PRFs
:type rfpath: str
:param rfsta: Path to PRFs
:type rfsta: seispy.rfcorrect.RFStation
:param enf: The enlarge factor, defaults to 3
:type enf: int, optional
:param out_path: The output path, defaults to current directory
:type out_path: str, optional
:param key: The key to sort PRFs, avialible for ``event``, ``evla``, ``evlo``, ``evdp``,
``dis``, ``bazi``, ``rayp``, ``mag``, ``f0``, defaults to ``bazi``
:type key: str, optional
:param outformat: File format of the image file, g as \'png\', f as \'pdf\', defaults to 'g'
:type outformat: str, optional
"""
Expand Down
10 changes: 8 additions & 2 deletions seispy/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ def plot_rt():
parser = argparse.ArgumentParser(description="Plot R(Q)&T components for P receiver functions (PRFs)")
parser.add_argument('rfpath', help='Path to PRFs with a \'finallist.dat\' in it', type=str, default=None)
parser.add_argument('-e', help='Enlargement factor, defaults to 3', dest='enf', type=float, default=3, metavar='enf')
parser.add_argument('-k', help='The key to sort PRFs, avialible for \'event\', \'evla\', \'evlo\', \'evdp\','
'\'dis\', \'bazi\', \'rayp\', \'mag\', \'f0\', defaults to \'bazi\'', metavar='key',
default='bazi', type=str)
parser.add_argument('-o', help='Output path without file name, defaults to current path', dest='output', default='./', type=str, metavar='outpath')
parser.add_argument('-t', help='Specify figure format. f = \'.pdf\', g = \'.png\', defaults to \'g\'',
dest='format', default='g', type=str, metavar='f|g')
Expand All @@ -234,14 +237,17 @@ def plot_rt():
if arg.format not in ('f', 'g'):
raise ValueError('Error: The format must be in \'f\' and \'g\'')
rfsta = RFStation(arg.rfpath)
plotrt(rfsta, enf=arg.enf, out_path=arg.output, outformat=arg.format, xlim=[-2, arg.x])
plotrt(rfsta, enf=arg.enf, out_path=arg.output, key=arg.k, outformat=arg.format, xlim=[-2, arg.x])


def plot_r():
from seispy.plotR import plotr
parser = argparse.ArgumentParser(description="Plot R&T receiver functions")
parser.add_argument('rfpath', help='Path to PRFs with a \'finallist.dat\' in it', type=str)
parser.add_argument('-e', help='Enlargement factor, defaults to 6', dest='enf', type=float, default=6, metavar='enf')
parser.add_argument('-k', help='The key to sort PRFs, avialible for \'event\', \'evla\', \'evlo\', \'evdp\','
'\'dis\', \'bazi\', \'rayp\', \'mag\', \'f0\', defaults to \'bazi\'', metavar='key',
default='bazi', type=str)
parser.add_argument('-o', help='Output path without file name, defaults to current path', dest='output', default='./', type=str, metavar='outpath')
parser.add_argument('-t', help='Specify figure format. f = \'.pdf\', g = \'.png\', defaults to \'g\'',
dest='format', default='g', type=str, metavar='f|g')
Expand All @@ -255,5 +261,5 @@ def plot_r():
elif arg.format == 'f':
fmt = 'pdf'
rfsta = RFStation(arg.rfpath)
plotr(rfsta, arg.output, enf=arg.enf, xlim=[-2, arg.x], format=fmt)
plotr(rfsta, arg.output, enf=arg.enf, key=arg.k, xlim=[-2, arg.x], format=fmt)

0 comments on commit befb1f0

Please sign in to comment.