Example #1
0
dataBox = list()
caseLst = ['Predict'] + [str(nd) + 'd Forcast' for nd in fLst]
for k in range(len(keyLst)):
    key = keyLst[k]
    temp = list()
    data = statP[key]
    temp.append(data)
    print(key, np.nanmedian(statP[key]))
    print(key, np.nanmedian(statF[key]))
    for i in range(len(fLst)):
        data = statLstF[i][key]
        temp.append(data)
        # print(key, np.nanmedian(data))
    dataBox.append(temp)
plt.tight_layout()
fig = plot.plotBoxFig(dataBox, keyLst, caseLst, sharey=False, figsize=[8, 3])
fig.show()
fig.savefig(os.path.join(saveDir, 'box_forecast'))

# plot maps forecast_days
keyLst = ['RMSE', 'Corr']
cRangeLst = [[0, 0.05], [0.7, 1]]
[lat, lon] = df.getGeo()
fig, axes = plt.subplots(len(fLst), len(keyLst), figsize=[8, 6])
for i in range(len(keyLst)):
    key = keyLst[i]
    cRange = cRangeLst[i]
    for j in range(len(fLst)):
        data = statLstF[j][key]
        titleStr = key + ' of {}d Forecast'.format(fLst[j])
        grid, uy, ux = utils.grid.array2grid(data, lat=lat, lon=lon)
Example #2
0
dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statDictLst)):
        data = statDictLst[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
# plt.style.use('classic')
plt.rcParams['font.size'] = 16
plt.rcParams['font.family'] = 'Times New Roman'
# plt.rcParams['mathtext.fontset'] = 'cm'
# # fig = plt.figure(figsize=(8, 5), tight_layout=True)
fig = plot.plotBoxFig(dataBox,
                      keyLst, ['LSTM', 'DA-1', 'DA-3', 'DA-7'],
                      sharey=False,
                      title='Dataset: HUC-' + str(HUCid))
fig.patch.set_facecolor('white')
fig.show()
# plt.savefig(pathCamels['Out'] + '/' + save_path + "/boxstat.png", dpi=500)

# # plot time series
# plt.rcParams['font.size'] = 13
# plt.rcParams['font.family'] = 'Times New Roman'
# t = utils.time.tRange2Array(tRange)
# npub = len(subset)
# fig, axes = plt.subplots(npub, 1, figsize=(16, 14))
# for k in range(npub):
#     # iGrid = np.random.randint(0, 671)
#     # iGrid = np.random.randint(0, len(subset))
#     iGrid = k
Example #3
0
# plot box - latency
# if 'post' in doLst:
caseLst = ['Predict'] + ['Nowcast ' + str(nd) + 'd latency' for nd in dLst]
statLst1 = [stat.statError(x, obs) for x in predLst]
keyLst = list(statLst1[0].keys())
dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statLst1)):
        data = statLst1[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
fig = plot.plotBoxFig(dataBox, keyLst, caseLst, sharey=False)
fig.show()
fig.savefig(os.path.join(saveDir, 'box_latency'))

# figure out how many days observation lead
maskObs = 1 * ~np.isnan(obs.squeeze())
maskDay = np.zeros(maskObs.shape).astype(int)
ngrid, nt = maskObs.shape
for j in range(ngrid):
    temp = 0
    for i in range(nt):
        maskDay[j, i] = temp
        if maskObs[j, i] == 1:
            temp = 1
        else:
            if temp != 0:
Example #4
0
fig.show()

indLst = [
    cropRate[:, 0] > 2, cropRate[:, 4] > 2, cropRate[:, 22] > 2,
    cropRate[:, 23] > 2
]
dataBox = list()
for iC in range(len(indLst)):
    tempLst = list()
    for k in range(4):
        data = statPLst[k]['RMSE'][indLst[iC]] - statFLst[k]['RMSE'][
            indLst[iC]]
        tempLst.append(data)
        print(key, k, np.nanmedian(data))
    dataBox.append(tempLst)
fig = plot.plotBoxFig(dataBox, sharey=True, figsize=[8, 3])
plt.tight_layout()
fig.show()

# plot time series
indLst = [1023]
strLst = ['east Texas']
tBar = [utils.time.t2dt(20160401)]
t = df.getT()
[lat, lon] = df.getGeo()
prcp = df.getDataTs('APCP_FORA')
tsNameLst = ['obs', 'prj', 'fore']
for k in range(len(indLst)):
    fig, axes = plt.subplots(2, 1, figsize=[16, 6])
    ind = indLst[k]
    titleStr = 'typical {} pixel, lat {:.3}, lon {:.3}'.format(
Example #5
0
        testName = subsetLst[kc - 1]
        if k != kc:
            outName = 'ecoRegion{:02d}{:02d}_v2f1_Forcing'.format(kc, k)
        else:
            outName = 'ecoRegion{:02d}_v2f1_Forcing'.format(kc)
        out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegion', outName)
        df, yp, yt = master.test(out, tRange=tRange, subset=testName)
        temp = stat.statError(yp[:, :, 0], yt[:, :, 0])
        tempLst.append(temp)
        if k == kc:
            statRefLst.append(temp)
    statLst.append(tempLst)

# %% plot box
keyLst = stat.keyLst
ecoLst = ['{:02d}'.format(x) for x in range(1, 18)]
caseLst = ['{:02d}'.format(x) for x in [7, 8, 13]]

for k in range(len(caseLst)):
    dataBox = list()
    key = 'RMSE'
    for ii in range(len(ecoLst)):
        temp = list()
        temp.append(statLst[k][ii][key] - statRefLst[k][key])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox, ecoLst, caseLst, title=key, figsize=(12, 4))
    plt.subplots_adjust(wspace=0, hspace=0)
    fig.show()
    saveFile = os.path.join(saveFolder, 'ecoRegionComb_box_' + str(caseLst[k]))
    fig.savefig(saveFile)
Example #6
0
if 'post' in doLst:
    # stat
    ypLst = [ypLstmLst, ypAnnLst]
    statDictLst = list()
    for i in range(0, len(ypLst)):
        tempLst = list()
        for j in range(0, len(ypLst[i])):
            tempLst.append(stat.statError(ypLst[i][j], yT))
        statDictLst.append(tempLst)
    keyLst = list(tempLst[0].keys())

    # plot box
    dataBox = list()
    caseLst1 = keyLst
    caseLst2 = ['LSTM', 'LSTM-DA']
    for iS in range(len(keyLst)):
        statStr = keyLst[iS]
        dataBox = list()
        for iS in range(len(keyLst)):
            statStr = keyLst[iS]
            temp = list()
            for k in range(len(statDictLst)):
                temp.append(statDictLst[k][statStr])
            dataBox.append(temp)
        fig = plot.plotBoxFig(dataBox,
                              caseLst1,
                              caseLst2,
                              sharey=True,
                              title=statStr)
        fig.show()
Example #7
0
                outName = 'Global_v4f1_y1' + '_' + case2
            out = os.path.join(pathSMAP['Out_L3_Global'], outName)
            df, yp, yt = master.test(out,
                                     tRange=yrLst,
                                     subset=testName,
                                     epoch=500)
            temp = stat.statError(yp[:, :, 0], yt[:, :, 0])
            tempLst.append(temp)
    statLst.append(tempLst)

# plot box
keyLst = stat.keyLst
caseLst = list()
for case1 in caseLst1:
    for case2 in caseLst2:
        caseLst.append(case1 + ' ' + case2)

for k in range(len(keyLst)):
    dataBox = list()
    key = keyLst[k]
    for ss in statLst:
        temp = list()
        for s in ss:
            temp.append(s[key])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox, contLst, caseLst, title=key)
    fig.show()

# fig = plot.plotBoxFig(dataBox, keyLst, caseLst, sharey=False)
# fig.show()
# fig.savefig(os.path.join(saveDir, 'box_forecast'))
Example #8
0
    stat.statError(yp1, yt2),
    stat.statError(yp2, yt2),
    stat.statError(yp3, yt2)
]
keyLst = list(statDictLst[0].keys())

dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statDictLst)):
        data = statDictLst[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
fig = plot.plotBoxFig(dataBox, keyLst, ['LSTM', 'DA-1', 'DA-7'], sharey=False)
fig.show()

# plot time series
t = utils.time.tRange2Array([20050101, 20150101])
fig, axes = plt.subplots(5, 1, figsize=(12, 8))
# iLst = [54, 219, 298, 325, 408]
for k in range(5):
    iGrid = np.random.randint(0, 671)
    # iGrid = iLst[k]
    yPlot = list()
    for y in yLst:
        yPlot.append(y[iGrid, :])
    if k == 0:
        plot.plotTS(
            t,
Example #9
0
plot.plotMap(grid, ax=axes[1], lat=uy, lon=ux, cRange=[0, 10])
fig.show()

indLst = [cropRate[:, 0] > 20, cropRate[:, 22] > 5, cropRate[:, 23] > 10]
labMonth = [
    'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Agu', 'Sep', 'Oct',
    'Nov', 'Dec'
]
labCrop = ['Corn', 'Spring wheat', 'Winter wheat']
dataBox = list()
for k in range(12):
    tempLst = list()
    for iC in range(len(indLst)):
        data = statPLst[k]['RMSE'][indLst[iC]] - statFLst[k]['RMSE'][
            indLst[iC]]
        if len(data[~np.isnan(data)]) < 20:
            data = None
        tempLst.append(data)
    dataBox.append(tempLst)
fig = plot.plotBoxFig(dataBox,
                      label1=labMonth,
                      label2=labCrop,
                      sharey=True,
                      figsize=[8, 3],
                      colorLst='rgb')
plt.tight_layout()
plt.subplots_adjust(wspace=0, hspace=0)
plt.ylim(-0.02, 0.04)
fig.show()
fig.savefig(os.path.join(saveDir, 'box_month'))
Example #10
0
    'Nov', 'Dec'
]
labCrop = ['Corn', 'Spring wheat', 'Winter wheat', 'Rice']
dataBox = list()
for k in range(12):
    tempLst = list()
    for iC in range(len(indLst)):
        data = statPLst[k]['RMSE'][indLst[iC]] - statFLst[k]['RMSE'][
            indLst[iC]]
        if len(data[~np.isnan(data)]) < 20:
            data = None
        tempLst.append(data)
    dataBox.append(tempLst)
fig = plot.plotBoxFig(dataBox,
                      label1=labMonth,
                      label2=None,
                      sharey=True,
                      figsize=[8, 3],
                      colorLst='rgbk')
plt.tight_layout()
plt.subplots_adjust(wspace=0, hspace=0)
plt.ylim(-0.02, 0.04)
fig.show()
fig.savefig(os.path.join(saveDir, 'box_crop.eps'))
fig.savefig(os.path.join(saveDir, 'box_crop.png'))

fig = plot.plotBoxFig(dataBox[10:11],
                      label1=labMonth[10:11],
                      label2=labCrop,
                      sharey=True,
                      figsize=[8, 3],
                      colorLst='rgbk',
matplotlib.rcParams.update({'lines.markersize': 12})
matplotlib.rcParams.update({'legend.fontsize': 11})
keyLst = stat.keyLst
keyLegLst = ['Bias', 'RMSE', 'ubRMSE', 'R']
dataBox = list()
caseLst = ['Project'] + [str(nd) + 'd Forecast' for nd in fLst]
for k in range(len(keyLst)):
    key = keyLst[k]
    temp = list()
    data = statP[key]
    temp.append(data)
    for i in range(len(fLst)):
        data = statLstF[i][key]
        temp.append(data)
    dataBox.append(temp)
fig = plot.plotBoxFig(dataBox, keyLegLst, sharey=False, figsize=[8, 4])
plt.suptitle('Error metrics of projection and forecast model')
plt.tight_layout()
plt.subplots_adjust(top=0.85, right=0.95)
fig.show()
fig.savefig(os.path.join(saveDir, 'box_forecast_RK.eps'))
fig.savefig(os.path.join(saveDir, 'box_forecast_RK.png'))

[np.nanmean(dataBox[1][1]), np.nanmean(
    dataBox[1][2]), np.nanmean(dataBox[1][3])]

# fig = plot.plotBoxFig(
#     dataBox, keyLst, caseLst, sharey=False, figsize=[8, 3], legOnly=True)
# # plt.suptitle('Error matrices of project and forecast model')
# plt.tight_layout()
# fig.show()
Example #12
0
        outName = subsetPattern.format(case) + '_Forcing'
        out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegionL3', outName)
        df, yp, yt = master.test(out, tRange=tRange, subset=testName)
        errLst.append(stat.statError(yp[:, :, 0], yt[:, :, 0]))

    # plot box
    keyLst = stat.keyLst
    dataBox = list()
    for key in keyLst:
        temp = list()
        for err in errLst:
            temp.append(err[key])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox,
                          keyLst,
                          caseLst,
                          title=caseLst[0],
                          figsize=(12, 4),
                          sharey=False)
    # plt.subplots_adjust(wspace=0, hspace=0)
    fig.show()
    saveFile = os.path.join(saveFolder, 'case_' + caseLst[0])
    fig.savefig(saveFile)

    # plot maps
    cLst = 'rbkgcmy'
    nCase = len(caseLst)
    fig, ax = plt.subplots(figsize=(8, 4))
    data = np.tile(np.array(to_rgb('lightgrey')), (latC.shape[0], 1))
    for k in range(1, nCase):
        case = caseLst[k]
        subsetLst = [subsetPattern.format(x) for x in case.split('+')]
Example #13
0
import matplotlib
matplotlib.rcParams.update({'font.size': 14})
matplotlib.rcParams.update({'lines.linewidth': 2})
matplotlib.rcParams.update({'lines.markersize': 6})
indLst = [cropRate[:, 0] > 30, cropRate[:, 22] > 5, cropRate[:, 23] > 10]
labMonth = [
    'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Agu', 'Sep', 'Oct',
    'Nov', 'Dec'
]
labCrop = ['Corn', 'Spring wheat', 'Winter wheat']
cLst = 'rgb'
dataBox = list()
for iC in range(len(indLst)):
    dataBox = list()
    for k in range(12):
        data = statPLst[k]['RMSE'][indLst[iC]] - statFLst[k]['RMSE'][
            indLst[iC]]
        if len(data[~np.isnan(data)]) < 20:
            data = []
        dataBox.append(data)
    fig = plot.plotBoxFig(dataBox,
                          label1=labMonth,
                          label2=[labCrop[iC]],
                          sharey=True,
                          figsize=[8, 3],
                          colorLst=cLst[iC])
    plt.subplots_adjust(wspace=0, hspace=0)
    plt.ylim(-0.02, 0.04)
    fig.show()
Example #14
0
        ypLst.append(
            dbCsv.transNorm(yP,
                            rootDB=rootDB,
                            fieldName='SMAP_AM',
                            fromRaw=False))

if 'post' in doLst:
    statDictLst = list()
    for k in range(0, len(ypLst)):
        statDictLst.append(stat.statError(ypLst[k], yT))
    keyLst = ['RMSE', 'ubRMSE', 'Bias', 'Corr']
    caseLst = ['LSTM']
    for k in dLst:
        caseLst.append('DA-' + str(k))

    # plot box
    dataBox = list()
    cmap = plt.cm.jet
    cLst = cmap(np.linspace(0, 1, len(caseLst)))
    for iS in range(len(keyLst)):
        statStr = keyLst[iS]
        temp = list()
        for k in range(len(statDictLst)):
            temp.append(statDictLst[k][statStr])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox,
                          keyLst,
                          caseLst,
                          sharey=False,
                          colorLst=cLst)
    fig.show()
Example #15
0
        out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegionCase', outName)
        df, yp, yt = master.test(out, tRange=tRange, subset=testName)
        errLst.append(stat.statError(yp[:, :, 0], yt[:, :, 0]))

    # plot box
    cLst = 'ygbr'
    keyLst = ['RMSE', 'Corr']
    dataBox = list()
    for key in keyLst:
        temp = list()
        for err in errLst:
            temp.append(err[key])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox,
                          '  ',
                          figsize=(8, 6),
                          colorLst=cLst,
                          sharey=False)
    # plt.subplots_adjust(wspace=0, hspace=0)
    plt.tight_layout()
    fig.show()
    saveFile = os.path.join(saveFolder, 'case_{}_box'.format(case))
    fig.savefig(saveFile)

# plot box
cLst = 'ygbr'
keyLst = ['Corr', 'RMSE']
dataBox = list()
for key in keyLst:
    temp = list()
    for err in errLst:
Example #16
0
keyLst = ['Bias', 'RMSE', 'NSE']
dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statDictLst)):
        data = statDictLst[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
# plt.style.use('classic')
plt.rcParams['font.size'] = 16
plt.rcParams['font.family'] = 'Times New Roman'
# plt.rcParams['mathtext.fontset'] = 'cm'
# # fig = plt.figure(figsize=(8, 5), tight_layout=True)
fig = plot.plotBoxFig(dataBox, keyLst, sharey=False)
fig.patch.set_facecolor('white')
fig.show()
# plt.savefig(pathCamels['Out'] + '/' + save_path + "/boxstat_within30.png", dpi=500)

# plot only NSE box
keyLst = ['NSE']
dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statDictLst)):
        data = statDictLst[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
Example #17
0
# axes[1].plot(corrLst0, corrLst1, '*')
# fig.show()

# plot box
keyLst = ['RMSE', 'Corr']
# ecoLst = ['{0:0>2}'.format(x) for x in range(1, 18)]
ecoLst = 'ABDEFGHIJKLMNOPQR'
matplotlib.rcParams.update({'font.size': 16})
matplotlib.rcParams.update({'lines.linewidth': 2})
matplotlib.rcParams.update({'lines.markersize': 10})
for k in range(len(keyLst)):
    dataBox = list()
    key = keyLst[k]
    for ss in statLst:
        temp = list()
        for s in ss:
            temp.append(s[key])
        dataBox.append(temp)
    if key == 'RMSE':
        fig = plot.plotBoxFig(dataBox,
                              ecoLst,
                              caseLst1,
                              widths=0.5,
                              figsize=(12, 4))
    else:
        fig = plot.plotBoxFig(dataBox, ecoLst, widths=0.5, figsize=(12, 4))
    plt.subplots_adjust(wspace=0, hspace=0)
    fig.show()
    saveFile = os.path.join(saveFolder, 'ecoRegion_box_' + key)
    fig.savefig(saveFile)
Example #18
0
matplotlib.rcParams.update({'lines.markersize': 12})
matplotlib.rcParams.update({'legend.fontsize': 11})
keyLst = stat.keyLst
keyLegLst = ['Bias', 'RMSE', 'ubRMSE', 'R']
dataBox = list()
caseLst = ['Project'] + [str(nd) + 'd Forecast' for nd in fLst]
for k in range(len(keyLst)):
    key = keyLst[k]
    temp = list()
    data = statP[key]
    temp.append(data)
    for i in range(len(fLst)):
        data = statLstF[i][key]
        temp.append(data)
    dataBox.append(temp)
fig = plot.plotBoxFig(dataBox, keyLegLst, sharey=False, figsize=[8, 4])
plt.suptitle('Error metrics of projection and forecast model')
plt.tight_layout()
plt.subplots_adjust(top=0.85, right=0.95)
fig.show()
fig.savefig(os.path.join(saveDir, 'box_forecast.eps'))
fig.savefig(os.path.join(saveDir, 'box_forecast.png'))

fig = plot.plotBoxFig(dataBox,
                      keyLst,
                      caseLst,
                      sharey=False,
                      figsize=[8, 3],
                      legOnly=True)
# plt.suptitle('Error matrices of project and forecast model')
plt.tight_layout()
Example #19
0
        errLst.append(err)
    errLstAll.append(errLst)

# plot box
cLst = 'ygbr'
keyLst = ['RMSE', 'Corr']
for key in keyLst:
    dataBox = list()
    for errLst in errLstAll:
        temp = list()
        for err in errLst:
            temp.append(err[key])
        dataBox.append(temp)
    fig = plot.plotBoxFig(dataBox,
                          caseLabLst,
                          colorLst=cLst,
                          figsize=(12, 4),
                          sharey=True)
    plt.tight_layout()
    plt.subplots_adjust(wspace=0, hspace=0)
    fig.show()
    saveFile = os.path.join(saveFolder, 'sim_box_lim_{}'.format(key))
    fig.savefig(saveFile)

# plot box
cLst = 'ygbr'
keyLst = ['Corr', 'RMSE']
dataBox = list()
for key in keyLst:
    temp = list()
    for err in errLst:
Example #20
0
        temp.append(data)
    dataBox.append(temp)
# plt.style.use('classic')
plt.rcParams['font.size'] = 14
plt.rcParams['font.family'] = 'Times New Roman'
plt.rcParams["legend.columnspacing"] = 0.1
plt.rcParams["legend.handletextpad"] = 0.2
labelname = ['LSTM']
for nDay in nDayLst:
    labelname.append('DA-' + str(nDay) + 'M')
xlabel = [
    'Bias ($\mathregular{ft^3}$/s)', 'RMSE ($\mathregular{ft^3}$/s)', 'NSE'
]
fig = plot.plotBoxFig(dataBox,
                      xlabel,
                      labelname,
                      sharey=False,
                      figsize=(10, 5))
fig.patch.set_facecolor('white')
fig.show()
plt.savefig(pathCamels['Out'] + '/' + save_path + "/boxstat_0625.png", dpi=600)

# # plot time series
# plt.rcParams['font.size'] = 13
# plt.rcParams['font.family'] = 'Times New Roman'
# t = utils.time.tRange2Array(tRange)
# fig, axes = plt.subplots(5, 1, figsize=(12, 8))
# for k in range(5):
#     iGrid = np.random.randint(0, 671)
#     yPlot = [obs[iGrid, :]]
#     for y in predLst:
Example #21
0
xLst = ['{}d Forecast'.format(x) for x in fLst]
key = 'RMSE'
dataBox = list()
for i in range(len(statLst)):
    ss = statLst[i]
    RKrmse = RKrmseMat[:, i]
    ind = np.where(~np.isnan(RKrmse))[0]
    temp = list()
    for s in ss:
        temp.append(s[key][ind])
    temp.append(RKrmse[ind])
    dataBox.append(temp)
fig = plot.plotBoxFig(
    dataBox,
    xLst,
    None,
    sharey=True,
    figsize=[6, 4],
    title='RMSE of forecast models using different training set')
fig.show()
fig.savefig(os.path.join(saveDir, 'compareRK.eps'))
fig.savefig(os.path.join(saveDir, 'compareRK.png'))

importlib.reload(plot)
fig = plot.plotBoxFig(dataBox,
                      xLst,
                      caseLst,
                      sharey=True,
                      figsize=[8, 4],
                      legOnly=True)
fig.show()
Example #22
0

if 'plotBox' in doLst:
    for grp in grpLst:
        grpCodeLst = codePdf[codePdf['group'] == grp].index.tolist()
        dataBox = list()
        for code in grpCodeLst:
            ind = dictData['varC'].index(code)
            # temp = [[npf['matRmse1'][:, ind], npf['matRmse2'][:, ind]] for npf in npfLst]
            temp = [[npf['matRho1'][:, ind], npf['matRho2'][:, ind]]
                    for npf in npfLst]
            dataBox.append([item for sublist in temp for item in sublist])
        legLst = [item for sublist in [[s+'_train', s+'_test']
                                       for s in modelLst] for item in sublist]
        labLst = codePdf[codePdf['group'] == grp]['shortName'].tolist()
        fig = plot.plotBoxFig(dataBox, label1=labLst,
                              label2=legLst, sharey=False)
        fig.show()

if 'plotTsMap' in doLst:
    # plot map
    iCLst = [0, 11]
    tempLst = [npfLst[0]['matRmse2'][:, iC] for iC in iCLst]
    temp = np.sum(tempLst, axis=0)

    indG = np.where(~np.isnan(temp))[0].tolist()
    npf = npfLst[0]
    dataLst = [npf['matRmse2'][indG, iC] for iC in iCLst]
    dataNLst = [npf['matN2'][indG, iC] for iC in iCLst]
    mapTitleLst = ['RMSE of ' + codePdf['shortName'][varC[iC]]
                   for iC in iCLst]
    siteNoLstTemp = [siteNoLst[i] for i in indG]
Example #23
0
keyLst=['Bias', 'RMSE', 'NSE']
dataBox = list()
for iS in range(len(keyLst)):
    statStr = keyLst[iS]
    temp = list()
    for k in range(len(statDictLst)):
        data = statDictLst[k][statStr]
        data = data[~np.isnan(data)]
        temp.append(data)
    dataBox.append(temp)
# plt.style.use('classic')
plt.rcParams['font.size'] = 16
plt.rcParams['font.family'] = 'Times New Roman'
# plt.rcParams['mathtext.fontset'] = 'cm'
# # fig = plt.figure(figsize=(8, 5), tight_layout=True)
fig = plot.plotBoxFig(dataBox, keyLst, ['LSTM', 'DA-1', 'DA-3', 'DA-7'], sharey=False, title='Dataset: North Great Plain')
fig.patch.set_facecolor('white')
fig.show()
# plt.savefig(pathCamels['Out'] + '/' + save_path + "/boxstat_test.png", dpi=500)


# plot time series
plt.rcParams['font.size'] = 13
plt.rcParams['font.family'] = 'Times New Roman'
t = utils.time.tRange2Array(tRange)
fig, axes = plt.subplots(5, 1, figsize=(12, 8))
for k in range(5):
    # iGrid = np.random.randint(0, 671)
    iGrid = np.random.randint(0, len(subset))
    yPlot = [obs[iGrid, :]]
    for y in predLst: