Пример #1
0
# pick by year
yrIn = np.arange(1985, 2020, 5).tolist()
t1 = dbBasin.func.pickByYear(DF.t, yrIn)
t2 = dbBasin.func.pickByYear(DF.t, yrIn, pick=False)
DF.createSubset('pkYr5', dateLst=t1)
DF.createSubset('rmYr5', dateLst=t2)

# pick by day
t1 = dbBasin.func.pickByDay(DF.t, dBase=5, dSel=1)
t2 = dbBasin.func.pickByDay(DF.t, dBase=5, dSel=1, pick=False)
DF.createSubset('pkD5', dateLst=t1)
DF.createSubset('rmD5', dateLst=t2)

# pick by random
t1 = dbBasin.func.pickRandT(DF.t, 0.2)
t2 = dbBasin.func.pickRandT(DF.t, 0.2, pick=False)
DF.createSubset('pkRT20', dateLst=t1)
DF.createSubset('rmRT20', dateLst=t2)

# plot
codeSel = ['00915', '00925', '00930', '00935', '00940', '00945', '00955']
d1 = dbBasin.DataModelBasin(DF, subset='pkR20', varY=codeSel)
d2 = dbBasin.DataModelBasin(DF, subset='rmR20', varY=codeSel)

k = 0
fig, axes = figplot.multiTS(d2.t, [d2.Y[:, k, :], d1.Y[:, k, :]],
                            cLst='br',
                            styLst='..')
fig.show()
Пример #2
0
d, dictTran = transform.transIn(a, **dictTran)
c = transform.transOut(b, dictTran)

# check hist
nd = len(mtdLst)
bins = 50
indS = 8
fig, axes = plt.subplots(nd, 2, figsize=(4, 8))
for k, var in enumerate(mtdLst):
    _ = axes[k, 0].hist(a[:, :, k].flatten(), bins=bins)
    _ = axes[k, 1].hist(b[:, :, k].flatten(), bins=bins)
fig.show()

fig, axes = plt.subplots(nd, 2, figsize=(4, 8))
for k, var in enumerate(mtdLst):
    _ = axes[k, 0].hist(a[:, indS, k].flatten(), bins=bins)
    _ = axes[k, 1].hist(b[:, indS, k].flatten(), bins=bins)
fig.show()

# TS
fig, axes = figplot.multiTS(d1.t, b[:, indS, :], labelLst=mtdLst)
fig.show()

fig, axes = plt.subplots(nd, 2, figsize=(4, 8))
for k, var in enumerate(mtdLst):
    _ = axes[k, 0].hist(b[:, :, k].flatten(), bins=bins)
    _ = axes[k, 1].hist(b[:, :, k].flatten(), bins=bins)
    _ = axes[k, 0].hist(b[:, 8, k].flatten(), bins=bins)
    _ = axes[k, 1].hist(b[:, 11, k].flatten(), bins=bins)
fig.show()
Пример #3
0
# yW = np.ndarray(yO.shape)
# for k, siteNo in enumerate(siteNoLst):
#     dirWRTDS = os.path.join(kPath.dirWQ, 'modelStat',
#                             'WRTDS-D', 'weathering-pkY5')
#     saveFile = os.path.join(dirWRTDS, siteNo)
#     df = pd.read_csv(saveFile, index_col=None).set_index('date')
#     df.index = df.index.values.astype('datetime64[D]')
#     indT = np.in1d(df.index.values, DF.t)
#     yW[:, k, :] = df.loc[indT][codeSel].values

d1 = dbBasin.DataModelBasin(DF, subset=trainSet, varY=codeSel)
d2 = dbBasin.DataModelBasin(DF, subset=testSet, varY=codeSel)
for k in range(len(DF.siteNoLst)):
    dataPlot = [yOut[:, k, :], d1.Y[:, k, :], d2.Y[:, k, :]]
    cLst = ['red', 'grey', 'black']
    fig, axes = figplot.multiTS(DF.t, dataPlot, labelLst=labelLst, cLst=cLst)
    fig.show()

# correlation matrix
mat1 = np.ndarray([len(siteNoLst), len(codeSel), 4])
mat2 = np.ndarray([len(siteNoLst), len(codeSel), 4])
for indS, siteNo in enumerate(siteNoLst):
    for indC, code in enumerate(codeSel):
        stat = utils.stat.calStat(yOut[:, indS, indC], d2.Y[:, indS, indC])
        mat1[indS, indC, 0] = stat['Bias']
        mat1[indS, indC, 1] = stat['RMSE']
        mat1[indS, indC, 2] = stat['NSE']
        mat1[indS, indC, 3] = stat['Corr']

statStrLst = ['Bias', 'RMSE', 'NSE', 'Corr']
dataPlot = list()
Пример #4
0
dm.saveSubset('B10', ed='2009-12-31')
dm.saveSubset('A10', sd='2010-01-01')

yrIn = np.arange(1985, 2020, 5).tolist()
t1 = dbBasin.func.pickByYear(dm.t, yrIn, pick=False)
t2 = dbBasin.func.pickByYear(dm.t, yrIn)
dm.createSubset('rmYr5', dateLst=t1)
dm.createSubset('pkYr5', dateLst=t2)

codeSel = ['00915', '00925', '00930', '00935', '00940', '00945', '00955']
d1 = dbBasin.DataModelBasin(dm, varY=codeSel, subset='rmYr5')
d2 = dbBasin.DataModelBasin(dm, varY=codeSel, subset='pkYr5')

mtdY = ['QT' for var in codeSel]
d1.trans(mtdY=mtdY)
d1.saveStat('temp')
# d2.borrowStat(d1)
d2.loadStat('temp')
yy = d2.y
yP = d2.transOutY(yy)
yO = d2.Y

# TS
indS = 1
fig, axes = figplot.multiTS(d1.t, [yO[:, indS, :], yP[:, indS, :]])
fig.show()

indS = 1
fig, axes = figplot.multiTS(d1.t, [yy[:, indS, :]])
fig.show()