コード例 #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
ファイル: test_calibration_types.py プロジェクト: yisak/shyft
 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
コード例 #3
0
 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)
コード例 #4
0
 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
# plot = ax.scatter(x, y, c=z, marker='o', s=10, lw=5, cmap=cm)
# plt.colorbar(plot).set_label('sub-catchments assocciate to targets')
plt.legend(fontsize=16, loc=1)
plt.show()

timelist = []
for i in range(len(ts_timestamps)):
    timelist.append((str(ts_timestamps[i])[0:10], dis_sims[i]))
timelist_pd = pd.DataFrame(timelist)
timelist_pd.to_csv('dis_sims_G.csv')

#  Somthing more to know
#  Getting access to defualt values of variables (not used in simulation)

parameterg = api.GammaSnowParameter()
parameterk = api.KirchnerParameter()
print('slow_albedo_decay_rate = ', parameterg.slow_albedo_decay_rate)
print('Kirchner C1 = ', parameterk.c1)

#  Getting access to the values are used for simulation which are in model.yaml (used in simulation)

param = simulator.region_model.get_region_parameter()
print('slow_albedo_decay_rate = ', param.gs.slow_albedo_decay_rate)
print('Kirchner C1 = ', param.kirchner.c1)

#  Getting access to atributes of simulator

for attr in dir(simulator.region_model):
    if attr[0] is not '_':  #ignore privates
        print(attr)