wolfhece 2.1.12__py3-none-any.whl → 2.1.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/PyDraw.py +111 -75
- wolfhece/PyGui.py +27 -4
- wolfhece/PyParams.py +1 -1
- wolfhece/PyVertexvectors.py +14 -0
- wolfhece/Results2DGPU.py +20 -12
- wolfhece/apps/version.py +1 -1
- wolfhece/fonts/arial.ttf +0 -0
- wolfhece/hydrology/Catchment.py +92 -8
- wolfhece/hydrology/Comparison.py +46 -7
- wolfhece/hydrology/Optimisation.py +63 -4
- wolfhece/hydrology/PyWatershed.py +563 -17
- wolfhece/hydrology/RetentionBasin.py +246 -41
- wolfhece/hydrology/SubBasin.py +42 -9
- wolfhece/hydrology/plot_hydrology.py +58 -0
- wolfhece/libs/WolfDll.dll +0 -0
- wolfhece/picc.py +35 -4
- wolfhece/wolf_array.py +152 -30
- wolfhece/wolfresults_2D.py +18 -4
- {wolfhece-2.1.12.dist-info → wolfhece-2.1.14.dist-info}/METADATA +1 -1
- {wolfhece-2.1.12.dist-info → wolfhece-2.1.14.dist-info}/RECORD +23 -23
- {wolfhece-2.1.12.dist-info → wolfhece-2.1.14.dist-info}/WHEEL +1 -1
- {wolfhece-2.1.12.dist-info → wolfhece-2.1.14.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.12.dist-info → wolfhece-2.1.14.dist-info}/top_level.txt +0 -0
wolfhece/hydrology/Comparison.py
CHANGED
@@ -581,7 +581,7 @@ class Comparison:
|
|
581
581
|
tmpHydro = cur_module.get_direct_insideRB_inlets(unit='m3/s')
|
582
582
|
|
583
583
|
y1.append(tmpHydro[:])
|
584
|
-
|
584
|
+
else:
|
585
585
|
|
586
586
|
# tmp = curCatch.retentionBasinDict["J18"].directFluxInRB
|
587
587
|
# tmpHydro = np.zeros(len(tmp))
|
@@ -664,7 +664,7 @@ class Comparison:
|
|
664
664
|
print("ERROR: the simulation time is not long enough for this subbasin to be taken into account")
|
665
665
|
sys.exit()
|
666
666
|
y1.append(tmpHydro[:])
|
667
|
-
|
667
|
+
else:
|
668
668
|
tmp = curCatch.retentionBasinDict["J16"].directFluxInRB
|
669
669
|
tmpHydro = np.zeros(len(tmp))
|
670
670
|
|
@@ -1588,7 +1588,7 @@ class Comparison:
|
|
1588
1588
|
# The following lines is take the peak difference between simulation and measurements -> Display 0.0 if the measurement is 0.0
|
1589
1589
|
isZero = np.array(meas_peak)==0
|
1590
1590
|
notZero = np.array(meas_peak)!=0
|
1591
|
-
peak_prop = {stationKey[i]: [ list( (np.array(
|
1591
|
+
peak_prop = {stationKey[i]: [ list( (np.array(el)-np.array(meas_peak[i]))/(np.array(meas_peak[i])+isZero[i]) *notZero[i] )
|
1592
1592
|
for el in all_peaks[i] ]
|
1593
1593
|
for i in range(len(stationKey))
|
1594
1594
|
}
|
@@ -1640,13 +1640,52 @@ class Comparison:
|
|
1640
1640
|
sorted_keys = list(all_data[0].keys())
|
1641
1641
|
|
1642
1642
|
## Str of dates
|
1643
|
-
all_names = ["-".join([cdate[0].strftime("%d/%m/%Y"), cdate[1].strftime("%d/%m/%Y")]) for cdate in intervals]
|
1643
|
+
all_names = ["\n - \n".join([cdate[0].strftime("%d/%m/%Y"), cdate[1].strftime("%d/%m/%Y")]) for cdate in intervals]
|
1644
1644
|
|
1645
1645
|
|
1646
1646
|
## Plot
|
1647
1647
|
nb_stations = len(stationKey)
|
1648
1648
|
type_of_model = [self.myCatchments[el]["Title"] for el in self.myCatchments]
|
1649
|
-
type_of_data =
|
1650
|
-
|
1649
|
+
type_of_data = ["Nash", r"$ \frac{Q^{s}_{max}-Q^{m}_{max}}{Q^{m}_{max}} $ "]
|
1650
|
+
type_of_data_names = ["Nash", "Exceedance"]
|
1651
|
+
|
1651
1652
|
ph.bar_Nash_n_other(all_data, all_colors, nb_x=len(intervals), nb_data=len(type_of_model), nb_lines=nb_stations,
|
1652
|
-
y_titles=type_of_data, x_titles=all_names, nameModel=type_of_model, line_names=sorted_keys, toShow=
|
1653
|
+
y_titles=type_of_data, x_titles=all_names, nameModel=type_of_model, line_names=sorted_keys, toShow=False)
|
1654
|
+
|
1655
|
+
# =========
|
1656
|
+
# =========
|
1657
|
+
# Plot tables - 2nd version with the table instead of bars
|
1658
|
+
all_ns= {
|
1659
|
+
cur_catch["Title"]: np.array([list(cur_catch["Object"].get_sub_Nash(measures[i], stationKey[i], intervals)) for i in range(len(stationKey))])
|
1660
|
+
for cur_catch in self.myCatchments.values()
|
1661
|
+
}
|
1662
|
+
|
1663
|
+
all_peaks = {cur_catch["Title"]: np.array([cur_catch["Object"].get_sub_peak(stationKey[i], intervals) for i in range(len(stationKey))])
|
1664
|
+
for cur_catch in self.myCatchments.values()
|
1665
|
+
}
|
1666
|
+
|
1667
|
+
print(all_peaks)
|
1668
|
+
|
1669
|
+
meas_peak = np.array([ measures[i].get_peak(intervals)
|
1670
|
+
for i in range(len(stationKey)) ])
|
1671
|
+
|
1672
|
+
# The following lines is take the peak difference between simulation and measurements -> Display 0.0 if the measurement is 0.0
|
1673
|
+
isZero = (meas_peak==0)
|
1674
|
+
notZero = (meas_peak!=0)
|
1675
|
+
peak_prop = {
|
1676
|
+
cur_model: (value-meas_peak)/(meas_peak+isZero) *notZero
|
1677
|
+
for cur_model, value in all_peaks.items()
|
1678
|
+
}
|
1679
|
+
|
1680
|
+
# Concatenate all data
|
1681
|
+
all_data = [all_ns, peak_prop]
|
1682
|
+
|
1683
|
+
for data, name_of_data in zip(all_data, type_of_data_names):
|
1684
|
+
for cur_model, cur_data in data.items():
|
1685
|
+
file_name = os.path.join(self.workingDir, name_of_data+"_"+cur_model)+".png"
|
1686
|
+
# cur_title = cur_model + ": " + name_of_data
|
1687
|
+
ph.table_Nash_n_other(cur_data, name_of_data,
|
1688
|
+
row_names=sorted_keys, column_names=all_names,
|
1689
|
+
writeFile=file_name, toShow=False)
|
1690
|
+
|
1691
|
+
plt.show()
|
@@ -2499,7 +2499,7 @@ class Optimisation(wx.Frame):
|
|
2499
2499
|
|
2500
2500
|
# FIXME : this function has been dashed off -> functionnal but not well written!!
|
2501
2501
|
# TODO : to improve !!!!!!
|
2502
|
-
def test_equifinality_with_Nash(self, event, idLauncher:int=0, idOpti:int=1, quantile_Nash:float=0.
|
2502
|
+
def test_equifinality_with_Nash(self, event, idLauncher:int=0, idOpti:int=1, quantile_Nash:float=0.01, std_Nash:float=0.3, clustering_Nash:bool=True):
|
2503
2503
|
"""
|
2504
2504
|
Test the equifinality of the model.
|
2505
2505
|
|
@@ -2578,6 +2578,8 @@ class Optimisation(wx.Frame):
|
|
2578
2578
|
# Save all the variables/evaluations desired
|
2579
2579
|
frac_dict = self._get_cur_fractions(idLauncher=idLauncher, stationOut=stationOut, intervals=cur_intervals)
|
2580
2580
|
cur_all_frac = list(frac_dict.values())
|
2581
|
+
frac_vol_dict = self._get_volume_fractions(idLauncher=idLauncher, stationOut=stationOut, intervals=cur_intervals)
|
2582
|
+
qof_max = self._get_max_runoff(idLauncher=idLauncher, stationOut=stationOut, intervals=cur_intervals)
|
2581
2583
|
p_excess = self._get_exceedance(idLauncher=idLauncher, stationOut=stationOut, intervals=cur_intervals)
|
2582
2584
|
max_sim_obs = self._get_ratio_max_sim_obs(idLauncher=idLauncher, stationOut=stationOut, intervals=cur_intervals)
|
2583
2585
|
# Extract the time delays
|
@@ -2585,13 +2587,18 @@ class Optimisation(wx.Frame):
|
|
2585
2587
|
all_timeDelays_str = {key : str(datetime.timedelta(seconds=all_timeDelays[key])) for key in all_timeDelays}
|
2586
2588
|
cur_timeDelays = list(all_timeDelays_str.values())
|
2587
2589
|
# Concatenate all the informations
|
2588
|
-
cur_all_frac = list(cur_p) + cur_timeDelays + cur_all_frac + [p_excess, max_sim_obs, cur_obj]
|
2590
|
+
cur_all_frac = list(cur_p) + cur_timeDelays + cur_all_frac + list(frac_vol_dict.values()) + [qof_max, p_excess, max_sim_obs, cur_obj]
|
2589
2591
|
all_frac.append(cur_all_frac)
|
2590
2592
|
|
2591
2593
|
# Get param names
|
2592
2594
|
names = self.get_param_names(idLauncher=idLauncher, stationOut=stationOut)
|
2593
2595
|
# Save the evaluations
|
2594
|
-
var_names = names
|
2596
|
+
var_names = names \
|
2597
|
+
+ list(all_timeDelays_str.keys()) \
|
2598
|
+
+ list(frac_dict.keys()) \
|
2599
|
+
+ list(frac_vol_dict.keys()) \
|
2600
|
+
+ ["% max runoff", "P. of exceedance", "Qmax_simul/Q_max_measure", "Nash"]
|
2601
|
+
|
2595
2602
|
cur_df = pd.DataFrame(all_frac, columns=var_names)
|
2596
2603
|
# write first the tempory results for each station
|
2597
2604
|
writer_stat = pd.ExcelWriter(os.path.join(self.workingDir, stationOut+"_tests.xlsx"), engine = 'xlsxwriter')
|
@@ -2741,11 +2748,39 @@ class Optimisation(wx.Frame):
|
|
2741
2748
|
curCatch:Catchment = self.myCases[idLauncher].refCatchment
|
2742
2749
|
cur_key = curCatch.get_key_catchmentDict(stationOut)
|
2743
2750
|
curBasin: SubBasin = curCatch.catchmentDict[cur_key]
|
2751
|
+
if type(curBasin) != SubBasin:
|
2752
|
+
logging.warning("The current module is not a SubBasin object!")
|
2753
|
+
return None
|
2744
2754
|
cur_fracts = curBasin.get_summary_fractions(summary="mean", interval=intervals)
|
2745
2755
|
|
2746
2756
|
return cur_fracts
|
2747
2757
|
|
2748
2758
|
|
2759
|
+
# TODO : to finish this function
|
2760
|
+
def _get_volume_fractions(self, idLauncher:int=0, stationOut:str="",
|
2761
|
+
intervals:list[tuple[datetime.datetime, datetime.datetime]]=[]) -> dict[list[str], list[float]]:
|
2762
|
+
|
2763
|
+
curCatch:Catchment = self.myCases[idLauncher].refCatchment
|
2764
|
+
cur_key = curCatch.get_key_catchmentDict(stationOut)
|
2765
|
+
curBasin: SubBasin = curCatch.catchmentDict[cur_key]
|
2766
|
+
if type(curBasin) != SubBasin:
|
2767
|
+
logging.warning("The current module is not a SubBasin object!")
|
2768
|
+
return None
|
2769
|
+
cur_fracts = curBasin.get_volume_fractions(interval=intervals)
|
2770
|
+
return cur_fracts
|
2771
|
+
|
2772
|
+
# FIXME : to improve and generalise
|
2773
|
+
def _get_max_runoff(self, idLauncher:int=0, stationOut:str="",
|
2774
|
+
intervals:list[tuple[datetime.datetime, datetime.datetime]]=[]) -> dict[list[str], list[float]]:
|
2775
|
+
|
2776
|
+
curCatch:Catchment = self.myCases[idLauncher].refCatchment
|
2777
|
+
cur_key = curCatch.get_key_catchmentDict(stationOut)
|
2778
|
+
curBasin: SubBasin = curCatch.catchmentDict[cur_key]
|
2779
|
+
cur_fracts = curBasin.get_summary_fractions(summary="max", interval=intervals)
|
2780
|
+
|
2781
|
+
return cur_fracts["% qof"]
|
2782
|
+
|
2783
|
+
|
2749
2784
|
def _get_ratio_max_sim_obs(self, idLauncher:int=0, stationOut:str="",
|
2750
2785
|
intervals:list[tuple[datetime.datetime, datetime.datetime]]=[]) -> float:
|
2751
2786
|
|
@@ -2795,6 +2830,8 @@ class Optimisation(wx.Frame):
|
|
2795
2830
|
def plot_equifinality(self, event, idLauncher:int=0):
|
2796
2831
|
|
2797
2832
|
physical_properties = ["%qof", "%qif", "%qbf", "%loss"]
|
2833
|
+
physical_properties_vol = ['% qof volume', '% qif volume', '% qbf volume', '% loss volume']
|
2834
|
+
# physical_properties_vol = [el+" volume" for el in physical_properties]
|
2798
2835
|
colors_properties = ["b", "g", "k", "orange"]
|
2799
2836
|
y_label = "Nash"
|
2800
2837
|
|
@@ -2820,6 +2857,19 @@ class Optimisation(wx.Frame):
|
|
2820
2857
|
ax.set_title("Proportion of rain : "+stationOut)
|
2821
2858
|
ax.legend()
|
2822
2859
|
fig.savefig(os.path.join(self.workingDir, "Equifinality_physical_prop_"+stationOut+".png"))
|
2860
|
+
# Plot the physical property volumes
|
2861
|
+
fig, ax = plt.subplots()
|
2862
|
+
for cur_prop, cur_color in zip(physical_properties_vol, colors_properties):
|
2863
|
+
cur_columns = [col for col in df.columns if cur_prop.replace(" ", "") in col.replace(" ", "")]
|
2864
|
+
if cur_columns != []:
|
2865
|
+
corr_prop = cur_columns[0]
|
2866
|
+
ax.scatter(df.loc[:,corr_prop], df.loc[:,y_label], s=0.5, c=cur_color,
|
2867
|
+
marker='o', label=cur_prop, alpha=0.4)
|
2868
|
+
ax.set_xlabel("% of the rain volume [-]")
|
2869
|
+
ax.set_ylabel(y_label+" [-]")
|
2870
|
+
ax.set_title("Proportion of rain volume : "+stationOut)
|
2871
|
+
ax.legend()
|
2872
|
+
fig.savefig(os.path.join(self.workingDir, "Equifinality_physical_prop_volumes_"+stationOut+".png"))
|
2823
2873
|
# Plot the Probability of exceedance
|
2824
2874
|
cur_color = colors_properties[0]
|
2825
2875
|
x_label = "P. of exceedance"
|
@@ -2841,7 +2891,16 @@ class Optimisation(wx.Frame):
|
|
2841
2891
|
ax.set_title("Peak analysis : "+stationOut)
|
2842
2892
|
ax.legend()
|
2843
2893
|
fig.savefig(os.path.join(self.workingDir, "Equifinality_peaks_ratio_"+stationOut+".png"))
|
2844
|
-
|
2894
|
+
# Plot % of the max runoff
|
2895
|
+
x_label = "% max runoff"
|
2896
|
+
fig, ax = plt.subplots()
|
2897
|
+
if x_label in df.columns:
|
2898
|
+
ax.scatter(df.loc[:,x_label], df.loc[:,y_label], s=0.5, c=cur_color, marker='o', label=x_label)
|
2899
|
+
ax.set_xlabel(x_label +" [-]")
|
2900
|
+
ax.set_ylabel(y_label+" [-]")
|
2901
|
+
ax.set_title("Max runoff [%] : "+stationOut)
|
2902
|
+
ax.legend()
|
2903
|
+
fig.savefig(os.path.join(self.workingDir, "Equifinality_max_runoff_"+stationOut+".png"))
|
2845
2904
|
else:
|
2846
2905
|
logging.error("The file "+filename+" does not exist!")
|
2847
2906
|
|