Пример #1
0
def get_NSE(values):

    its = values['LZSN'], values['INFILT']
    print(('running simulation LZSN: {:.1f}, INFILT: {:.4f}\n'.format(*its)))

    # open the baseline HSPF model

    with open(model, 'rb') as f:
        hspfmodel = pickle.load(f)

    # change the filename to prevent two simultaneous runs with the same name

    its = working, values['LZSN'], values['INFILT']
    hspfmodel.filename = '{}/LZSN{:.1f}INFILT{:.4f}'.format(*its)

    # change the pan coefficient

    hspfmodel.evap_multiplier = 0.76

    # change the parameter values in all the land segments

    for p in hspfmodel.perlnds:
        p.LZSN = values['LZSN']
        p.INFILT = values['INFILT']

    # build the input WDM file

    hspfmodel.build_wdminfile()

    # build the UCI file (only need to save the reach_outvolume, ROVOL)

    hspfmodel.build_uci(['reach_outvolume'], start, end, hydrology=True)

    # run the simulation

    hspfmodel.run(verbose=True)

    # make an instance of the postprocessor to get the efficiency

    p = Postprocessor(hspfmodel, (start, end), comid=gagecomid)

    # the regressions between the simulated and observed flows can be
    # computed using the "regression" function that returns:
    #
    # daily r2, log daily r2, daily NSE, log daily NSE
    # montly r2, log monthly r2, monthly NSE, log monthly NSE

    dr2, dlr2, dNS, dlNS, mr2, mlr2, mNS, mlNS = p.get_regression(gagecomid)

    # close the Postprocessor

    p.close()

    return dNS
Пример #2
0
def get_NSE(values):

    its = values['LZSN'], values['INFILT']
    print('running simulation LZSN: {:.0f}, INFILT: {:.2f}\n'.format(*its))

    # open the baseline HSPF model

    with open(filename, 'rb') as f:
        hspfmodel = pickle.load(f)

    # change the filename to prevent two simultaneous runs with the same name

    i = len(hspfmodel.filename) - 1
    while hspfmodel.filename[i] != '/':
        i -= 1

    path = hspfmodel.filename[:i]

    its = path, values['LZSN'], values['INFILT']
    hspfmodel.filename = '{}/LZSN{:.0f}INFILT{:.2f}'.format(*its)

    # change the parameter values in all the land segments

    for p in hspfmodel.perlnds:

        p.LZSN = values['LZSN']
        p.INFILT = values['INFILT']

    # build the input WDM file

    hspfmodel.build_wdminfile()

    # build the UCI file (only need to save the reach_outvolume, ROVOL)

    hspfmodel.build_uci(['reach_outvolume'],
                        start,
                        end,
                        atemp=atemp,
                        snow=snow,
                        hydrology=hydrology)

    # run the simulation

    hspfmodel.run(verbose=True)

    # calibration period

    dates = start + datetime.timedelta(days=warmup), end

    # find the common identifier for the NWIS gage

    d = {v: k for k, v in hspfmodel.subbasin_timeseries['flowgage'].items()}
    comid = d[gageid]

    # make an instance of the postprocessor to get the efficiency

    p = Postprocessor(hspfmodel, dates, comid=comid)

    # the regressions between the simulated and observed flows can be
    # computed using the "regression" function that returns:
    #
    # daily r2, log daily r2, daily NSE, log daily NSE
    # montly r2, log monthly r2, monthly NSE, log monthly NSE

    dr2, dlr2, dNS, dlNS, mr2, mlr2, mNS, mlNS = p.get_regression(comid)

    # close the Postprocessor

    p.close()

    return dNS
Пример #3
0
def get_NSE(values):

    its = values['LZSN'], values['INFILT']
    print('running simulation LZSN: {:.0f}, INFILT: {:.2f}\n'.format(*its))
    
    # open the baseline HSPF model

    with open(filename, 'rb') as f: hspfmodel = pickle.load(f)

    # change the filename to prevent two simultaneous runs with the same name

    i = len(hspfmodel.filename) - 1
    while hspfmodel.filename[i] != '/': i -= 1

    path = hspfmodel.filename[:i]
    
    its = path, values['LZSN'], values['INFILT']
    hspfmodel.filename = '{}/LZSN{:.0f}INFILT{:.2f}'.format(*its)
                              
    # change the parameter values in all the land segments

    for p in hspfmodel.perlnds:

        p.LZSN   = values['LZSN']
        p.INFILT = values['INFILT']

    # build the input WDM file
        
    hspfmodel.build_wdminfile()

    # build the UCI file (only need to save the reach_outvolume, ROVOL)
        
    hspfmodel.build_uci(['reach_outvolume'], start, end, atemp = atemp,
                        snow = snow, hydrology = hydrology)

    # run the simulation

    hspfmodel.run(verbose = True)

    # calibration period

    dates = start + datetime.timedelta(days = warmup), end

    # find the common identifier for the NWIS gage

    d = {v:k for k, v in hspfmodel.subbasin_timeseries['flowgage'].items()}
    comid = d[gageid]

    # make an instance of the postprocessor to get the efficiency
        
    p = Postprocessor(hspfmodel, dates, comid = comid)

    # the regressions between the simulated and observed flows can be
    # computed using the "regression" function that returns:
    #
    # daily r2, log daily r2, daily NSE, log daily NSE
    # montly r2, log monthly r2, monthly NSE, log monthly NSE
        
    dr2, dlr2, dNS, dlNS, mr2, mlr2, mNS, mlNS = p.get_regression(comid)

    # close the Postprocessor

    p.close()

    return dNS