diff --git a/seispy/plotR.py b/seispy/plotR.py index 5b745cd1..b61f9475 100644 --- a/seispy/plotR.py +++ b/seispy/plotR.py @@ -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) diff --git a/seispy/plotRT.py b/seispy/plotRT.py index 80a63a4c..5fdd1ca5 100644 --- a/seispy/plotRT.py +++ b/seispy/plotRT.py @@ -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) @@ -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 """ diff --git a/seispy/scripts.py b/seispy/scripts.py index 2e54c736..0cdddfc1 100644 --- a/seispy/scripts.py +++ b/seispy/scripts.py @@ -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') @@ -234,7 +237,7 @@ 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(): @@ -242,6 +245,9 @@ def plot_r(): 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') @@ -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)