コード例 #1
0
    def __init__(self, p, pet, t, nsubcats, subcatwts):
        """ This method is used to initialise, i.e., create an instance of the ExphydroDistrModel class.

        Syntax: ExphydroDistrModel(p, pet, t, npixels)

        Args:
            (1) p: Daily precipitation time-series (mm/day). Each column is 1 pixel
            (2) pet: Daily potential evapotranspiration time-series (mm/day). Each column is 1 pixel
            (3) t: Daily mean air temperature time-series (deg C). Each column is 1 pixel
            (4) nsubcats: Number of sub-catchments in the catchment
            (5) Relative weight of all sub-catchments (array). It is the proportion of area
            covered by each sub-catchment.  Sum of all array elements is 1.

        """

        # The statement below creates nsubcats instances of the lumped EXP-HYDRO model
        self.model = [
            ExphydroModel(p[:, j], pet[:, j], t[:, j]) for j in range(nsubcats)
        ]

        self.subcatwts = subcatwts  # Relative weight of each sub-catchment
        self.timespan = p.shape[0]  # Time length of the simulation period
        self.qsimtmp = numpy.zeros(
            self.timespan
        )  # Variable to temporarily store pixel's streamflow output
        self.qsim = numpy.zeros(self.timespan)  # Simulated streamflow (mm/day)
コード例 #2
0
    def __init__(self, p, pet, t, npixels):
        """ This method is used to initialise, i.e., create an instance of the ExphydroDistrModel class.

        Syntax: ExphydroDistrModel(p, pet, t, npixels)

        Args:
            (1) p: Daily precipitation time-series (mm/day)
            (2) pet: Daily potential evapotranspiration time-series (mm/day)
            (3) t: Daily mean air temperature time-series (deg C)
            (4) npixels: Number of pixels in the catchment

        """

        # The statement below creates npixel instances of the lumped EXP-HYDRO model
        self.model = [ExphydroModel(p, pet, t) for j in range(npixels)]

        self.timespan = p.shape[0]  # Time length of the simulation period
        self.qsimtmp = numpy.zeros(
            self.timespan
        )  # Variable to temporarily store pixel's streamflow output
        self.qsim = numpy.zeros(self.timespan)  # Simulated streamflow (mm/day)
コード例 #3
0
# MAIN PROGRAM

# Load meteorological and observed flow data
P = numpy.genfromtxt('SampleData/P_test.txt')  # Observed rainfall (mm/day)
T = numpy.genfromtxt('SampleData/T_test.txt')  # Observed air temperature (deg C)
PET = numpy.genfromtxt('SampleData/PET_test.txt')  # Potential evapotranspiration (mm/day)
Qobs = numpy.genfromtxt('SampleData/Q_test.txt')  # Observed streamflow (mm/day)

# Specify the no. of iterations
niter = 100

# Generate 'niter' initial EXP-HYDRO model parameters
params = [ExphydroParameters() for j in range(niter)]

# Initialise the model by loading its climate inputs
model = ExphydroModel(P, PET, T)

# Specify the start and end day numbers of the calibration period.
# This is done separately for the observed and simulated data
# because they might not be of the same length in some cases.
calperiods_obs = [365, 2557]
calperiods_sim = [365, 2557]

# Calibrate the model to identify optimal parameter set
paramsmax = Calibration.montecarlo_maximise(model, params, Qobs, ObjectiveFunction.klinggupta,
                                            calperiods_obs, calperiods_sim)
print 'Calibration run KGE value = ', paramsmax.objval

# Run the optimised model for validation period
Qsim = model.simulate(paramsmax)
kge = ObjectiveFunction.klinggupta(Qobs[calperiods_obs[1]:], Qsim[calperiods_sim[1]:])