コード例 #1
0
def detide_uv(gaugeno):
    """
    Detide the observations and write out the new time series for later
    use.
    """

    HAIdir = os.path.join(obsdir,HAIdirs[gaugeno])
    t,uave,vave = V.get_gauge(HAIdir)

    if gaugeno==1123:
        t = t - 1.   # correct error in NGDC data for this gauge

    t2,u2h,u2p = detide_u(t,uave,gaugeno,'u')
    plt.savefig(HAIdir + '/u_detided.png')

    t2,v2h,v2p = detide_u(t,vave,gaugeno,'v')
    plt.savefig(HAIdir + '/v_detided.png')

    if 0:
        fname = HAIdir + '/detided_harmonic.txt'
        tuv = numpy.vstack([t2,u2h,v2h]).T
        numpy.savetxt(fname, tuv, fmt="%20.10f")
        print "Saved harmonic detided t,u,v in ",fname

        fname = HAIdir + '/detided_poly.txt'
        tuv = numpy.vstack([t2,u2p,v2p]).T
        numpy.savetxt(fname, tuv, fmt="%20.10f")
        print "Saved polynomial detided t,u,v in ",fname
コード例 #2
0
def detide_uv(gaugeno):
    """
    Detide the observations and write out the new time series for later
    use.
    """

    HAIdir = os.path.join(obsdir, HAIdirs[gaugeno])
    t, uave, vave = V.get_gauge(HAIdir)

    if gaugeno == 1123:
        t = t - 1.  # correct error in NGDC data for this gauge

    t2, u2h, u2p = detide_u(t, uave, gaugeno, 'u')
    plt.savefig(HAIdir + '/u_detided.png')

    t2, v2h, v2p = detide_u(t, vave, gaugeno, 'v')
    plt.savefig(HAIdir + '/v_detided.png')

    if 0:
        fname = HAIdir + '/detided_harmonic.txt'
        tuv = numpy.vstack([t2, u2h, v2h]).T
        numpy.savetxt(fname, tuv, fmt="%20.10f")
        print "Saved harmonic detided t,u,v in ", fname

        fname = HAIdir + '/detided_poly.txt'
        tuv = numpy.vstack([t2, u2p, v2p]).T
        numpy.savetxt(fname, tuv, fmt="%20.10f")
        print "Saved polynomial detided t,u,v in ", fname
コード例 #3
0
def plot_depths_and_detide(HAIdir):


    gauges = V.read_all(HAIdir)
    ng = len(gauges)
    R = np.linspace(0,1,ng)
    G = np.linspace(0,0,ng)
    B = np.linspace(1,0,ng)
    depths = gauges.keys()
    depths.sort()
    figure(11,(10,10))
    clf()
    subplot(211)
    for i in range(ng):
        g = gauges[depths[i]]
        plot(g.tdata,g.vdata[:,2],color=[R[i],G[i],B[i]])
    #xticks(rotation=20)
    #xlim([g.tdata[0] - DT.timedelta(0,12.*3600), g.tdata[-1]])
    #xlabel("Hours post-quake")
    ylabel("cm/sec", fontsize=15)
    #title("%s   %s" % (g.id,g.name))
    title("u-velocities at gauge   %s" % (g.id),fontsize=15)
    #legend([str(d) for d in depths], 'upper left')

    subplot(212)
    for i in range(ng):
        g = gauges[depths[i]]
        plot(g.tdata,g.vdata[:,3],color=[R[i],G[i],B[i]])
    #xticks(rotation=20)
    #xlim([g.tdata[0] - DT.timedelta(0,12.*3600), g.tdata[-1]])
    xlabel("Hours post-quake")
    ylabel("cm/sec", fontsize=15)
    title("v-velocities at gauge   %s" % (g.id),fontsize=15)
    #legend([str(d) for d in depths], 'upper left')
    savefig('uvdepth%s.png' % g.id)


    t,uave,vave = V.get_gauge(HAIdir)
    degree = 20
    c, t2, u2, u_tide = dart.fit_tide_poly2(t,uave,degree,-20,28,-20,28)
    c, t2, v2, v_tide = dart.fit_tide_poly2(t,vave,degree,-20,28,-20,28)

    figure(12,(10,10))
    clf()
    subplot(211)
    plot(t,uave,'b')
    plot(t2,u_tide,'k')
    ylabel("cm/sec", fontsize=15)
    title("Depth averaged u-velocity at gauge   %s" % (g.id),fontsize=15)
    subplot(212)
    plot(t,vave,'b')
    plot(t2,v_tide,'k')
    ylabel("cm/sec", fontsize=15)
    title("Depth averaged v-velocity at gauge   %s" % (g.id),fontsize=15)
    savefig('uvtide%s.png' % g.id)
コード例 #4
0
def make_figures(gaugeno):
    HAIdir = os.path.join(obsdir,HAIdirs[gaugeno])
    t,uave,vave = V.get_gauge(HAIdir)

    if gaugeno==1123:
        t = t - 1.   # correct error in NGDC data for this gauge

    plt.figure(310,figsize=(10,10))
    plt.clf()
    ax1 = plt.subplot(211)
    t2,u2h,u2p = detide_and_plot(t,uave,gaugeno,'u',ax1)
    ax2 = plt.subplot(212)
    t2,v2h,v2p = detide_and_plot(t,vave,gaugeno,'v',ax2)
    fname = '../Figures/uv_tideHAI%s.png' % gaugeno
    plt.savefig(fname)
    print "Created ",fname
コード例 #5
0
def make_figures(gaugeno):
    HAIdir = os.path.join(obsdir, HAIdirs[gaugeno])
    t, uave, vave = V.get_gauge(HAIdir)

    if gaugeno == 1123:
        t = t - 1.  # correct error in NGDC data for this gauge

    plt.figure(310, figsize=(10, 10))
    plt.clf()
    ax1 = plt.subplot(211)
    t2, u2h, u2p = detide_and_plot(t, uave, gaugeno, 'u', ax1)
    ax2 = plt.subplot(212)
    t2, v2h, v2p = detide_and_plot(t, vave, gaugeno, 'v', ax2)
    fname = '../Figures/uv_tideHAI%s.png' % gaugeno
    plt.savefig(fname)
    print "Created ", fname
コード例 #6
0
ファイル: detide.py プロジェクト: rjleveque/tohoku2011-paper2
def detide(gaugeno, HAIdir):
    """
    Detide the observations and write out the new time series for later
    use.
    """

    t, uave, vave = V.get_gauge(HAIdir)

    degree = 20
    c, t2, u2 = dart.fit_tide_poly(t, uave, degree, -20, 28, 0, 25)
    c, t2, v2 = dart.fit_tide_poly(t, vave, degree, -20, 28, 0, 25)

    if gaugeno == 1123:
        t2 = t2 - 1.  # correct error in NGDC data for this gauge

    fname = HAIdir + '/detided.txt'
    tuv = vstack([t2, u2, v2]).T
    savetxt(fname, tuv, fmt="%20.10f")
    print "Saved detided t,u,v in ", fname
コード例 #7
0
def detide(gaugeno,HAIdir):
    """
    Detide the observations and write out the new time series for later
    use.
    """

    t,uave,vave = V.get_gauge(HAIdir)

    degree = 20
    c, t2, u2 = dart.fit_tide_poly(t,uave,degree,-20,28,0,25)
    c, t2, v2 = dart.fit_tide_poly(t,vave,degree,-20,28,0,25)
    
    if gaugeno==1123:
        t2 = t2 - 1.   # correct error in NGDC data for this gauge

    fname = HAIdir + '/detided.txt' 
    tuv = vstack([t2,u2,v2]).T
    savetxt(fname, tuv, fmt="%20.10f")
    print "Saved detided t,u,v in ",fname
コード例 #8
0
def make_figs(gaugeno, rundir, outdir, veldir):

    rootdir = os.getcwd()
    os.chdir(rundir)

    # measurement values:
    mdir = os.path.abspath('../../Hawaii_velocity_measurements/%s') % veldir
    print "Looking for observations in ", mdir

    if 0:
        # Use raw data:
        t_m, u_m, v_m = V.get_gauge(mdir)
    else:
        # Use detided values:
        fname = mdir + '/detided.txt'
        t_m, u_m, v_m = loadtxt(os.path.join(mdir, fname), unpack=True)
        print "Read detided u,v from ", fname

    # computed results:
    plotdata = ClawPlotData()
    plotdata.outdir = outdir
    print "Looking for GeoClaw results in ", outdir

    t, speed, u, v, eta = PGV.plot_gauge(gaugeno, plotdata)
    t = t / 3600.  # convert to hours

    i_ts = find((t_m >= t.min()) & (t_m <= t.min() + 5.))

    figure(101)
    clf()
    #plot(u_m,v_m,'k')
    plot(u, v, 'r', linewidth=3, label='GeoClaw')
    plot(u_m[i_ts], v_m[i_ts], 'ko', label='Observed')

    smax = max(abs(u).max(),
               abs(v).max(),
               abs(u_m).max(),
               abs(v_m).max()) * 1.05
    plot([-smax, smax], [0, 0], 'k')
    plot([0, 0], [-smax, smax], 'k')
    axis('scaled')
    axis([-smax, smax, -smax, smax])
    #legend(['Observed','GeoClaw'])
    legend(loc=('lower right'))
    title('Velocities at gauge %s' % gaugeno)
    xlabel('u in cm/sec')
    ylabel('v in cm/sec')
    fname = "figure%sa.png" % gaugeno
    savefig(fname)
    print "Created ", fname

    figure(102, figsize=(8, 10))
    clf()
    subplot(2, 1, 1)
    plot(t_m, u_m, 'ko-', linewidth=2)
    #plot(t_m[i_ts],u_m[i_ts],'bo-',linewidth=2)
    plot(t, u, 'r', linewidth=3)
    #legend(['Observed','GeoClaw'],'upper left')
    title('u velocities at gauge %s' % gaugeno)
    xlim(t.min(), t.max())
    ylim(-smax, smax)
    ylabel('Velocities in cm/sec')
    #ylim(-80,40)

    subplot(2, 1, 2)
    plot(t_m, v_m, 'ko-', linewidth=2, label="Observed")
    #plot(t_m[i_ts],v_m[i_ts],'bo-',linewidth=2)
    plot(t, v, 'r', linewidth=3, label="GeoClaw")
    #legend(loc=('lower left'))
    title('v velocities at gauge %s' % gaugeno)
    xlim(t.min(), t.max())
    ylim(-smax, smax)
    ylabel('Velocities in cm/sec')
    xlabel('Hours post-quake')

    #import pdb; pdb.set_trace()

    fname = "figure%sb.png" % gaugeno
    savefig(fname)
    print "Created ", fname
    os.chdir(rootdir)
コード例 #9
0
def make_figs(gaugeno,rundir,outdir,veldir):

    rootdir = os.getcwd()
    os.chdir(rundir)

    # measurement values:
    mdir = os.path.abspath('../../Hawaii_velocity_measurements/%s') % veldir
    print "Looking for observations in ",mdir
    
    if 0:
        # Use raw data:
        t_m,u_m,v_m = V.get_gauge(mdir)
    else:
        # Use detided values:
        fname = mdir + '/detided.txt'
        t_m,u_m,v_m = loadtxt(os.path.join(mdir,fname), unpack=True)
        print "Read detided u,v from ",fname


    # computed results:
    plotdata = ClawPlotData()
    plotdata.outdir = outdir
    print "Looking for GeoClaw results in ",outdir

    t,speed,u,v,eta = PGV.plot_gauge(gaugeno,plotdata)
    t = t/3600.  # convert to hours

    i_ts = find((t_m >= t.min()) & (t_m <= t.min() + 5.))

    figure(101)
    clf()
    #plot(u_m,v_m,'k')
    plot(u,v,'r',linewidth=3,label='GeoClaw')
    plot(u_m[i_ts],v_m[i_ts],'ko',label='Observed')

    smax = max(abs(u).max(),abs(v).max(),abs(u_m).max(),abs(v_m).max()) * 1.05
    plot([-smax,smax],[0,0],'k')
    plot([0,0],[-smax,smax],'k')
    axis('scaled')
    axis([-smax,smax,-smax,smax])
    #legend(['Observed','GeoClaw'])
    legend(loc=('lower right'))
    title('Velocities at gauge %s' % gaugeno)
    xlabel('u in cm/sec')
    ylabel('v in cm/sec')
    fname = "figure%sa.png" % gaugeno
    savefig(fname)
    print "Created ",fname

    figure(102,figsize=(8,10))
    clf()
    subplot(2,1,1)
    plot(t_m,u_m,'ko-',linewidth=2)
    #plot(t_m[i_ts],u_m[i_ts],'bo-',linewidth=2)
    plot(t,u,'r',linewidth=3)
    #legend(['Observed','GeoClaw'],'upper left')
    title('u velocities at gauge %s' % gaugeno)
    xlim(t.min(),t.max())
    ylim(-smax,smax)
    ylabel('Velocities in cm/sec')
    #ylim(-80,40)

    subplot(2,1,2)
    plot(t_m,v_m,'ko-',linewidth=2,label="Observed")
    #plot(t_m[i_ts],v_m[i_ts],'bo-',linewidth=2)
    plot(t,v,'r',linewidth=3,label="GeoClaw")
    #legend(loc=('lower left'))
    title('v velocities at gauge %s' % gaugeno)
    xlim(t.min(),t.max())
    ylim(-smax,smax)
    ylabel('Velocities in cm/sec')
    xlabel('Hours post-quake')
    
    #import pdb; pdb.set_trace()

    fname = "figure%sb.png" % gaugeno
    savefig(fname)
    print "Created ",fname
    os.chdir(rootdir)