示例#1
0
 def region_model_repository(self):
     """
     Returns
     -------
      - RegionModelRepository - configured with 'Tistel-ptgsk' etc.
     """
     id_list = [1225]
     # parameters can be loaded from yaml_config Model parameters..
     pt_params = api.PriestleyTaylorParameter(
     )  # *params["priestley_taylor"])
     gs_params = api.GammaSnowParameter()  # *params["gamma_snow"])
     ss_params = api.SkaugenParameter()
     ae_params = api.ActualEvapotranspirationParameter(
     )  # *params["act_evap"])
     k_params = api.KirchnerParameter()  # *params["kirchner"])
     p_params = api.PrecipitationCorrectionParameter(
     )  # TODO; default 1.0, is it used ??
     ptgsk_rm_params = pt_gs_k.PTGSKParameter(pt_params, gs_params,
                                              ae_params, k_params,
                                              p_params)
     ptssk_rm_params = pt_ss_k.PTSSKParameter(pt_params, ss_params,
                                              ae_params, k_params,
                                              p_params)
     # create the description for 2 models of tistel,ptgsk, ptssk
     tistel_grid_spec = self.grid_spec  #
     cfg_list = [
         RegionModelConfig("Tistel-ptgsk", pt_gs_k.PTGSKModel,
                           ptgsk_rm_params, tistel_grid_spec,
                           "unregulated", "FELTNR", id_list),
         RegionModelConfig("Tistel-ptssk", pt_ss_k.PTSSKModel,
                           ptssk_rm_params, tistel_grid_spec,
                           "unregulated", "FELTNR", id_list)
     ]
     rm_cfg_dict = {x.name: x for x in cfg_list}
     return GisRegionModelRepository(rm_cfg_dict)
示例#2
0
 def _create_std_ptgsk_param(self):
     ptp = api.PriestleyTaylorParameter(albedo=0.85, alpha=1.23)
     ptp.albedo = 0.9
     ptp.alpha = 1.26
     aep = api.ActualEvapotranspirationParameter(ae_scale_factor=1.5)
     aep.ae_scale_factor = 1.1
     gsp = api.GammaSnowParameter(
         winter_end_day_of_year=99,
         initial_bare_ground_fraction=0.04,
         snow_cv=0.44,
         tx=-0.3,
         wind_scale=1.9,
         wind_const=0.9,
         max_water=0.11,
         surface_magnitude=33.0,
         max_albedo=0.88,
         min_albedo=0.55,
         fast_albedo_decay_rate=6.0,
         slow_albedo_decay_rate=4.0,
         snowfall_reset_depth=6.1,
         glacier_albedo=0.44
     )  # TODO: This does not work due to boost.python template arity of 15,  calculate_iso_pot_energy=False)
     gsp.calculate_iso_pot_energy = False
     gsp.snow_cv = 0.5
     gsp.initial_bare_ground_fraction = 0.04
     kp = api.KirchnerParameter(c1=-2.55, c2=0.8, c3=-0.01)
     kp.c1 = 2.5
     kp.c2 = -0.9
     kp.c3 = 0.01
     spcp = api.PrecipitationCorrectionParameter(scale_factor=0.9)
     ptgsk_p = pt_gs_k.PTGSKParameter(ptp, gsp, aep, kp, spcp)
     ptgsk_p.ae.ae_scale_factor = 1.2  # sih: just to demo ae scale_factor can be set directly
     return ptgsk_p
 def std_ptgsk_parameters(self):
     pt_params = api.PriestleyTaylorParameter(
     )  # *params["priestley_taylor"])
     gs_params = api.GammaSnowParameter()  # *params["gamma_snow"]
     ae_params = api.ActualEvapotranspirationParameter(
     )  # *params["act_evap"])
     k_params = api.KirchnerParameter()  # *params["kirchner"])
     p_params = api.PrecipitationCorrectionParameter(
     )  # TODO; default 1.0, is it used ??
     return api.pt_gs_k.PTGSKParameter(pt_params, gs_params, ae_params,
                                       k_params, p_params)
 def test_region_model_repository(self):
     id_list = [1225]
     epsg_id = 32632
     # parameters can be loaded from yaml_config Model parameters..
     pt_params = api.PriestleyTaylorParameter(
     )  # *params["priestley_taylor"])
     gs_params = api.GammaSnowParameter()  # *params["gamma_snow"])
     ss_params = api.SkaugenParameter()
     ae_params = api.ActualEvapotranspirationParameter(
     )  # *params["act_evap"])
     k_params = api.KirchnerParameter()  # *params["kirchner"])
     p_params = api.PrecipitationCorrectionParameter(
     )  # TODO; default 1.0, is it used ??
     ptgsk_rm_params = api.pt_gs_k.PTGSKParameter(
         pt_params, gs_params, ae_params, k_params, p_params)
     ptssk_rm_params = api.pt_ss_k.PTSSKParameter(
         pt_params, ss_params, ae_params, k_params, p_params)
     # create the description for 4 models of tistel,ptgsk, ptssk, full and optimized
     tistel_grid_spec = GridSpecification(epsg_id=epsg_id,
                                          x0=362000.0,
                                          y0=6765000.0,
                                          dx=1000,
                                          dy=1000,
                                          nx=8,
                                          ny=8)
     cfg_list = [
         RegionModelConfig("tistel-ptgsk", PTGSKModel, ptgsk_rm_params,
                           tistel_grid_spec, "unregulated", "FELTNR",
                           id_list),
         RegionModelConfig("tistel-ptgsk-opt", PTGSKOptModel,
                           ptgsk_rm_params, tistel_grid_spec,
                           "unregulated", "FELTNR", id_list),
         RegionModelConfig("tistel-ptssk", PTSSKModel, ptssk_rm_params,
                           tistel_grid_spec, "unregulated", "FELTNR",
                           id_list)
     ]
     rm_cfg_dict = {x.name: x for x in cfg_list}
     rmr = GisRegionModelRepository(
         rm_cfg_dict
     )  # ok, now we have a Gis RegionModelRepository that can handle all named entities we pass.
     cm1 = rmr.get_region_model(
         "tistel-ptgsk")  # pull out a PTGSKModel for tistel
     cm2 = rmr.get_region_model("tistel-ptgsk-opt")
     # Does not work, fail on ct. model:
     cm3 = rmr.get_region_model(
         "tistel-ptssk")  # pull out a PTGSKModel for tistel
     # cm4= rmr.get_region_model("tistel-ptssk",PTSSKOptModel)
     self.assertIsNotNone(cm3)
     self.assertIsNotNone(cm1)
     self.assertIsNotNone(cm2)
     self.assertIsNotNone(
         cm2.catchment_id_map
     )  # This one is needed in order to properly map catchment-id to internal id
     self.assertEqual(cm2.catchment_id_map[0], id_list[0])
示例#5
0
rhh_ts = api.TimeSeries(tah, rhh_dv, point_fx=instant)

radph = api.RadiationParameter(0.2, 1.0)
radch = api.RadiationCalculator(radph)
radrh = api.RadiationResponse()
# pmph=api.PenmanMonteithParameter(lai,height_ws,height_t)
pmph = api.PenmanMonteithParameter(height_veg, height_ws, height_t, rl, True)
pmch = api.PenmanMonteithCalculator(pmph)
pmphst = api.PenmanMonteithParameter(height_veg, height_ws, height_t, rl,
                                     False)
pmchst = api.PenmanMonteithCalculator(pmphst)
pmrh = api.PenmanMonteithResponse()
pmrhst = api.PenmanMonteithResponse()

#PriestleyTaylor
ptp = api.PriestleyTaylorParameter(0.2, 1.26)
ptc = api.PriestleyTaylorCalculator(0.2, 1.26)
ptr = api.PriestleyTaylorResponse

ET_ref_sim_h = []
ET_sim_st_h = []

timeofday = []
ET_pt_sim_h = []
Rso_sim_h = []
LW_sim_h = []
SW_sim_h = []
Ra_sim_h = []
Rnet_sim_h = []

for i in range(nhour - 1):
示例#6
0
def run_pm(ws_Th, ws_eah, ws_Rsh, ws_windspeedh,ws_rhh, rnet, height_veg=0.12,dt=1, n=30,rl = 144.0,height_ws = 3, height_t = 1.68, elevation = 1462.4, method='asce-ewri'):
    """Run Penman-Monteith evapotranspiration model from SHyFT"""

    import numpy as np
    import math
    import shyft
    from shyft import api

    utc = api.Calendar()

    c_MJm2d2Wm2 = 0.086400
    c_MJm2h2Wm2 = 0.0036

    #for radiation model
    latitude = 40.4
    slope_deg = 0.0
    aspect_deg = 0.0




    # n = 30 # nr of time steps: 1 year, daily data
    t_starth = utc.time(2000, 6, 1,16,0,0,0) # starting at the beginning of the year 1970
    step = api.deltahours(dt)


    # Let's now create Shyft time series from the supplied lists of precipitation and temperature.
    # First, we need a time axis, which is defined by a starting time, a time step and the number of time steps.
    ta = api.TimeAxis(t_starth, step, n) # days

    # First, we convert the lists to shyft internal vectors of double values:
    temph_dv = api.DoubleVector.from_numpy(ws_Th)
    eah_dv = api.DoubleVector.from_numpy(ws_eah)
    rsh_dv = api.DoubleVector.from_numpy(ws_Rsh)
    windspeedh_dv = api.DoubleVector.from_numpy(ws_windspeedh)

    rhh_dv = api.DoubleVector.from_numpy(ws_rhh)

    # Finally, we create shyft time-series as follows:
    # (Note: This step is not necessarily required to run the single methods.
    #  We could also just work with the double vector objects and the time axis)
    instant = api.point_interpretation_policy.POINT_INSTANT_VALUE
    average = api.point_interpretation_policy.POINT_AVERAGE_VALUE

    temph_ts = api.TimeSeries(ta, temph_dv, point_fx=instant)
    eah_ts = api.TimeSeries(ta, eah_dv, point_fx=instant)
    rsh_ts = api.TimeSeries(ta, rsh_dv, point_fx=instant)
    windspeedh_ts = api.TimeSeries(ta, windspeedh_dv, point_fx=instant)


    #recalculated inputs:
    rhh_ts = api.TimeSeries(ta, rhh_dv, point_fx=instant)


    radph = api.RadiationParameter(0.26,1.0)
    radch = api.RadiationCalculator(radph)
    radrh =api.RadiationResponse()
    if method=='asce-ewri':
        full_model = False
    else:
        full_model = True
    pmph=api.PenmanMonteithParameter(height_veg,height_ws,height_t, rl, full_model)
    pmch=api.PenmanMonteithCalculator(pmph)
    pmrh =api.PenmanMonteithResponse()

    #PriestleyTaylor
    ptp = api.PriestleyTaylorParameter(0.2,1.26)
    ptc = api.PriestleyTaylorCalculator(0.2, 1.26)
    ptr = api.PriestleyTaylorResponse

    ET_ref_sim_h= []

    for i in range(n-1):
        pmch.reference_evapotranspiration(pmrh, step,rnet[i], temph_ts.v[i],temph_ts.v[i],
                                                      rhh_ts.v[i], elevation, windspeedh_ts.v[i])
        ET_ref_sim_h.append(pmrh.et_ref)




    return ET_ref_sim_h