Пример #1
0
    # out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUSv2f1_LSTM'+yrLst[k])
    # masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    # master.runTrain(masterDict, cudaID=k % 3, screen='LSTM' + yrLst[k])

    # k=0
    optData = default.update(default.optDataSMAP,
                             rootDB=pathSMAP['DB_L3_NA'],
                             subset='CONUSv2f1',
                             tRange=tLst[k])
    optModel = default.update(default.optLstmClose,
                              name='hydroDL.model.rnn.AnnModel')
    optLoss = default.optLossRMSE
    optTrain = default.update(default.optTrainSMAP, nEpoch=300)
    out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUSv2f1_NN' + yrLst[k])
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=k % 3, screen='NN' + yrLst[k])
    # master.train(masterDict)

    optData = default.update(default.optDataSMAP,
                             rootDB=pathSMAP['DB_L3_NA'],
                             subset='CONUSv2f1',
                             tRange=tLst[k],
                             daObs=1)
    optModel = default.update(default.optLstmClose,
                              name='hydroDL.model.rnn.AnnCloseModel')
    optLoss = default.optLossRMSE
    optTrain = default.update(default.optTrainSMAP, nEpoch=300)
    out = os.path.join(pathSMAP['Out_L3_NA'], 'DA',
                       'CONUSv2f1_DANN' + yrLst[k])
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=k % 3, screen='DANN' + yrLst[k])
Пример #2
0
from hydroDL import pathSMAP, master, utils
from hydroDL.master import default
from hydroDL.post import plot, stat
import os
import matplotlib.pyplot as plt
import numpy as np
import torch

# train
optData = default.update(default.optDataSMAP,
                         rootDB=pathSMAP['DB_L3_NA'],
                         subset='CONUSv4f1',
                         tRange=[20150402, 20180401],
                         daObs=1)
optModel = default.optLstmClose
optLoss = default.optLossRMSE
optTrain = default.update(default.optTrainSMAP, nEpoch=500)
out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUS_DA_3yr')
masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
master.runTrain(masterDict, cudaID=2, screen='DA')

# test
subset = 'CONUS'
tRange = [20150402, 20180401]
# out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUSv2f1_DA2015')
out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUS_DA_3yr')
df, yf, obs = master.test(out, tRange=tRange, subset=subset, batchSize=100)

# /home/kxf227/work/GitHUB/hydroDL-dev/app/closeLoop/fullCONUS.py
Пример #3
0
#         optModel = default.optLstm
#         optLoss = default.optLossRMSE
#         optTrain = default.optTrainSMAP
#         out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegionCase',
#                            outName)
#         masterDict = wrapMaster(out, optData, optModel, optLoss,
#                                 optTrain)
#         runTrain(masterDict, cudaID=cid % 3, screen=case)
#         # train(masterDict)
#     cid = cid+1

cid = 2
for case in caseLst:
    for k in [0, 1]:
        subset = 'ecoReg_{}_L{}_sampleLin'.format(case, k)
        outName = subset + '_Forcing'
        varLst = dbCsv.varForcing
        optData = default.update(default.optDataSMAP,
                                 rootDB=pathSMAP['DB_L3_NA'],
                                 tRange=[20150401, 20160401],
                                 varT=varLst)
        optData = default.forceUpdate(optData, subset=subset)
        optModel = default.optLstm
        optLoss = default.optLossRMSE
        optTrain = default.optTrainSMAP
        out = os.path.join(pathSMAP['Out_L3_NA'], 'ecoRegionCase', outName)
        masterDict = wrapMaster(out, optData, optModel, optLoss, optTrain)
        runTrain(masterDict, cudaID=cid % 3, screen=case)
        # train(masterDict)
        cid = cid + 1
Пример #4
0
tLst = [[20150501, 20151001], [20150402, 20160401]]
tagLst = ['2015RK', '2015']
for k in range(len(tLst)):
    optData = default.update(default.optDataSMAP,
                             varT=['APCP_FORA'],
                             rootDB=pathSMAP['DB_L3_NA'],
                             subset='CONUSv2f1',
                             tRange=tLst[k],
                             daObs=1)
    optModel = default.optLstmClose
    optLoss = default.optLossRMSE
    optTrain = default.update(default.optTrainSMAP, nEpoch=500)
    out = os.path.join(pathSMAP['Out_L3_NA'], 'DA',
                       'CONUSv2f1_DA_Prcp_' + tagLst[k])
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=(k + 1) % 3, screen='DA' + tagLst[k])

    optData = default.update(default.optDataSMAP,
                             varT=['APCP_FORA'],
                             rootDB=pathSMAP['DB_L3_NA'],
                             subset='CONUSv2f1',
                             tRange=tLst[k])
    optModel = default.optLstm
    optLoss = default.optLossRMSE
    optTrain = default.update(default.optTrainSMAP, nEpoch=500)
    out = os.path.join(pathSMAP['Out_L3_NA'], 'DA',
                       'CONUSv2f1_LSTM_Prcp_' + tagLst[k])
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=(k + 1) % 3, screen='LSTM' + tagLst[k])

# training
Пример #5
0
        else:
            varLst = dbCsv.varSoilmGlobal

        optData = master.default.update(master.default.optDataSMAP,
                                        rootDB=pathSMAP['DB_L3_Global'],
                                        subset=subsetLst[k],
                                        tRange=[20150401, 20160401],
                                        varT=varLst)
        optModel = master.default.optLstm
        optLoss = master.default.optLossSigma
        optTrain = master.default.optTrainSMAP
        out = os.path.join(pathSMAP['Out_L3_Global'], outLst[k] + '_' + case)

        masterDict = master.wrapMaster(out, optData, optModel, optLoss,
                                       optTrain)
        master.runTrain(masterDict, cudaID=cid % 3, screen=outLst[k])
        cid = cid + 1
        # master.train(masterDict)

# some of them failed and rerun
# master.runTrain(
#     r'/mnt/sdb/rnnSMAP/Model_SMAPgrid/L3_Global/Africa_v4f1_y1_Forcing/',
#     cudaID=1,
#     screen='Africa_v4f1_y1_Forcing')
# master.runTrain(
#     r'/mnt/sdb/rnnSMAP/Model_SMAPgrid/L3_Global/Asia_v4f1_y1_Soilm/',
#     cudaID=0,
#     screen='Asia_v4f1_y1_Soilm')
# master.runTrain(
#     r'/mnt/sdb/rnnSMAP/Model_SMAPgrid/L3_Global/NorthAmerica_v4f1_y1_Soilm/',
#     cudaID=1,
Пример #6
0
for case in caseLst:
    if case == 'Forcing':
        varLst = dbCsv.varForcing
    else:
        varLst = dbCsv.varSoilM
    optData = master.default.update(master.default.optDataSMAP,
                                    rootDB=pathSMAP['DB_L3_NA'],
                                    subset='CONUSv2f1',
                                    tRange=[20150401, 20160401],
                                    varT=varLst)
    optModel = master.default.optLstm
    optLoss = master.default.optLossRMSE
    optTrain = master.default.optTrainSMAP
    out = os.path.join(pathSMAP['Out_L3_NA'], 'CONUSv2f1_' + case)
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=cid % 3, screen=case)
    cid = cid + 1

# train for each region
cid = 0
for k in range(len(subsetLst)):
    for case in caseLst:
        if case == 'Forcing':
            varLst = dbCsv.varForcing
        else:
            varLst = dbCsv.varSoilM
        optData = master.default.update(master.default.optDataSMAP,
                                        rootDB=pathSMAP['DB_L3_NA'],
                                        subset=subsetLst[k],
                                        tRange=[20150401, 20160401],
                                        varT=varLst)
Пример #7
0
    ndayda = list(range(1, nDay + 1))
    optData = default.update(default.optDataCamels,
                             daObs=ndayda,
                             davar='streamflow')
    optModel = default.update(default.optLstm, hiddenSize=HIDDENSIZE)
    optLoss = default.optLoss
    optTrain = default.update(default.optTrainCamels,
                              miniBatch=[BATCH_SIZE, RHO],
                              nEpoch=EPOCH)
    save_path = exp_name + '/' + exp_disp + \
                '/epochs{}_batch{}_rho{}_hiddensize{}'.format(optTrain['nEpoch'], optTrain['miniBatch'][0],
                                                              optTrain['miniBatch'][1], optModel['hiddenSize'])
    out = os.path.join(pathCamels['Out'], save_path,
                       'All-90-95-DA' + str(nDay))
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=cid % 3, screen='test-DA' + str(nDay))
    cid = cid + 1

# test original model
caseLst = ['All-90-95']
nDayLst = [3, 7]
for nDay in nDayLst:
    caseLst.append('All-90-95-DA' + str(nDay))
outLst = [os.path.join(pathCamels['Out'], save_path, x) for x in caseLst]
subset = 'All'
tRange = [19950101, 20000101]
predLst = list()
for out in outLst:
    df, pred, obs = master.test(out,
                                tRange=tRange,
                                subset=subset,
Пример #8
0
from hydroDL import pathSMAP, master
import os

# define training options
out = os.path.join(pathSMAP['Out_L3_NA'], 'RegTest', 'CONUSv4f1_sigma')

optData = master.default.update(
    master.default.optDataCsv,
    rootDB=pathSMAP['DB_L3_NA'],
    subset='CONUSv4f1',
    tRange=[20150401, 20160401],
)
optModel = master.default.optLstm
optLoss = master.default.update(master.default.optLoss,
                                name='hydroDL.model.crit.SigmaLoss')
optTrain = master.default.optTrain

masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)

# train
master.runTrain(masterDict, cudaID=0, screenName='sigmaTest')
Пример #9
0
    cid = 0
    for nd in dLst:
        optData = default.update(
            default.optDataSMAP,
            rootDB=pathSMAP['DB_L3_NA'],
            subset='CONUSv2f1',
            tRange=[20150501, 20160501],
            daObs=nd)
        optModel = default.optLstmClose
        optLoss = default.optLossRMSE
        optTrain = default.update(default.optTrainSMAP, nEpoch=300)
        out = os.path.join(pathSMAP['Out_L3_NA'], 'DA',
                           'CONUSv2f1_d' + str(nd))
        masterDict = master.wrapMaster(out, optData, optModel, optLoss,
                                       optTrain)
        master.runTrain(masterDict, cudaID=cid % 3, screen='d' + str(nd))
        # master.train(masterDict)
        cid = cid + 1
    # vanila LSTM
    optData = default.update(
        default.optDataSMAP,
        rootDB=pathSMAP['DB_L3_NA'],
        subset='CONUSv2f1',
        tRange=[20150501, 20160501])
    optModel = default.optLstm
    optLoss = default.optLossRMSE
    optTrain = default.update(default.optTrainSMAP, nEpoch=300)
    out = os.path.join(pathSMAP['Out_L3_NA'], 'DA', 'CONUSv2f1')
    masterDict = master.wrapMaster(out, optData, optModel, optLoss, optTrain)
    master.runTrain(masterDict, cudaID=0, screen='LSTM')