1# -*- coding: utf-8 -*-
2
3if __name__ == "__main__":
4
5 ################ Test rapoort ################
6 import smashbox
7 import numpy as np
8
9 bbox = {"left": 875000.0, "bottom": 6228000.0, "right": 1001000.0, "top": 6320000.0}
10
11 sb = smashbox.SmashBox()
12
13 sb.myparam.set_param("bbox", bbox)
14
15 sb.newmodel("rex")
16
17 sb.rex.mysetup.update_setup({"read_pet": False})
18
19 sb.rex.generate_mesh(
20 query="(SURF>200) & (INFLUENCE=='Influence nulle ou faible')", area_error_th=0.2
21 )
22
23 sb.rex.myplot.plot_mesh()
24
25 ##########################################################
26 # Artificial rainfall
27 nrow = sb.rex.mymesh.mesh["nrow"]
28 ncol = sb.rex.mymesh.mesh["ncol"]
29 prcp = np.random.randint(-100, 100, size=(nrow, ncol, 365 * 24))
30 prcp = np.where(prcp < 0, 0.0, prcp)
31 ###########################################################
32
33 sb.rex.atmos_data_connector(input_prcp=prcp, input_dt=3600.0)
34 sb.rex.model()
35
36 sb.rex.mysmashmodel.atmos_data.pet = 0.0
37 sb.rex.forward_run(return_options={"q_domain": True}, invert_states=True)
38
39 ##########################################################
40 # Artificial observed discharge
41 rand = np.random.randint(-20, 20, sb.rex.mysmashmodel.response_data.q.shape) / 100.0
42 qsim = sb.rex.mysmashmodel.response.q[:]
43 sb.rex.mysmashmodel.response_data.q = qsim + qsim * rand
44 ##########################################################
45
46 sb.rex.mystats.fmisfit_stats()
47 sb.rex.mystats.fquantile_stats(
48 chunk_size=30,
49 estimate_method="MLE",
50 ncpu=6,
51 fit="gumbel",
52 compute_uncertainties=False,
53 )
54
55 sb.rex.myplot.multiplot_misfit()
56 sb.rex.myplot.multiplot_spatial_quantile()
57 sb.rex.myplot.plot_outlets_quantile()
58 sb.rex.myplot.plot_hydrograph()