def plot_ilag(en, lag, ilag, lagS=None, ilagS=None, figsize=None):
    """plot the results of lag_en_pipeline, with simulations if given"""
    
    doindv = False
    try:
        _,nindv,_,nfq = ilag.shape
        doindv = True 
    except:
        nfq, nindv = lag.shape[-1], 1
    if figsize is None: figsize=(14,3*nfq)
    fig = plt.figure(figsize=figsize)
    for ifq in range(nfq):
        if not lagS is None:
            lm, ls = lagS[:,:,1,ifq].mean(0), lagS[:,:,1,ifq].std(0)
        for il in range(nindv):
            if nindv < 10:
                ax = plt.subplot(nfq, nindv, il+ifq*nfq+1)
            else:
                ax = plt.subplot(nfq*2, nindv//2+1, il+ifq*nfq+1)
            ax.set_xscale('log')
            ax.set_ylim([-2,2])
            ax.set_xticks([3,6])
            ax.xaxis.set_major_formatter(plt.ScalarFormatter())
            ax.xaxis.set_minor_formatter(plt.NullFormatter())
            ax.errorbar(en, lag[:,1,ifq]/1e3, lag[:,2,ifq]/1e3, fmt='o-', alpha=0.5)
            if doindv:
                ax.errorbar(en, ilag[:,il,1,ifq]/1e3, ilag[:,il,2,ifq]/1e3, fmt='s-')

            # simulations #
            if not lagS is None:
                ax.fill_between(en, (lm-ls)/1e3, (lm+ls)/1e3, alpha=0.3)
                if doindv:
                    ilm, ils = ilagS[:,:,il,1,ifq].mean(0), ilagS[:,:,il,1,ifq].std(0)
                    ax.fill_between(en, (ilm-ils)/1e3, (ilm+ils)/1e3, alpha=0.3)
    plt.tight_layout(pad=0)
Exemplo n.º 2
0
        imshow_grid(mgrid, iz-mz, vmin=-120, vmax=120, cmap='RdBu_r')
        
        # slope
        plt.sca(axarr[2,0])
        plt.text(0.2, 0.9, 'Slope', color='w', ha='center', va='center', transform=axarr[2,0].transAxes)
        imshow_grid(grid, grid['node']['topographic__steepest_slope'], vmin=0, vmax=1.2, cmap='plasma_r')
        
        plt.sca(axarr[2,1])
        imshow_grid(mgrid, mgrid['node']['topographic__steepest_slope'], vmin=0, vmax=1.2, cmap='plasma_r')

        for ni in range(2):
            for nj in range(3):
                axarr[nj,ni].set_aspect('equal')
                axarr[nj,ni].set_xlabel('')
                axarr[nj,ni].set_ylabel('')
                axarr[nj,ni].xaxis.set_major_formatter(plt.NullFormatter())
                axarr[nj,ni].yaxis.set_major_formatter(plt.NullFormatter())
        plt.tight_layout()
        plt.savefig(os.path.join('comparison_figures', model + '.png'), dpi=300)
        #plt.savefig(os.path.join('comparison_figures', model + '.pdf')) # pdfs take about 3 minutes to render and 10 
            

df = pd.DataFrame(outputs).T

output_filepath = ['work', 'WVDP_EWG_STUDY3', 'study3py', 'result_tables', 'calibration', 'sew', 'sew.calibration.summary.csv']
df.to_csv(os.path.join(os.sep, *output_filepath), float_format='%.3e')

#%%
cat_df = pd.DataFrame(cat_diff).T
cat_of = np.sum(np.square(cat_df), axis=1)
#%%
Exemplo n.º 3
0
def AXIS(axis,
         xlabel=None,
         ylabel=None,
         remove_xticks=False,
         remove_yticks=False,
         remove_ticks_all=False,
         tickscolor="k"):
    plt.setp(axis.get_yticklabels(), rotation='vertical',
             fontsize=10)  #,visible=False)
    plt.setp(axis.get_xticklabels(), fontsize=10)

    axis.spines['bottom'].set_color(tickscolor)
    axis.spines['top'].set_color(tickscolor)
    axis.spines['left'].set_color(tickscolor)
    axis.spines['right'].set_color(tickscolor)

    axis.minorticks_on()
    axis.tick_params('both',
                     length=6.5,
                     width=0.7,
                     which='major',
                     direction='in',
                     color=tickscolor,
                     bottom=1,
                     top=1,
                     left=1,
                     right=1)
    axis.tick_params('both',
                     length=3.5,
                     width=0.7,
                     which='minor',
                     direction='in',
                     color=tickscolor,
                     bottom=1,
                     top=1,
                     left=1,
                     right=1)

    axis.tick_params(axis='x', colors='k', pad=1)
    axis.tick_params(axis='y', colors='k', pad=1)
    axis.tick_params(axis='both', direction='in', color=tickscolor)

    axis.xaxis.major.locator.set_params(nbins=3)
    axis.yaxis.major.locator.set_params(nbins=3)

    if xlabel != None:
        axis.set_xlabel('%s' % ylabel, fontsize=10)

    if ylabel != None:
        axis.set_xlabel('%s' % xlabel, fontsize=10)

    #
    # Remove x,y label ticks
    #
    if remove_xticks == True:
        axis.xaxis.set_major_formatter(plt.NullFormatter())

    if remove_yticks == True:
        axis.yaxis.set_major_formatter(plt.NullFormatter())

    # remove all from the axis (both ticks and xy ticks labels)

    if remove_ticks_all == True:
        axis.yaxis.set_major_locator(plt.NullLocator())
        axis.xaxis.set_major_locator(plt.NullLocator())

    axis.set_facecolor('#e8ebf2')
Exemplo n.º 4
0
        for p in range(0, 16):
            gs = gridspec.GridSpec(6, 1)

            res_dir = database_dir + '/' + d  # e.g. /raid8/srvx1/federico/odb_netCDF/$New_Results/1759/
            res_name = os.listdir(res_dir)[0].replace('u.nc', '').replace(
                'v.nc', '').replace('t.nc', '')

            ax0 = plt.subplot(gs[0])

            netCDF_file = netCDF(database_dir, d, res_name, hour=h, plevel=p)
            netCDF_file.load()

            Plot = Plotter(netCDF_file, var='temp')
            Plot.plotter(out_dir=out_dir, save=False, xlabel=False)
            plt.tight_layout()
            ax0.xaxis.set_major_formatter(plt.NullFormatter())

            ax1 = plt.subplot(gs[1])
            netCDF_file.load()
            Plot = Plotter(netCDF_file, var='uwind')
            Plot.plotter(out_dir=out_dir, save=False, xlabel=False)
            plt.tight_layout()
            ax1.xaxis.set_major_formatter(plt.NullFormatter())

            ax2 = plt.subplot(gs[2])
            netCDF_file.load()
            Plot = Plotter(netCDF_file, var='vwind')
            Plot.plotter(out_dir=out_dir, save=False, xlabel=False)
            plt.tight_layout()
            ax2.xaxis.set_major_formatter(plt.NullFormatter())