Esempio n. 1
0
def main(test, hours=24):
    inifiles = _get_files(
        '/home/okada/ism-i/apps/OB500P/testDA/{}/output/ob500_ini_*.nc'.format(
            test),
        hours=hours)
    figfile = '/home/okada/Dropbox/Figures/2016_param/tplot_param_{}.png'.format(
        test)
    if test == 'param2':
        fig, ax = plt.subplots(2, 1)
        tplot_param(inifiles, 'P01', ax=ax[0])
        tplot_param(inifiles, 'P04', ax=ax[1])
        ax[0].set_title('4dvar(ini+param), window=1day, pfactor=0.1')
    elif 'param3' in test:
        ax = _plot6(inifiles)
        pfactor = _get_pfactor(test)
        ax[0].set_title(
            '4dvar(ini+param), window=1day, pfactor={}'.format(pfactor))
    elif 'param4' in test:
        ax = _plot6(inifiles)
        pfactor = _get_pfactor(test)
        ax[0].set_title(
            '4dvar(param), window=1day, pfactor={}'.format(pfactor))
    elif 'param5' in test:
        ax = _plot6(inifiles)
        pfactor = '*'
        ax[0].set_title(
            '4dvar(ini+param), window=1day, pfactor={}'.format(pfactor))
    elif 'param6' in test:
        ax = _plot6(inifiles)
        pfactor = '*'
        ax[0].set_title(
            '4dvar(param), window=7day, pfactor={}'.format(pfactor))
    romspy.savefig(figfile)
Esempio n. 2
0
def main(test):
    if test == 'param2':
        inifiles = ['/home/okada/ism-i/apps/OB500P/testDA/{}/output/ob500_ini_{}.nc'.format(test, i) for i in range(0,8712,24)]
        title = '4dvar(ini+param), window=1day, pfactor=0.1'
        for vid in [1,4]:
            vname = 'P{:02d}'.format(vid)
            figfile = '/home/okada/Dropbox/Figures/2016_param/plot_pdf_param_{test}_{vname}.png'.format(**locals())
            plt.cla()
            plot_pdf_param(inifiles, vname)
            plt.title(title)
            romspy.savefig(figfile)
Esempio n. 3
0
def main(test):
    if test == 'param2':
        inifiles = [
            '/home/okada/ism-i/apps/OB500P/testDA/{}/output/ob500_ini_{}.nc'.
            format(test, i) for i in range(0, 8712, 24)
        ]
        title = '4dvar(ini+param), window=1day, pfactor=0.1'
        for vid in [1, 4]:
            vname = 'P{:02d}'.format(vid)
            figfile = '/home/okada/Dropbox/Figures/2016_param/plot_pdf_param_{test}_{vname}.png'.format(
                **locals())
            plt.cla()
            plot_pdf_param(inifiles, vname)
            plt.title(title)
            romspy.savefig(figfile)
Esempio n. 4
0
def _plot_col(df, vname, fname, title):
    if vname == 'temp':
        vmin, vmax = 0, 35
    elif vname == 'DO':
        vmin, vmax = 0, 12
    elif vname == 'COD':
        vmin, vmax = 0, 12
    plt.figure(figsize=(6, 6))
    plt.scatter(df[vname].values, df.ts.values, alpha=0.5)
    plt.plot([vmin, vmax], [vmin, vmax], 'k-', alpha=0.5)
    plt.xlim(vmin, vmax)
    plt.ylim(vmin, vmax)
    plt.xlabel('observations')
    plt.ylabel('trend+seasonal')
    plt.title(title)
    col_png = fname + '_col.png'
    sk._mkdir(col_png)
    romspy.savefig(col_png)
Esempio n. 5
0
def plot_stations(stafile):
    df = _read_stations(stafile)
    plt.figure(figsize=(8,8))
    plt.scatter(df.lon.values, df.lat.values)
    for i in df.index:
        #plt.text(df.lon[i], df.lat[i], df.id[i], backgroundcolor='w')
        plt.annotate(str(df.id[i]), xy=(df.lon[i], df.lat[i]), 
                xycoords='data',
                xytext=(df.lon[i]-0.025, df.lat[i]+0.015), 
                #textcoords='offset points',
                arrowprops=dict(arrowstyle="-")
                )
    romspy.basemap(mapfile)
    plt.gca().patch.set_facecolor('gray')
    plt.gca().patch.set_alpha(0.2)
    pngfile = stafile.replace('csv', 'png')
    romspy.savefig(pngfile)
    plt.show()
Esempio n. 6
0
def _plot_col(df, vname, fname, title):
    if vname == 'temp':
        vmin, vmax = 0, 35
    elif vname == 'DO':
        vmin, vmax = 0, 12
    elif vname == 'COD':
        vmin, vmax = 0, 12
    plt.figure(figsize=(6,6))
    plt.scatter(df[vname].values, df.ts.values, alpha=0.5)
    plt.plot([vmin,vmax], [vmin,vmax], 'k-', alpha=0.5)
    plt.xlim(vmin, vmax)
    plt.ylim(vmin, vmax)
    plt.xlabel('observations')
    plt.ylabel('trend+seasonal')
    plt.title(title)
    col_png = fname+'_col.png'
    sk._mkdir(col_png)
    romspy.savefig(col_png)
Esempio n. 7
0
def plot_osaka():
    plt.figure(figsize=(15,10))
    plt.subplot(2,3,1)
    plots(3)
    plt.subplot(2,3,2)
    plots(4)
    plt.subplot(2,3,3)
    plots2(5)
    plt.subplot(2,3,4)
    plots(6)
    plt.subplot(2,3,5)
    plots(12)
    plt.subplot(2,3,6)
    plots(13)

    import romspy
    plt.suptitle('osaka, 2012')
    romspy.savefig('F:/okada/Dropbox/Figures/analysis_mp/osaka2012_light_chlo.png')
Esempio n. 8
0
def plot_stations(stafile):
    df = _read_stations(stafile)
    plt.figure(figsize=(8, 8))
    plt.scatter(df.lon.values, df.lat.values)
    for i in df.index:
        #plt.text(df.lon[i], df.lat[i], df.id[i], backgroundcolor='w')
        plt.annotate(
            str(df.id[i]),
            xy=(df.lon[i], df.lat[i]),
            xycoords='data',
            xytext=(df.lon[i] - 0.025, df.lat[i] + 0.015),
            #textcoords='offset points',
            arrowprops=dict(arrowstyle="-"))
    romspy.basemap(mapfile)
    plt.gca().patch.set_facecolor('gray')
    plt.gca().patch.set_alpha(0.2)
    pngfile = stafile.replace('csv', 'png')
    romspy.savefig(pngfile)
    plt.show()
Esempio n. 9
0
    resample = 'H'

# outpt directories
outdir = os.path.dirname(modfiles[0]).replace('ism-i/apps', 'Dropbox/Figures')
outdir = outdir.replace('/output', '')
if not os.path.exists(outdir):
    print 'mkdir', outdir
    os.makedirs(outdir)

# plot cost functions
if plot_cost:
    romspy.plot_cost(modfiles, Ninner)
    outfile = os.path.join(outdir, plot_costfile)
    print outfile
    plt.suptitle(case)
    romspy.savefig(outfile)

# plot time series of mod files
assimilation = True
if tplot_valification:
    for varid in varids:
        fig, axes = plt.subplots(3, 2, figsize=[12, 12])
        axlist = [axes[y][x] for x in range(2) for y in range(3)]
        for station, ax in zip(stations, axlist):
            romspy.tplot_valification(obsfile,
                                      modfile,
                                      varid,
                                      station,
                                      dates,
                                      assimilation=assimilation,
                                      ax=ax,
Esempio n. 10
0
        ax[1].scatter(mod_value, obs_value)

    for i in range(2):
        ax[i].plot([0,100], [0,100], 'k-', alpha=0.5)
        ax[i].set_xlabel('Model')
        ax[i].set_xlim(lim)
        ax[i].set_ylim(lim)
    ax[0].set_ylabel('Observation')
    ax[0].set_title('Background')
    ax[1].set_title('Assimilation')
    plt.suptitle(title)

if __name__ == '__main__':
    #import seaborn as sns
    romspy.cmap('jet')

    case = 'case28/DA0-3.1'

    varids = [6,7,10,15]
    #varids = [6,7]
    #varids = [6]
    obsfile = '/home/okada/Data/ob500_obs_2012_mp-2.nc'
    #obsfile = '/home/okada/Data/ob500_obs_2012_mp-1_ts.nc'
    #modfile = '/home/okada/ism-i/apps/OB500P/{}/output/ob500_mod_0.nc'.format(case)
    modfiles = ['/home/okada/ism-i/apps/OB500P/{}/output/ob500_mod_{}.nc'.format(case, i*24) for i in range(0,7)]

    for varid in varids:
        tplot_rmse(obsfile, modfiles, varid)
        #plt.show()
        romspy.savefig('/home/okada/Dropbox/Figures/OB500P/{}/tplot_rmse_{}.png'.format(case, varid))
Esempio n. 11
0
    resample = 'H'

# outpt directories
outdir = os.path.dirname(modfiles[0]).replace('ism-i/apps', 'Dropbox/Figures')
outdir = outdir.replace('/output', '')
if not os.path.exists(outdir):
    print 'mkdir', outdir
    os.makedirs(outdir)

# plot cost functions
if plot_cost:
    romspy.plot_cost(modfiles, Ninner)
    outfile = os.path.join(outdir, plot_costfile)
    print outfile
    plt.suptitle(case)
    romspy.savefig(outfile)

# plot time series of mod files
assimilation = True
if tplot_valification:
    for varid in varids:
        fig, axes = plt.subplots(3,2, figsize=[12,12])
        axlist = [axes[y][x] for x in range(2) for y in range(3)]
        for station, ax in zip(stations, axlist):
            romspy.tplot_valification(obsfile, modfile, varid, station, dates, assimilation=assimilation, ax=ax, date_format=date_format, resample=resample)
            if varid == 6:
                ax.set_ylim(5, 30)
            elif varid == 7:
                ax.set_ylim(23, 33)
            elif varid == 10:
                ax.set_ylim(0, 30)
Esempio n. 12
0
        ax[i].plot([0,100], [0,100], 'k-', alpha=0.5)
        ax[i].set_xlabel('Model')
        ax[i].set_xlim(lim)
        ax[i].set_ylim(lim)
    ax[0].set_ylabel('Observation')
    ax[0].set_title('Background')
    ax[1].set_title('Assimilation')
    plt.suptitle(title)

if __name__ == '__main__':
    #import seaborn as sns
    romspy.cmap('jet')

    case = 'case28/DA0-3.1'

    #how = 'scatter2d'
    how = 'scatter2d_gaussian'
    #how = 'hist2d'
    varids = [6,7,10,15]
    #varids = [6,7]
    #varids = [6]
    obsfile = '/home/okada/Data/ob500_obs_2012_mp-2.nc'
    #obsfile = '/home/okada/Data/ob500_obs_2012_mp-1_ts.nc'
    #modfile = '/home/okada/ism-i/apps/OB500P/{}/output/ob500_mod_0.nc'.format(case)
    modfiles = ['/home/okada/ism-i/apps/OB500P/{}/output/ob500_mod_{}.nc'.format(case, i*24) for i in range(0,7)]

    for varid in varids:
        plot_hist2d(obsfile, modfiles, varid, how)
        #plt.show()
        romspy.savefig('/home/okada/Dropbox/Figures/OB500P/{}/{}_{}.png'.format(case, how, varid))