コード例 #1
0
def animate(frame):
    print('*' * 60)
    print(frame)
    roms_file = roms_path + 'chaba_his.' + str(start_file +
                                               (frame // 5) * 5) + '.nc'
    print(roms_file)
    zeta = vt.get_var('zeta', roms_file, itime=frame % 5, ndims=3)
    map_var = zeta[ymin:ymax, xmin:xmax]
    quad1.set_array(map_var.ravel())
    X = np.c_[px[frame, :] - xmin + npts, py[frame, :] - ymin + npts]
    #scat.set_offsets(X)
    scat = plt.scatter(px[frame, :] - xmin,
                       py[frame, :] - ymin,
                       c=pt[frame, :],
                       cmap='jet',
                       zorder=4)
    ax1.set_title('time ' + str(frame * delta_t / 3600 / 24) + ' (days)')
    #scat = vt.plot_seeding(px[frame, :]-xmin+npts, py[frame, :]-ymin+npts)
    vt.plot_traj(px - xmin + npts, py - ymin + npts, tend=frame, ax=ax1)
    return quad1
コード例 #2
0
xmin = int(np.floor(np.nanmin(px))) - ng
xmax = int(np.ceil(np.nanmax(px))) + ng
ymin = int(np.floor(np.nanmin(py))) - ng
ymax = int(np.ceil(np.nanmax(py))) + ng

save_path = '/home/jeremy/Bureau/Data/Pyticles/RESU/Visual_tools/Map_traj/'
fname = save_path + 'test_pw_dtime_' + str(dtime)

fig = plt.figure(figsize=[8., 8.])

# background 2D variable
plt.contourf(topo_roms, cmap='Greys', levels=zlevs, zorder=1, extend='max')
cbar0 = plt.colorbar(orientation='vertical', shrink=0.5)

# trajectories above 2D background variable
vt.plot_traj(px, py, zorder=2)

# particles vertical velocity pw every dtime
# marker Plus for depths0 = -50 m
# marker 'O' for depths0 = -500 m
vt.plot_part(pw[:, indx],
             px[:, indx],
             py[:, indx],
             ng=2,
             cmap='seismic',
             vmin=-2e-3,
             vmax=2e-3,
             marker='P',
             zorder=3,
             size=16,
             dtime=dtime)
コード例 #3
0
    # text
    ax1.set_xlabel('px')
    ax1.set_ylabel('py')
    ax1.set_title('time ' + str(itime * delta_t / 3600 / 24) + ' (days)')
    # scatter
    scat2 = vt.anim_scat(pdepth_lin,
                         px_lin - xmin,
                         py_lin - ymin,
                         itime=itime,
                         zorder=3,
                         size=10)
    scat = vt.anim_scat(pdepth_cub,
                        px_cub - xmin,
                        py_cub - ymin,
                        itime=itime,
                        zorder=4,
                        size=20,
                        marker='+')
    # cb0axes = fig.add_axes([left, bottom, width, height])
    cb0 = plt.colorbar(orientation='vertical', pad=0.1, shrink=0.5)
    cb1 = fig.colorbar(quad1, ax=ax1, shrink=0.5)
    # traj
    vt.plot_traj(px_lin - xmin,
                 py_lin - ymin,
                 tend=itime,
                 linewidth=0.25,
                 alpha=0.5)
    if save_fig:
        fname = save_dir + gen_name + str(itime) + fmt
        plt.savefig(fname)
コード例 #4
0
    # map_var
    #map_var = topo[xmin:xmax, ymin:xmax]
    map_var = topo
    quad1 = ax1.contourf(np.ma.masked_invalid(map_var.T),
                         cmap='Greys',
                         zorder=1)
    # text
    ax1.set_xlabel('px')
    ax1.set_ylabel('py')
    ax1.set_title('time ' + str(itime * delta_t / 3600 / 24) + ' (days)')
    # scatter
    #scat = vt.anim_scat(pt, px-xmin+npts, py-ymin+npts, itime=itime, zorder=3,
    #                    size=10)
    scat = vt.anim_scat(pt, px, py, itime=itime, zorder=3, size=10, vmin=10)

    cb0 = plt.colorbar(orientation='vertical', pad=0.1, shrink=0.5)
    cb1 = fig.colorbar(quad1, ax=ax1, shrink=0.5)
    # traj
    #vt.plot_traj(px-xmin+npts, py-ymin+npts, tend=itime, linewidth=0.25, alpha=0.5)
    vt.plot_traj(px, py, tend=itime, linewidth=0.25, alpha=0.5)
    ax1.set_xlim(left=xmin, right=xmax)
    ax1.set_ylim(bottom=ymin, top=ymax)

    if save_fig:
        fname = save_dir + gen_name + str(itime) + fmt
        plt.savefig(fname)
    plt.close('all')

##################################