From 898aad3da5f3c76ae5652e25c2ff38ac2dc193da Mon Sep 17 00:00:00 2001 From: Theophile Terraz <theophile.terraz@inrae.fr> Date: Wed, 21 Aug 2024 15:45:42 +0200 Subject: [PATCH] add wet arrea in custom plots + slider mark --- doc/users/Tuto1/step2.pamhyr | Bin 200704 -> 208896 bytes doc/users/Tuto1/step3.pamhyr | Bin 229376 -> 237568 bytes src/View/Results/CustomPlot/Plot.py | 64 ++++++++++++++++++++++- src/View/Results/CustomPlot/Translate.py | 2 + src/View/Results/PlotH.py | 31 +++++------ 5 files changed, 78 insertions(+), 19 deletions(-) diff --git a/doc/users/Tuto1/step2.pamhyr b/doc/users/Tuto1/step2.pamhyr index e10e685b6ce4b9e25e4542a1b28f15fdaa745870..c7516dff606939dd005eafa8e54776cee528a4ee 100644 GIT binary patch delta 575 zcmZozz|-)6XM(gKI|BoQF%ZLm+(aE?M)r*f^Z6xtc=@dvIC!lX_`Ue`c&+#k@o(dw z%%9I6v$0W$ce9l&3zH!~OdF6EU}Tn-EK4ma&dkp<&@<38G!*1uR_8A+DNU)2FG|fx zO)O3|n4B-4#i%v0QB8sisD*>Shk<`1|6%?+{PXzV@b~ba;s3g^v4mepkXfA(MI*=N zdHQJ^n0Xi@HnTqnWZazoD~FM*nS+~M+|-n@)p&B@FUiTzAAMjd%AV}_UWP3-FC`wr zoLv8(XS4E?Qf4et>wfZ1p7Bb2^PlI2EKupq-fy-s%X6hO@G#ghaI9rN%C?5}0rMYb z3C1IQl04fO?6_BPZJ6jNx7qGPHz!CB<5$_qFMigu0Da>*vC-A6v0Q>(Twb2B*|sDx zDJQikwIDtxGcUCm&M<Zka&-)GRS0o(@^Mvw3QsQhXFK`qKefqw-zu<x)K6A?D#Ko! zp92cd$*aFhc{g#2vy1EMGB&${%}q>6$t(c|bYf0?T4qjaF*@G}#THaq6w3+{OEN%~ tF_)xPOrH2nX7lzxPE63im>m0`gAp8{%{KqrZT>TExB1U>L}1Yd1puoH#})tp delta 325 zcmZp8z|*jRXM(gKD+2?AArQlW$V44uM%Il9^ZCWOdHJmw*m<oO_}}yE@mld8;@`$U znLmGHqYCe4D_IsMMw5w+29xvUvlt~OI*O|EGcrqym!%dJXXfV_=o#pla{<j{=by*G zzmfki{~i8${BQWr@PFMbXwbpGd7ggS24-%iBb(VD1TwPl|6rZDu`z>j^N~lwj7-@D zlO5m7u%+gu#6y^q>;Lm?R(?{-j74hQPu|HhUWsr1^W2aHD!tkJ%{FFv?#m3^40a4$ z=^Sg>kFu>{eZc&OS%UEhpCr#V20O+*6CLF?+kNQf1nFV?Dm(eb&-%>~4|5n<fR27V ivGM-qZGW7ZpaxEk{m%|%HrxDfxB1Vw-R3{j5di>FUvH5B diff --git a/doc/users/Tuto1/step3.pamhyr b/doc/users/Tuto1/step3.pamhyr index 00a39e3a44170e11157d417d529b9238a17d726a..018a4aea279cf4566b96ce30dc3229f0bf7133cf 100644 GIT binary patch delta 580 zcmZo@;A=R*H$hrZl7WH23W#AqZlaDcqvXbf`TUYRy!_S-9K2Qx{NDU}yjJ{&__y&- z<}cun-K?mf#Jkx_mW9bk0HzN_3otTEOO~Y;6=&w>8R!}485#<5Fst(ymz1Vd#uugL zq$U=p8cZ&b&t%k^tSF!+!3EUA!QaEczmfki{~i8${BQVs_|Ncv1)5*NFC@sU&WNIw zWAi-yv<=KWj1imJ9|SUPPXCp|$koij%`R?g%Ghc=x$u|d<mZn*FcoD_c6=|xmYSCm z4`EKO|If2o`AI1=7O8bVc_+_!CBFI3b3+!W^k(lj+nD9K(iwOd>=-!KvL9tz!}@^v z53>a05k5(tZ47qYtGG5ybd=j{_o15;q=)gV?Bo|e>sf%_@dSFz)vU2xf?Zr*p0U}s zBrz!`wJ5b9J|{CTwHVH@at?BJ3~^Nmadh%=Re%alF8F6V`RqTn$$Q@_uz=K0R(vYM zUYwr;3ew4|ze{;Haf-8x>*_K#yMoP4Oi9Ts0fu#APJCKsPHHha-x9?ZR9O_u3KB~) vK$bC=q*hFx_)TW>_CHQc(9oD1`=5gm9HPxO|J!Z;Gj6x}&vc|=(FO$oq_oCx delta 328 zcmZoTz}L{gH$hrZoPmMC0*GNiWTK8Sqxi;z`TXMCy!_S-?7UVC{O|eoc&+#k@o(dw z%wMosQ9*@wvz06h({#fIMx)6E@|ld16CFj>`5Bp|#miEQiZk=`4D<~2%(;Muvh&Yl z;NQr9nEwv{JpMQQXZXKvRy63~-#kx0Z38nm(~-^W4+0rk_<yj@+^i^&!MORzBVk6S z?1IUT?`7Ch^HSm=%*pltc{VFQDP_hYweBbH<QcETH~)EV$O4t#?EPjNvpn}@25tsB z2Cj6Dwd_aP*04Tc{=+Q6c!W=qXB&eZ<DQ9*a+~cwbaR6AFn*Pt{NiW*=7@(mj4VJ` lKc1{8aDVf*Kh8{06DP<1XNNMIZT`30{Ab*5^PlNR0{~l}Zz})* diff --git a/src/View/Results/CustomPlot/Plot.py b/src/View/Results/CustomPlot/Plot.py index cb45863c..0f2ed5cb 100644 --- a/src/View/Results/CustomPlot/Plot.py +++ b/src/View/Results/CustomPlot/Plot.py @@ -37,6 +37,7 @@ unit = { "depth": "3-meter", "mean_depth": "3-meter", "froude": "4-dimensionless", + "wet_area": "5-m2", } @@ -174,7 +175,7 @@ class CustomPlot(PamhyrPlot): if "mean_depth" in self._y: - ax = self._axes[unit["depth"]] + ax = self._axes[unit["mean_depth"]] d = list( map( lambda p: p.geometry.mean_water_depth( @@ -213,6 +214,23 @@ class CustomPlot(PamhyrPlot): ) lines["froude"] = line + if "wet_area" in self._y: + + ax = self._axes[unit["wet_area"]] + d = list( + map( + lambda p: p.geometry.wet_area( + p.get_ts_key(self._timestamp, "Z")), + reach.profiles + ) + ) + + line = ax.plot( + rk, d, + color='blue', linestyle='--', lw=1., + ) + lines["wet_area"] = line + # Legend lns = reduce( lambda acc, line: acc + line, @@ -358,7 +376,7 @@ class CustomPlot(PamhyrPlot): if "mean_depth" in self._y: - ax = self._axes[unit["depth"]] + ax = self._axes[unit["mean_depth"]] d = list( map(lambda z: profile.geometry.mean_water_depth(z), z) ) @@ -386,6 +404,18 @@ class CustomPlot(PamhyrPlot): ) lines["froude"] = line + if "wet_area" in self._y: + + ax = self._axes[unit["wet_area"]] + d = list( + map(lambda z: profile.geometry.wet_area(z), z) + ) + + line = ax.plot( + ts, d, color='blue', linestyle='--', lw=1., + ) + lines["wet_area"] = line + self._customize_x_axes_time(ts) # Legend @@ -432,6 +462,21 @@ class CustomPlot(PamhyrPlot): self._draw_rk() elif self._x == "time": self._draw_time() + if self._x == "rk": + reach = self.data.river.reach(self._reach) + profile = reach.profile(self._profile) + x = profile.rk + elif self._x == "time": + x = self._timestamp + + self._current, = self.canvas.axes.plot( + [x, x], + self.canvas.axes.get_ylim(), + # label=self.label_timestamp, + color='grey', + linestyle="dashed", + lw=1., + ) self.canvas.figure.canvas.draw_idle() if self.toolbar is not None: @@ -441,6 +486,7 @@ class CustomPlot(PamhyrPlot): def update(self): if not self._init: self.draw() + self.draw_current() return def set_reach(self, reach_id): @@ -454,9 +500,23 @@ class CustomPlot(PamhyrPlot): if self._x != "rk": self.update() + else: + self.draw_current() def set_timestamp(self, timestamp): self._timestamp = timestamp if self._x != "time": self.update() + else: + self.draw_current() + + def draw_current(self): + if self._x == "rk": + reach = self.data.river.reach(self._reach) + profile = reach.profile(self._profile) + x = profile.rk + elif self._x == "time": + x = self._timestamp + self._current.set_data([x, x], self.canvas.axes.get_ylim()) + self.canvas.figure.canvas.draw_idle() diff --git a/src/View/Results/CustomPlot/Translate.py b/src/View/Results/CustomPlot/Translate.py index 6d96bf27..b00bab0a 100644 --- a/src/View/Results/CustomPlot/Translate.py +++ b/src/View/Results/CustomPlot/Translate.py @@ -58,6 +58,7 @@ class CustomPlotTranslate(ResultsTranslate): self._dict['2-ms'] = self._dict["unit_speed"] self._dict['3-meter'] = self._dict["unit_height"] self._dict['4-dimensionless'] = self._dict["unit_froude"] + self._dict['5-m2'] = self._dict["wet_area"] # SubDict @@ -73,4 +74,5 @@ class CustomPlotTranslate(ResultsTranslate): "depth": self._dict["max_depth"], "mean_depth": self._dict["mean_depth"], "froude": self._dict["froude"], + "wet_area": self._dict["wet_area"], } diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index 2ac499e4..90aa6674 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -88,13 +88,14 @@ class PlotH(PamhyrPlot): self.draw_max(reach) self.draw_data(reach, profile) - self.draw_current(reach, profile) + self.draw_current() self.set_ticks_time_formater() self.enable_legend() self.idle() + self.update_current() self._init = True def draw_data(self, reach, profile): @@ -111,21 +112,12 @@ class PlotH(PamhyrPlot): **self.plot_default_kargs ) - def draw_current(self, reach, profile): - min_y, max_y = reduce( - lambda acc, p: ( - acc[0] + [min(p.get_key("Q"))], - acc[1] + [max(p.get_key("Q"))] - ), - reach.profiles, - ([], []) - ) - + def draw_current(self): self._current, = self.canvas.axes.plot( [self._current_timestamp, self._current_timestamp], - [min(min_y), max(max_y)], + self.canvas.axes.get_ylim(), # label=self.label_timestamp, - color=self.color_plot_river_bottom, + color="grey", linestyle="dashed", lw=1., ) @@ -162,14 +154,14 @@ class PlotH(PamhyrPlot): def set_timestamp(self, timestamp): self._current_timestamp = timestamp - self.update() + self.update_current() + self.update_idle() def update(self): if not self._init: self.draw() self.update_data() - self.update_idle() def update_data(self): @@ -181,8 +173,13 @@ class PlotH(PamhyrPlot): self._line.set_data(x, y) - _, min_max = self._current.get_data() self._current.set_data( self._current_timestamp, - min_max + self.canvas.axes.get_ylim() + ) + + def update_current(self): + self._current.set_data( + self._current_timestamp, + self.canvas.axes.get_ylim() ) -- GitLab