Esempio n. 1
0
def update_save_1D(sim):

    sim.fig.suptitle(smart_time(sim.time))

    for var_cnt in range(len(sim.plot_vars)):

        var = sim.plot_vars[var_cnt]

        # Update plot
        for L in range(sim.Nz):

            if var == 'u':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.u[0:sim.Nx, 0:sim.Ny + 1, L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.u[0:sim.Nx, 0:sim.Ny, L]
            elif var == 'v':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.v[0:sim.Nx + 1, 0:sim.Ny, L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.v[0:sim.Nx, 0:sim.Ny, L]
            elif var == 'h':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.h[0:sim.Nx + 1, 0:sim.Ny + 1,
                                         L] - sim.Hs[L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.h[0:sim.Nx, 0:sim.Ny, L] - sim.Hs[L]
            elif var == 'vort':
                to_plot = sim.ddx_v(sim.soln.v[:,:,L],sim) \
                        - sim.ddy_u(sim.soln.u[:,:,L],sim)
                to_plot = to_plot.ravel()
                if sim.f0 != 0:
                    to_plot *= 1. / sim.f0
            elif var == 'div':
                h = sim.soln.h[:, :, L]
                to_plot = sim.ddx_u(h*sim.soln.u[:,:,L],sim) \
                        + sim.ddy_v(h*sim.soln.v[:,:,L],sim)
                to_plot = to_plot.ravel()
                if sim.f0 != 0:
                    to_plot *= 1. / sim.f0

            sim.Qs[var_cnt][L].set_ydata(to_plot)

            if len(sim.ylims[var_cnt]) != 2:
                sim.axs[var_cnt][L].relim()
                tmp = sim.axs[var][L].get_ylim()
                sim.axs[var_cnt][L].set_ylim(
                    [-np.max(np.abs(tmp)),
                     np.max(np.abs(tmp))])
                sim.axs[var_cnt][L].autoscale_view()

    plt.draw()

    sim.fig.savefig('Outputs/{0:s}/Frames/frame_{1:05d}.png'.format(
        sim.run_name, sim.frame_count))
    sim.frame_count += 1
Esempio n. 2
0
def update_hov(sim):

    sim.fig.suptitle(smart_time(sim.time))
    if sim.Nx > 1:
        sim.hov_h[:,:,sim.hov_count] = sim.soln.h[:,0,:-1]
        x = sim.x/1e3
    else:
        sim.hov_h[:,:,sim.hov_count] = sim.soln.h[0,:,:-1] 
        x = sim.y/1e3
    sim.hov_count += 1
Esempio n. 3
0
def update_save_1D(sim):

    sim.fig.suptitle(smart_time(sim.time))

    for var_cnt in range(len(sim.plot_vars)):

        var = sim.plot_vars[var_cnt]

        # Update plot
        for L in range(sim.Nz):

            if var == 'u':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.u[0:sim.Nx,0:sim.Ny+1,L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.u[0:sim.Nx,0:sim.Ny,L]
            elif var == 'v':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.v[0:sim.Nx+1,0:sim.Ny,L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.v[0:sim.Nx,0:sim.Ny,L]
            elif var == 'h':
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L] - sim.Hs[L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.h[0:sim.Nx,0:sim.Ny,L] - sim.Hs[L]
            elif var == 'vort':
                to_plot = sim.ddx_v(sim.soln.v[:,:,L],sim) \
                        - sim.ddy_u(sim.soln.u[:,:,L],sim)
                to_plot = to_plot.ravel()
                if sim.f0 != 0:
                    to_plot *= 1./sim.f0
            elif var == 'div':
                h = sim.soln.h[:,:,L]
                to_plot = sim.ddx_u(h*sim.soln.u[:,:,L],sim) \
                        + sim.ddy_v(h*sim.soln.v[:,:,L],sim)
                to_plot = to_plot.ravel()
                if sim.f0 != 0:
                    to_plot *= 1./sim.f0


            sim.Qs[var_cnt][L].set_ydata(to_plot)

            if len(sim.ylims[var_cnt]) != 2: 
                sim.axs[var_cnt][L].relim()
                tmp = sim.axs[var][L].get_ylim()
                sim.axs[var_cnt][L].set_ylim([-np.max(np.abs(tmp)), np.max(np.abs(tmp))]);
                sim.axs[var_cnt][L].autoscale_view()

    plt.draw()

    sim.fig.savefig('Outputs/{0:s}/Frames/frame_{1:05d}.png'.format(sim.run_name,sim.frame_count))
    sim.frame_count += 1
Esempio n. 4
0
def update_save_2D(sim):

    Nx, Ny = sim.Nx, sim.Ny
    for var_cnt in range(len(sim.plot_vars)):

        var = sim.plot_vars[var_cnt]

        for L in range(sim.Nz):

            if var == 'u':
                sim.ttls[var_cnt][L].set_text('Zonal Velocity : {0:s}'.format(
                    smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.u[0:sim.Nx, 0:sim.Ny + 1, L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.u[0:sim.Nx, 0:sim.Ny, L]
            elif var == 'v':
                sim.ttls[var_cnt][L].set_text(
                    'Meridional Velocity : {0:s}'.format(smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.v[0:sim.Nx + 1, 0:sim.Ny, L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.v[0:sim.Nx, 0:sim.Ny, L]
            elif var == 'h':
                sim.ttls[var_cnt][L].set_text(
                    'Free Surface Displacement : {0:s}'.format(
                        smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.h[0:sim.Nx + 1, 0:sim.Ny + 1,
                                         L] - sim.Hs[L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.h[0:sim.Nx, 0:sim.Ny, L] - sim.Hs[L]
            elif var == 'vort':

                if sim.method.lower() == 'sadourny':
                    to_plot =     sim.ddx_v(sim.soln.v[0:sim.Nx+1,0:sim.Ny,L],sim.dx[0]) \
                                - sim.ddy_u(sim.soln.u[0:sim.Nx,0:sim.Ny+1,L],sim.dx[1])
                    to_plot = sim.avx_u(sim.avy_v(to_plot))
                elif sim.method.lower() == 'spectral':
                    to_plot =     sim.ddx_v(sim.soln.v[0:sim.Nx,0:sim.Ny,L],sim) \
                                - sim.ddy_u(sim.soln.u[0:sim.Nx,0:sim.Ny,L],sim)

                if sim.f0 != 0:
                    sim.ttls[var_cnt][L].set_text(
                        'Vorticity / f_0 : {0:s}'.format(smart_time(sim.time)))
                    to_plot *= 1. / sim.f0
                else:
                    sim.ttls[var_cnt][L].set_text('Vorticity : {0:s}'.format(
                        smart_time(sim.time)))
            elif var == 'div':

                if sim.method.lower() == 'sadourny':
                    to_plot =     sim.ddx_u(sim.avx_h(sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L])*sim.soln.u[0:sim.Nx,0:sim.Ny+1,L],sim.dx[0]) \
                                + sim.ddy_v(sim.avy_h(sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L])*sim.soln.v[0:sim.Nx+1,0:sim.Ny,L],sim.dy[0])
                elif sim.method.lower() == 'spectral':
                    h = sim.soln.h[:, :, L]
                    to_plot =     sim.ddx_u(h*sim.soln.u[0:Nx,0:Ny,L],sim) \
                                + sim.ddy_v(h*sim.soln.v[0:Nx,0:Ny,L],sim)

                if sim.f0 != 0:
                    sim.ttls[var_cnt][L].set_text(
                        'Divergence of mass-flux / f_0 : {0:s}'.format(
                            smart_time(sim.time)))
                    to_plot *= 1. / sim.f0
                else:
                    sim.ttls[var_cnt][L].set_text(
                        'Divergence of mass-flux : {0:s}'.format(
                            smart_time(sim.time)))

            sim.Qs[var_cnt][L].set_array(to_plot.ravel())
            sim.Qs[var_cnt][L].changed()

        plt.draw()
        sim.figs[var_cnt].savefig(
            'Outputs/{0:s}/Frames/{1:s}_{2:05d}.png'.format(
                sim.run_name, var, sim.frame_count))

    sim.frame_count += 1
Esempio n. 5
0
def update_anim_2D(sim):

    Nx, Ny = sim.Nx, sim.Ny
    for var_cnt in range(len(sim.plot_vars)):

        var = sim.plot_vars[var_cnt]

        for L in range(sim.Nz):

            if var == 'u':
                sim.ttls[var_cnt][L].set_text('Zonal Velocity : {0:s}'.format(smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.u[0:sim.Nx,0:sim.Ny+1,L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.u[0:sim.Nx,0:sim.Ny,L]
            elif var == 'v':
                sim.ttls[var_cnt][L].set_text('Meridional Velocity : {0:s}'.format(smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.v[0:sim.Nx+1,0:sim.Ny,L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.v[0:sim.Nx,0:sim.Ny,L]
            elif var == 'h':
                sim.ttls[var_cnt][L].set_text('Free Surface Displacement : {0:s}'.format(smart_time(sim.time)))
                if sim.method.lower() == 'sadourny':
                    to_plot = sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L] - sim.Hs[L]
                elif sim.method.lower() == 'spectral':
                    to_plot = sim.soln.h[0:sim.Nx,0:sim.Ny,L] - sim.Hs[L]
            elif var == 'vort':
                
                if sim.method.lower() == 'sadourny':
                    to_plot =     sim.ddx_v(sim.soln.v[0:sim.Nx+1,0:sim.Ny,L],sim.dx[0]) \
                                - sim.ddy_u(sim.soln.u[0:sim.Nx,0:sim.Ny+1,L],sim.dx[1])
                    to_plot = sim.avx_u(sim.avy_v(to_plot))
                elif sim.method.lower() == 'spectral':
                    to_plot =     sim.ddx_v(sim.soln.v[0:sim.Nx,0:sim.Ny,L],sim) \
                                - sim.ddy_u(sim.soln.u[0:sim.Nx,0:sim.Ny,L],sim)
                
                if sim.f0 != 0:
                    sim.ttls[var_cnt][L].set_text('Vorticity / f_0 : {0:s}'.format(smart_time(sim.time)))
                    to_plot *= 1./sim.f0
                else:   
                    sim.ttls[var_cnt][L].set_text('Vorticity : {0:s}'.format(smart_time(sim.time)))
            elif var == 'div':

                if sim.method.lower() == 'sadourny':
                    to_plot =     sim.ddx_u(sim.avx_h(sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L])*sim.soln.u[0:sim.Nx,0:sim.Ny+1,L],sim.dx[0]) \
                                + sim.ddy_v(sim.avy_h(sim.soln.h[0:sim.Nx+1,0:sim.Ny+1,L])*sim.soln.v[0:sim.Nx+1,0:sim.Ny,L],sim.dy[0])
                elif sim.method.lower() == 'spectral':
                    h = sim.soln.h[:,:,L] 
                    to_plot =     sim.ddx_u(h*sim.soln.u[0:Nx,0:Ny,L],sim) \
                                + sim.ddy_v(h*sim.soln.v[0:Nx,0:Ny,L],sim)

                if sim.f0 != 0:
                    sim.ttls[var_cnt][L].set_text('Divergence of mass-flux / f_0 : {0:s}'.format(smart_time(sim.time)))
                    to_plot *= 1./sim.f0
                else:   
                    sim.ttls[var_cnt][L].set_text('Divergence of mass-flux : {0:s}'.format(smart_time(sim.time)))

            sim.Qs[var_cnt][L].set_array(to_plot.ravel())
            sim.Qs[var_cnt][L].changed()
        plt.pause(0.01) 
    plt.draw()