Пример #1
0
def funcPoint(iP, axP):
    [axTS, axH1, axH2, axH3, axP1, axP2] = axP
    siteNo = siteNoLstCode[iP]
    outName1 = '{}-{}-{}-{}'.format(dataName, 'comb', 'QTFP_C', trainSet)
    outName2 = '{}-{}-{}-{}'.format(dataName, 'comb', 'QT_C', trainSet)
    dfL1 = basins.loadSeq(outName1, siteNo)
    dfL2 = basins.loadSeq(outName2, siteNo)
    dfW = pd.read_csv(os.path.join(dirWRTDS, siteNo),
                      index_col=None).set_index('date')
    dfO = waterQuality.readSiteTS(siteNo, codeLst + ['00060'], freq='W')
    dfOD = waterQuality.readSiteTS(siteNo, codeLst + ['00060'], freq='D')
    t = dfO.index
    # ts
    tBar = np.datetime64('2010-01-01')
    sd = np.datetime64('1980-01-01')
    legLst = ['LSTM QTFP', 'LSTM QT', 'WRTDS', 'Obs']
    axplot.plotTS(axTS,
                  t, [dfL1[code], dfL2[code], dfW[code], dfO[code]],
                  tBar=tBar,
                  sd=sd,
                  styLst='---*',
                  cLst='mrbk',
                  legLst=legLst)
    corrL = corrMat[indS[iP], iCode, 0]
    corrW = corrMat[indS[iP], iCode, 1]
    axplot.titleInner(axTS,
                      'siteNo {} {:.2f} {:.2f}'.format(siteNo, corrL, corrW))
    axTS.legend()
    # hist
    axH1.hist(dfOD[code].values, density=True, bins=50)
    axplot.titleInner(axH1, 'histogram {}'.format(shortName))
    axH2.hist(dfOD['00060'].values, density=True, bins=50)
    axplot.titleInner(axH2, 'histogram {}'.format('Q'))
    axH3.hist(np.log(dfOD['00060'].values + 1), density=True, bins=50)
    axplot.titleInner(axH3, 'histogram {}'.format('log Q'))
    # periodgram
    freqQ, powerQ, pQ = calPower('00060', dfOD)
    freqC, powerC, pC = calPower(code, dfOD)
    axP1.plot(1 / freqQ, powerC, '-*b', label='Periodograms')
    axP1.plot(1 / freqQ, pQ, '-*r', label='baluev probability')
    axplot.titleInner(axP1, 'streamflow')
    axP1.legend()
    axP2.plot(1 / freqC, powerC, '-*b', label='Periodograms')
    axP2.plot(1 / freqC, pC, '-*r', label='baluev probability')
    axplot.titleInner(axP2, shortName)
    axP2.legend()
Пример #2
0
# attr vs diff
fig, axes = plt.subplots(nfy, nfx)
for k, code in enumerate(codeLst2):
    j, i = utils.index2d(k, nfy, nfx)
    ax = axes[j, i]
    ic = codeLst.index(code)
    x = cMat[:, k] if cMat.ndim == 2 else cMat
    # y = corrMat[:, ic, 1]**2-corrMat[:, ic, 2]**2
    y = rmseMat[:, ic, 1]**2-rmseMat[:, ic, 2]**2
    ax.plot(x, y, '*')
    ax.plot([np.nanmin(x), np.nanmax(x)], [0, 0], 'k-')
    ax.set_ylim([-0.5, 0.5])
    # ax.set_xlim([0, 200])
    titleStr = '{} {} '.format(
        code, usgs.codePdf.loc[code]['shortName'])
    axplot.titleInner(ax, titleStr)
fig.show()


indC = [codeLst.index(code) for code in codeLst2]
labelLst = ['{} {}'.format(code, usgs.codePdf.loc[code]['shortName'])
            for code in codeLst2]
xMat = rmseMat[:, indC, 1]
yMat = rmseMat[:, indC, 2]
nXY = [nfx, nfy]


def funcM():
    figM, axM = figplot.scatter121Batch(
        xMat, yMat, cMat, labelLst, nXY, optCb=1, cR=cR)
    figM.suptitle('corr of LSTM vs WRTDS colored by {}'.format(cVar))
Пример #3
0

# Q of Nine random sites
indLst = np.random.randint(0, ns, 9)
nfy, nfx = (3, 3)
bins = 10
fig, axes = plt.subplots(nfy, nfx)
for k, indS in enumerate(indLst):
    j, i = utils.index2d(k, nfy, nfx)
    ax = axes[j, i]
    ic = DF.varC.index(code)
    q1 = np.log(q[:, indS]+1)
    ind = np.where(~np.isnan(c[:, indS]))[0]
    q2 = np.log(q[ind, indS]+1)
    axplot.plotCDF(ax, [q1, q2])
    # ax.hist([q1, q2], bins=bins, density=True)
    nData = np.sum(~np.isnan(DF.c[:, indS, ic]))
    shortName = usgs.codePdf.loc[code]['shortName']
    titleStr = '{} {}'.format(
        DF.siteNoLst[indS], nData)
    axplot.titleInner(ax, titleStr, top=False)
fig.show()

q1 = np.log(q+1).flatten()
b = ~np.isnan(c)
q2 = np.log(q[b]+1)
fig, axes = plt.subplots(2, 1)
axplot.plotCDF(axes[0], [q1, q2])
axes[1].hist([q1, q2], bins=20, density=True)
fig.show()
s, p = scipy.stats.ks_2samp(q1, q2)