예제 #1
0
def plot_pd_heat_fn(inp_fol, years):
    
    data=heatbudg_zon_pd_fn(inp_fol, years,[0,72])
    pd_dic = pentad_dic(1)
    #data = rundata.mean(('lon'))
    
    def plot_heat_var(var,lev,levels):
        var_dic = {'heat_eddy': 'Eddy advective terms',
                    'heat_mean': 'Mean state advective terms'}
        plot_data = data.data_vars[var]
        plot_data = plot_data*86400.
        g=plot_data[:,lev,:].plot.contourf(x='pentad', y='lat', add_label = False, add_colorbar=False)
        plt.colorbar(g)
        tickspace = range(10,80,10)
        labels = [pd_dic[k] for k in tickspace]
        plt.ylim(0,90)
        plt.xlim(1,73)
        plt.xlabel('Pentad')
        plt.xticks(tickspace,labels,rotation=25)
        plt.ylabel('Latitude')
        plt.plot([float(data.pentad[36]),float(data.pentad[36])],[0.,90.],'k--')
        plt.title(var_dic[var])
        plt.savefig('/scratch/rg419/plots/mom_budg_work/'+inp_fol+'/'+var+'.png')
        plt.close()
        
    vars = ['heat_eddy','heat_mean']
    for var in vars:
        plot_heat_var(var,2,np.arange(-2.,2.1,0.2))            
예제 #2
0
def plot_pd_mom_fn(inp_fol):
    
    data_file = '/scratch/rg419/plots/monsoon_analysis/'+inp_fol+'/mombudg_data.nc'
    data= xr.open_dataset( data_file) 
    print 'data loaded, starting plotting'
    land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/topo_10m/input/land.nc'
    land = xr.open_dataset( land_file)
    land_plot = xr.DataArray(land.land_mask.values, [('lat', data.lat), ('lon', data.lon)])
    pd_dic = pentad_dic(1)
        
    def plot_mom_var(var,levels,qscale):
        
        if var == 'fv_mn_imb':
            plot_data = data.data_vars['fv_av'] + data.data_vars['mom_mean']
        else:
            plot_data = data.data_vars[var]
        plot_data = plot_data*10000.
        
        for mnth in range(0,12):
            g=plot_data[mnth*6 : mnth*6+6,:,:].plot.contourf(x='lon', y='lat',levels=levels, col='pentad', col_wrap=3)
            plt.ylim(0,90)
            #plt.xlim(60,180)
            for i, ax in enumerate(g.axes.flat):
                land_plot.plot.contour(x='lon', y='lat',levels=np.arange(0.,2.,1.), colors='k',add_colorbar=False,add_labels=False,ax=ax)
                ax.quiver(data.lon[::3], data.lat[::1], data.u_av[mnth*6 +i,::1,::3], data.v_av[mnth*6+i,::1,::3], scale=qscale,headwidth=5)
                ax.set_title(pd_dic[mnth*6+i+1])
            plt.savefig('/scratch/rg419/plots/monsoon_analysis/'+ inp_fol + '/' + var + str(mnth + 1) + '.png')
            plt.close()
        
    vars = ['dphidx_av']#,'fv_av','mom_eddy','mom_mean','mom_sum','fv_mn_imb']
    for var in vars:
        plot_mom_var(var,np.arange(-2.,2.1,0.2),500.)            
예제 #3
0
def plot_pd_mom_fn(inp_fol, years, trange):
    
    data=mom_adv_terms_fn(inp_fol, years, trange)
    print 'data loaded, starting plotting'
    land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/topo_10m/input/land.nc'
    land = xr.open_dataset( land_file)
    land_plot = xr.DataArray(land.land_mask.values, [('lat', data.lat), ('lon', data.lon)])
    pd_dic = pentad_dic(1)
    
    data.to_netcdf(path='/scratch/rg419/plots/monsoon_analysis/'+inp_fol+'/mom_adv_data.nc', mode='w')
    
    def plot_mom_var(var,levels,qscale):
        
        plot_data = -1.*data.data_vars[var]
        plot_data = plot_data*10000.
        
        for mnth in range(0,12):
            g=plot_data[mnth*6 : mnth*6+6,:,:].plot.contourf(x='lon', y='lat',levels=levels, col='pentad', col_wrap=3)
            plt.ylim(-45,45)
            plt.xlim(60,180)
            for i, ax in enumerate(g.axes.flat):
                land_plot.plot.contour(x='lon', y='lat',levels=np.arange(0.,2.,1.), colors='k',add_colorbar=False,add_labels=False,ax=ax)
                ax.quiver(data.lon[::3], data.lat[::1], data.u_av[mnth*6 +i,::1,::3], data.v_av[mnth*6+i,::1,::3], scale=qscale,headwidth=5)
                ax.set_title(pd_dic[mnth*6+i+1])
            plt.savefig('/scratch/rg419/plots/monsoon_analysis/'+ inp_fol + '/' + var + str(mnth + 1) + '.png')
            plt.close()
        
    vars = ['ududx_av','vdudy_av','wdudp_av','duueddx_av','duveddy_av','duweddp_av']
    for var in vars:
        plot_mom_var(var,np.arange(-2.,2.1,0.2),500.)            
예제 #4
0
def plot_pd_gp_fn(inp_fol, nproc, years, trange):

    phi = load_phi(inp_fol, years, 'pentad', trange)
    land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/flat_10m/input/land.nc'
    land = xr.open_dataset(land_file)
    land_plot = xr.DataArray(land.land_mask.values, [('lat', phi.lat),
                                                     ('lon', phi.lon)])
    pd_dic = pentad_dic(1)

    def plot_gp_var(lev, levels):
        g = phi[:, lev, :, :].plot.contourf(x='lon',
                                            y='lat',
                                            levels=levels,
                                            col='pentad',
                                            col_wrap=5)
        plt.ylim(0, 45)
        plt.xlim(60, 180)
        for i, ax in enumerate(g.axes.flat):
            if not 'aquaplanet' in inp_fol:
                land_plot.plot.contour(x='lon',
                                       y='lat',
                                       levels=np.arange(0., 2., 1.),
                                       colors='k',
                                       add_colorbar=False,
                                       add_labels=False,
                                       ax=ax)
            ax.set_title(pd_dic[trange[0] + i + 1])
        plt.savefig('/scratch/rg419/plots/' + inp_fol + '/pd_phi_' +
                    str(int(phi.pfull[lev].values)) + '.png')
        plt.close()

    plot_gp_var(2, np.arange(1., 1.6, 0.025))
    plot_gp_var(9, np.arange(12., 14.1, 0.1))
예제 #5
0
def plot_pd_mom_fn(inp_fol, years, trange):

    data = mombudg_lev_pd_fn(inp_fol, years, trange)
    land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/topo_10m/input/land.nc'
    land = xr.open_dataset(land_file)
    land_plot = xr.DataArray(land.land_mask.values, [('lat', data.lat),
                                                     ('lon', data.lon)])
    pd_dic = pentad_dic(1)

    def plot_mom_var(var, levels, qscale):
        var_dic = {
            'fv_av': 'fv',
            'mom_eddy': 'Eddy advective terms',
            'mom_mean': 'Mean state advective terms',
            'mom_sum': 'Residual',
            'dphidx_av': 'Geopotential gradient'
        }
        plot_data = data.data_vars[var]
        plot_data = plot_data * 10000.
        g = plot_data.plot.contourf(x='lon',
                                    y='lat',
                                    levels=levels,
                                    col='pentad',
                                    col_wrap=5)
        plt.ylim(-45, 45)
        plt.xlim(60, 180)
        for i, ax in enumerate(g.axes.flat):
            land_plot.plot.contour(x='lon',
                                   y='lat',
                                   levels=np.arange(0., 2., 1.),
                                   colors='k',
                                   add_colorbar=False,
                                   add_labels=False,
                                   ax=ax)
            ax.quiver(data.lon[::3],
                      data.lat[::1],
                      data.u_av[i, ::1, ::3],
                      data.v_av[i, ::1, ::3],
                      scale=qscale,
                      headwidth=5)
            ax.set_title(pd_dic[trange[0] + i + 1])
        plt.savefig('/scratch/rg419/plots/mom_budg_work/' + inp_fol +
                    '/mom_ll_' + var + '.png')
        plt.close()

    vars = ['dphidx_av', 'fv_av', 'mom_eddy', 'mom_mean', 'mom_sum']
    for var in vars:
        plot_mom_var(var, np.arange(-5., 5.1, 0.5), 500.)
예제 #6
0
def plot_pd_mom_fn(inp_fol, nproc, years, trange):

    data = mombudg_2d_pd_fn(inp_fol, nproc, years, trange)
    land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/flat_10m/input/land.nc'
    land = xr.open_dataset(land_file)
    land_plot = xr.DataArray(land.land_mask.values, [('lat', data.lat),
                                                     ('lon', data.lon)])
    pd_dic = pentad_dic(1)

    def plot_mom_var(var, lev, levels, qscale):
        g = data.data_vars[var][:, lev, :, :].plot.contourf(x='lon',
                                                            y='lat',
                                                            levels=levels,
                                                            col='pentad',
                                                            col_wrap=5)
        plt.ylim(0, 45)
        plt.xlim(60, 180)
        for i, ax in enumerate(g.axes.flat):
            if not 'aquaplanet' in inp_fol:
                land_plot.plot.contour(x='lon',
                                       y='lat',
                                       levels=np.arange(0., 2., 1.),
                                       colors='k',
                                       add_colorbar=False,
                                       add_labels=False,
                                       ax=ax)
            ax.quiver(data.lon[::3],
                      data.lat[::1],
                      data.u_av[i, lev, ::1, ::3],
                      data.v_av[i, lev, ::1, ::3],
                      scale=qscale,
                      headwidth=5)
            ax.set_title(pd_dic[trange[0] + i + 1])
        plt.savefig('/scratch/rg419/plots/' + inp_fol + '/pd_' + var + '_' +
                    str(int(data.pfull[lev].values)) + '.png')
        plt.close()

    vars = [
        'dphidx_av', 'fv_av', 'mom_eddy', 'mom_mean', 'ddamp_av', 'mom_sum'
    ]
    for var in vars:
        plot_mom_var(var, 2, np.arange(-0.0003, 0.00031, 0.00003), 250.)
        plot_mom_var(var, 9, np.arange(-0.0005, 0.00051, 0.00005), 500.)
예제 #7
0
def plot_weather(inp_fol, years):

    year = years[0]
    rundata = load_year_xr(inp_fol, year)
    tot_p = xr.DataArray(np.zeros((72, 64, 128, len(years))),
                         [('pentad', range(1, 73)), ('lat', rundata.lat),
                          ('lon', rundata.lon), ('year', years)])
    tsurf = xr.DataArray(np.zeros((72, 64, 128, len(years))),
                         [('pentad', range(1, 73)), ('lat', rundata.lat),
                          ('lon', rundata.lon), ('year', years)])
    #w = xr.DataArray(np.zeros((72,64,128,len(years))), [('pentad', range(1,73) ), ('lat', rundata.lat), ('lon', rundata.lon), ('year', years)])

    if not 'aqua' in inp_fol:
        land_file = '/scratch/rg419/GFDL_model/GFDLmoistModel/exp/topo_10m/input/land.nc'
        land = xr.open_dataset(land_file)
        land_plot = xr.DataArray(land.land_mask.values, [('lat', rundata.lat),
                                                         ('lon', rundata.lon)])

    i = 0
    for year in years:
        print year
        rundata = load_year_xr(inp_fol, year)
        rundata.coords['pentad'] = (rundata.time // 5) - 71
        conv_p = rundata.convection_rain.groupby('pentad').mean(('time'))
        cond_p = rundata.condensation_rain.groupby('pentad').mean(('time'))
        tot_p[:, :, :, i] = (conv_p + cond_p) * 86400
        tsurf[:, :, :, i] = rundata.t_surf.groupby('pentad').mean(('time'))

        #rundata = load_year_xr(inp_fol, year, pinterp=True)
        #rundata.coords['pentad'] = (rundata.time // 5) -71
        #w[:,:,:,i] = rundata.omega[:,3,:,:].groupby('pentad').mean(('time'))

        i = i + 1

    tot_p_clim = tot_p.mean(('year'))
    tsurf_clim = tsurf.mean(('year'))
    #w_clim = w.mean(('year'))

    pd_dic = pentad_dic(1)

    for p in range(0, 72):
        print p
        tot_p_clim[p, 15:64, 21:66].plot.contourf(x='lon',
                                                  y='lat',
                                                  add_labels=False,
                                                  levels=range(0, 31, 3))
        cs = tsurf_clim[p, 15:64,
                        21:66].plot.contour(x='lon',
                                            y='lat',
                                            colors='w',
                                            add_labels=False,
                                            add_colorbar=False,
                                            levels=range(250, 321, 5))
        if not 'aqua' in inp_fol:
            land_plot.plot.contour(x='lon',
                                   y='lat',
                                   levels=np.arange(0., 2., 1.),
                                   colors='w',
                                   add_colorbar=False,
                                   add_labels=False)
        plt.clabel(cs, fontsize=15, inline_spacing=-1, fmt='%1.0f')
        plt.ylim(0, 90)
        plt.xlim(60, 180)
        plt.title(pd_dic[p + 1])
        plt.tight_layout()
        plt.savefig('/scratch/rg419/plots/monsoon_analysis/' + inp_fol +
                    '/rain_and_t' + str(p) + '.png')
        plt.close()