Esempio n. 1
0
    def __init__(self, fig=None, targetfile=None):
        if fig is None:
            self.fig = plt.figure(figsize=(12, 6))#figsize=(18, 10))
            self.fig.subplots_adjust(wspace=0.05)
        else:
            fig.clf()
            self.fig = fig

        self.axdepth = {}
        self.axdepth['VP'] = self.fig.add_subplot(1, 5, 1, title="$V_P\,(km/s)$", ylabel="depth (km)")
        self.axdepth['VS'] = self.fig.add_subplot(1, 5, 2, title="$V_S\,(km/s)$",sharey=self.axdepth['VP'])
        self.axdepth['PR'] = self.fig.add_subplot(1, 5, 3, title=r"$V_P/V_S$", sharey=self.axdepth['VP'])
        self.axdepth['RH'] = self.fig.add_subplot(1, 5, 4, title=r"$\rho\,(g/cm^3)$", sharey=self.axdepth['VP'])

        if targetfile is None:
            self.axdisp = {}
            self.axdisp['RU0'] = self.fig.add_subplot(4, 5, 5, title="RU0", ylabel="grpvel (km/s)")
            self.axdisp['RU1'] = self.fig.add_subplot(4, 5, 10, title="RU1", ylabel="grpvel (km/s)", sharex=self.axdisp['RU0'], sharey=self.axdisp['RU0'])
            self.axdisp['RC0'] = self.fig.add_subplot(4, 5, 15, title="RC0", ylabel="phsvel (km/s)", sharex=self.axdisp['RU0'], sharey=self.axdisp['RU0'])
            self.axdisp['RC1'] = self.fig.add_subplot(4, 5, 20, title="RC1", ylabel="phsvel (km/s)", sharex=self.axdisp['RU0'], sharey=self.axdisp['RU0'])
            for key, ax in self.axdisp.items():
                ax.loglog([1.],[1.]) #f**k matplotlib v2
                ax.yaxis.set_label_position("right")
                ax.yaxis.tick_right()
        else:
            #adjust the suplots according to the target data
            s = surf96reader(targetfile)
            Ndisp = max([4, len(list(s.wtm()))])

            self.axdisp = {}
            share = None
            for n, (w, t, m)  in enumerate(s.wtm()):
                ax = self.fig.add_subplot(Ndisp, 5, (n+1)*5,
                                          title="%s%s%d" % (w, t, m),
                                          sharex=share, sharey=share,
                                          #ylabel="velocity (km/s)")
                                          ylabel="%s (km/s)" % (["grpvel", "phsvel"][int(t=="C")]))
                ax.yaxis.set_label_position("right")
                ax.yaxis.tick_right()

                self.axdisp["%s%s%d" % (w.upper(), t.upper(), m)] = share = ax
                plt.setp(ax.get_xticklabels(), visible = False)
            plt.setp(ax.get_xticklabels(), visible=True)
            ax.set_xlabel('$period\,(s)$')

        pos = ax.get_position()
        self.cax = self.fig.add_axes((pos.x0, np.max([0.12, pos.y0 - 0.12]), pos.width, 0.01))

        plt.setp(self.axdepth['VS'].get_yticklabels(), visible=False)
        plt.setp(self.axdepth['PR'].get_yticklabels(), visible=False)
        plt.setp(self.axdepth['RH'].get_yticklabels(), visible=False)
        self.axconv = None #Not needed here

        if not self.axdepth['VP'].yaxis_inverted():
            self.axdepth['VP'].invert_yaxis()

        # initiate collections data
        self.clear_collections()
Esempio n. 2
0
    def __init__(self, fig=None, targetfile=None):
        if fig is None:
            self.fig = plt.figure(figsize=(12, 6))#figsize=(18, 10))
            self.fig.subplots_adjust(wspace=0.05)
        else:
            self.fig = fig

        self.axvp = self.fig.add_subplot(1, 5, 1, title="$V_P\,(km/s)$", ylabel="depth (km)")
        self.axvs = self.fig.add_subplot(1, 5, 2, title="$V_S\,(km/s)$", sharey=self.axvp)  # , sharex = self.axvp)
        self.axpr = self.fig.add_subplot(1, 5, 3, title=r"$V_P/V_S$", sharey=self.axvp)
        self.axrh = self.fig.add_subplot(1, 5, 4, title=r"$\rho\,(g/cm^3)$", sharey=self.axvp)

        if targetfile is None:
            self.axru0 = self.fig.add_subplot(4, 5, 5,  title="RU0", ylabel="grpvel (km/s)")
            self.axru1 = self.fig.add_subplot(4, 5, 10, title="RU1", ylabel="grpvel (km/s)", sharex=self.axru0, sharey=self.axru0)
            self.axrc0 = self.fig.add_subplot(4, 5, 15, title="RC0", ylabel="phsvel (km/s)", sharex=self.axru0, sharey=self.axru0)
            self.axrc1 = self.fig.add_subplot(4, 5, 20, title="RC1", ylabel="phsvel (km/s)", sharex=self.axru0, sharey=self.axru0)
            self.axdisp = [self.axru0, self.axru1, self.axrc0, self.axrc1]
            for ax in self.axdisp:
                ax.loglog([1.],[1.]) #f**k matplotlib v2
                ax.yaxis.set_label_position("right")
                ax.yaxis.tick_right()
        else:
            #adjust the suplots according to the target data
            s = surf96reader(targetfile)
            Ndisp = max([4, len(list(s.wtm()))])

            self.axdisp = []
            share = None
            for n, (w, t, m)  in enumerate(s.wtm()):
                ax = self.fig.add_subplot(Ndisp, 5, (n+1)*5,
                                          title="%s%s%d" % (w, t, m),
                                          sharex=share, sharey=share,
                                          #ylabel="velocity (km/s)")
                                          ylabel="%s (km/s)" % (["grpvel", "phsvel"][int(t=="C")]))
                ax.yaxis.set_label_position("right")
                ax.yaxis.tick_right()
                share=ax
                self.__setattr__("ax%s%s%d" % (w.lower(), t.lower(), m), ax)
                self.axdisp.append(eval("self.ax%s%s%d" % (w.lower(), t.lower(), m)))
                plt.setp(ax.get_xticklabels(), visible = False)
            plt.setp(ax.get_xticklabels(), visible=True)
            ax.set_xlabel('$period\,(s)$')

        pos = self.axdisp[-1].get_position()
        #self.cax = self.fig.add_axes((pos.x0, 0.12, pos.width, 0.01))
        self.cax = self.fig.add_axes((pos.x0, pos.y0 - 0.12, pos.width, 0.01))

        plt.setp(self.axvs.get_yticklabels(), visible=False)
        plt.setp(self.axpr.get_yticklabels(), visible=False)
        plt.setp(self.axrh.get_yticklabels(), visible=False)
        self.axconv = None #Not needed here

        self.axdepth = [self.axvp, self.axvs, self.axpr, self.axrh]
        if not self.axvp.yaxis_inverted():
            self.axvp.invert_yaxis()
Esempio n. 3
0
    # -----------------------------------
    Waves, Types, Modes, Freqs = [], [], [], []
    for k in argv.keys():
        if k[0].upper() in "RL" and k[1].upper(
        ) in "UC" and k[2] in "0123456789":
            fstart, fend, nfreq, fspace = argv[k]
            freq = freqspace(float(fstart), float(fend), int(nfreq), fspace)
            Waves.append(k[0])
            Types.append(k[1])
            Modes.append(int(k[2:]))
            Freqs.append(freq)

    # -----------------------------------
    # ##compute dispersion curves
    fig1 = plt.figure(figsize=(8, 8))
    fig1.subplots_adjust(wspace=0.3)
    with Timer('dispersion'):
        out = list(dispersion_1(ztop, vp, vs, rh, Waves, Types, Modes, Freqs))
    ax1 = fig1.add_subplot(223)
    dm.show(ax1)
    ax1.grid(True, linestyle=":", color="k")
    plt.legend()
    ax2 = fig1.add_subplot(222)
    for w, t, m, fs, us in out:
        ax2.loglog(1. / fs, us, '+-', label="%s%s%d" % (w, t, m))
    ax2.set_ylabel('velocity (km/s)')
    ax2.grid(True, which="major")
    ax2.grid(True, which="minor")
    logtick(ax2, "xy")
    plt.legend()
Esempio n. 4
0
        out = list(dispersion_1(ztop, vp, vs, rh, Waves, Types, Modes, Freqs))
    ax1 = plt.gcf().add_subplot(121)
    dm.show(ax1)
    ax2 = plt.gcf().add_subplot(122)
    for w, t, m, fs, us in out:
        ax2.loglog(1. / fs, us, '+-', label="%s%s%d" % (w, t, m))
    ax2.set_xlabel('period (s)')
    ax2.set_ylabel('velocity (km/s)')
    ax2.grid(True, which="major")
    ax2.grid(True, which="minor")
    plt.legend()
    plt.gcf().show()

    # ##sensitivity kernels
    norm = True
    fig = plt.figure()
    fig.subplots_adjust(wspace=0.1, hspace=0.2)
    fig.show()
    for w, t, m, F, DLOGVADZ, DLOGVADLOGVS, DLOGVADLOGPR, DLOGVADLOGRH in \
            sker17_1(ztop, vp, vs, rh,
                     Waves, Types, Modes, Freqs,
                     dz=0.001, dlogvs=.01, dlogpr=.01, dlogrh=.01, norm=True,
                     h=0.005, dcl=0.005, dcr=0.005):

        fig.clf()
        # ------
        _depth_ = np.concatenate((ztop, [1.1 * ztop[-1]]))
        _F_ = np.concatenate(([F[0] * 0.95], F * 1.05))
        fig.suptitle('%s%s%d' % (w, t, m))

        # ------