Compare commits

..

No commits in common. "a61d130baa12a1041d15b4634e1645e3108b316e" and "3e094af325e197daf0837262659fd9b9a08b927f" have entirely different histories.

2 changed files with 79 additions and 102 deletions

View File

@ -1107,7 +1107,7 @@ class Mage8(Mage):
# Profile ID offset # Profile ID offset
reach_offset[r] = i1 reach_offset[r] = i1
profile_len.append(i2 - i1 + 1) profile_len.append(i2-i1+1)
logger.debug(f"read_bin: iprofiles = {len(iprofiles)}") logger.debug(f"read_bin: iprofiles = {len(iprofiles)}")
@ -1161,7 +1161,7 @@ class Mage8(Mage):
ri = i - reach_offset[reach] ri = i - reach_offset[reach]
# Set data for profile RI # Set data for profile RI
# reach.set(ri, timestamp, key, d) reach.set(ri, timestamp, key, d)
if key == "Z": if key == "Z":
profile = reach.profile(ri) profile = reach.profile(ri)
limits = profile.geometry.get_water_limits(d) limits = profile.geometry.get_water_limits(d)
@ -1201,7 +1201,7 @@ class Mage8(Mage):
table["Q"][ti, p.global_index], table["Q"][ti, p.global_index],
table["Z"][ti, p.global_index], table["Z"][ti, p.global_index],
) )
# r.set(pi, t, "V", v) r.set(pi, t, "V", v)
velocity_arr[ti, j] = v velocity_arr[ti, j] = v
j += 1 j += 1
@ -1210,9 +1210,9 @@ class Mage8(Mage):
logger.info(f"read_bin: ... end with {len(ts)} timestamp read") logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
# results.bufferize("Z") results.bufferize("Z")
# results.bufferize("Q") results.bufferize("Q")
# results.bufferize("V") results.bufferize("V")
logger.info(f"reading time: '{time.time() - start}'") logger.info(f"reading time: '{time.time() - start}'")
@timer @timer
@ -1282,8 +1282,8 @@ class Mage8(Mage):
reachs.append(r) reachs.append(r)
# ID of first and last reach profiles # ID of first and last reach profiles
i1 = data[2 * i] - 1 i1 = data[2*i] - 1
i2 = data[2 * i + 1] - 1 i2 = data[2*i+1] - 1
# Add profile id correspondance to reach # Add profile id correspondance to reach
key = (i1, i2) key = (i1, i2)
@ -1394,26 +1394,26 @@ class Mage8(Mage):
r.profiles r.profiles
)) ))
z_br = list(map( z_br = list(map(
lambda z, sl: reduce( lambda z, sl: reduce(
lambda z, h: z - h[0], lambda z, h: z - h[0],
sl, z sl, z
), ),
z_min, # Original geometry z_min, # Original geometry
sls # Original sediment layers sls # Original sediment layers
)) ))
for t in ts_list: for t in ts_list:
sls = list(map( sls = list(map(
lambda p: p.get_ts_key(t, "sl")[0], lambda p: p.get_ts_key(t, "sl")[0],
r.profiles r.profiles
)) ))
zfd = list(map( zfd = list(map(
lambda z, sl: reduce( lambda z, sl: reduce(
lambda z, h: z + h[0], lambda z, h: z + h[0],
sl, z sl, z
), ),
z_br, # bedrock z_br, # bedrock
sls # Original sediment layers sls # Original sediment layers
)) ))
for i, p in enumerate(r.profiles): for i, p in enumerate(r.profiles):
r.set(i, t, "zfd", zfd[i]) r.set(i, t, "zfd", zfd[i])

View File

@ -91,6 +91,7 @@ class CustomPlot(PamhyrPlot):
self.lines = {} self.lines = {}
def draw_bottom_with_bedload(self, reach): def draw_bottom_with_bedload(self, reach):
rk = reach.geometry.get_rk() rk = reach.geometry.get_rk()
z = list( z = list(
map( map(
@ -340,7 +341,8 @@ class CustomPlot(PamhyrPlot):
line1 = ax.plot( line1 = ax.plot(
rk, vmax, lw=1., rk, vmax, lw=1.,
color='g', linestyle='dotted', color='g',
linestyle='dotted',
) )
self.lines["velocity_envelop"] = line1 self.lines["velocity_envelop"] = line1
vmin = [min(v) for v in velocities] vmin = [min(v) for v in velocities]
@ -395,7 +397,7 @@ class CustomPlot(PamhyrPlot):
d = list(map( d = list(map(
lambda p1, p2: p1 - p2, map( lambda p1, p2: p1 - p2, map(
lambda p: np.max(table["Z"][:, p.global_index]), lambda p: max(p.get_key("Z")),
reach.profiles reach.profiles
), z_min) ), z_min)
) )
@ -572,9 +574,6 @@ class CustomPlot(PamhyrPlot):
reach1 = self.data[0].river.reach(self._current_reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._current_reach) reach2 = self.data[1].river.reach(self._current_reach)
table = results.get("table")
id_ts = results.get_timestamp_id(self._current_timestamp)
rk = reach.geometry.get_rk() rk = reach.geometry.get_rk()
z_min = reach.geometry.get_z_min() z_min = reach.geometry.get_z_min()
if reach.has_bedload(): if reach.has_bedload():
@ -584,19 +583,19 @@ class CustomPlot(PamhyrPlot):
q = list( q = list(
map( map(
lambda p: table["Q"][id_ts, p.global_index], lambda p: p.get_ts_key(self._current_timestamp, "Q"),
reach.profiles reach.profiles
) )
) )
z = list( z = list(
map( map(
lambda p: table["Z"][id_ts, p.global_index], lambda p: p.get_ts_key(self._current_timestamp, "Z"),
reach.profiles reach.profiles
) )
) )
v = list( v = list(
map( map(
lambda p: table["Z"][id_ts, p.global_index], lambda p: p.get_ts_key(self._current_timestamp, "V"),
reach.profiles reach.profiles
) )
) )
@ -643,8 +642,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach.profiles reach.profiles
) )
) )
@ -652,16 +650,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach2.profiles reach2.profiles
) )
) )
@ -679,8 +675,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach.profiles reach.profiles
) )
) )
@ -688,16 +683,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach2.profiles reach2.profiles
) )
) )
@ -714,50 +707,41 @@ class CustomPlot(PamhyrPlot):
if self._current_res_id < 2: if self._current_res_id < 2:
fr = list( fr = list(
map( map(
lambda p: ( lambda p:
table["V"][id_ts, p.global_index] / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
table["Z"][id_ts, p.global_index] self._current_timestamp, "Z")) /
) / p.geometry.wet_width(p.get_ts_key(
p.geometry.wet_width( self._current_timestamp, "Z"))
table["Z"][id_ts, p.global_index] )),
)
))
),
reach.profiles reach.profiles
) )
) )
else: else:
fr1 = list( fr1 = list(
map( map(
lambda p: ( lambda p:
table["V"][id_ts, p.global_index] / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
table["Z"][id_ts, p.global_index] self._current_timestamp, "Z")) /
) / p.geometry.wet_width(p.get_ts_key(
p.geometry.wet_width( self._current_timestamp, "Z"))
table["Z"][id_ts, p.global_index] )),
)
))
),
reach1.profiles reach1.profiles
) )
) )
fr2 = list( fr2 = list(
map( map(
lambda p: ( lambda p:
table["V"][id_ts, p.global_index] / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
table["Z"][id_ts, p.global_index] self._current_timestamp, "Z")) /
) / p.geometry.wet_width(p.get_ts_key(
p.geometry.wet_width( self._current_timestamp, "Z"))
table["Z"][id_ts, p.global_index] )),
)
))
),
reach2.profiles reach2.profiles
) )
) )
@ -775,8 +759,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach.profiles reach.profiles
) )
) )
@ -784,16 +767,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
table["Z"][id_ts, p.global_index] p.get_ts_key(self._current_timestamp, "Z")),
),
reach2.profiles reach2.profiles
) )
) )
@ -864,7 +845,6 @@ class CustomPlot(PamhyrPlot):
shift += 60 shift += 60
ts = self._parent._timestamps ts = self._parent._timestamps
table = results.get("table")
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._current_reach) reach1 = self.data[0].river.reach(self._current_reach)
@ -872,18 +852,17 @@ class CustomPlot(PamhyrPlot):
profile1 = reach1.profile(self._current_profile_id) profile1 = reach1.profile(self._current_profile_id)
profile2 = reach2.profile(self._current_profile_id) profile2 = reach2.profile(self._current_profile_id)
q1 = table["Q"][:, profile1.global_index] q1 = profile1.get_key("Q")
z1 = table["Z"][:, profile1.global_index] z1 = profile1.get_key("Z")
v1 = table["V"][:, profile1.global_index] v1 = profile1.get_key("V")
q2 = table["Q"][:, profile2.global_index] q2 = profile2.get_key("Q")
z2 = table["Z"][:, profile2.global_index] z2 = profile2.get_key("Z")
v2 = table["V"][:, profile2.global_index] v2 = profile2.get_key("V")
q = table["Q"][:, profile.global_index]
z = table["Z"][:, profile.global_index]
v = table["V"][:, profile.global_index]
q = profile.get_key("Q")
z = profile.get_key("Z")
v = profile.get_key("V")
z_min = profile.geometry.z_min() z_min = profile.geometry.z_min()
if self._current_res_id < 2: if self._current_res_id < 2:
if reach.has_bedload(): if reach.has_bedload():
@ -1091,32 +1070,30 @@ class CustomPlot(PamhyrPlot):
self.update_legend() self.update_legend()
def _redraw_time(self): def _redraw_time(self):
results = self.data[self._current_res_id] results = self.data[self._current_res_id]
reach = results.river.reach(self._current_reach) reach = results.river.reach(self._current_reach)
profile = reach.profile(self._current_profile_id) profile = reach.profile(self._current_profile_id)
ts = list(results.get("timestamps")) ts = list(results.get("timestamps"))
ts.sort() ts.sort()
table = results.get("table")
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._current_reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._current_reach) reach2 = self.data[1].river.reach(self._current_reach)
profile1 = reach1.profile(self._current_profile_id) profile1 = reach1.profile(self._current_profile_id)
profile2 = reach2.profile(self._current_profile_id) profile2 = reach2.profile(self._current_profile_id)
q1 = table["Q"][:, profile1.global_index] q1 = profile1.get_key("Q")
z1 = table["Z"][:, profile1.global_index] z1 = profile1.get_key("Z")
v1 = table["V"][:, profile1.global_index] v1 = profile1.get_key("V")
q2 = table["Q"][:, profile2.global_index] q2 = profile2.get_key("Q")
z2 = table["Z"][:, profile2.global_index] z2 = profile2.get_key("Z")
v2 = table["V"][:, profile2.global_index] v2 = profile2.get_key("V")
q = table["Q"][:, profile.global_index]
z = table["Z"][:, profile.global_index]
v = table["V"][:, profile.global_index]
q = profile.get_key("Q")
z = profile.get_key("Z")
v = profile.get_key("V")
if self._current_res_id < 2: if self._current_res_id < 2:
if reach.has_bedload(): if reach.has_bedload():
ts_z_min = self.get_ts_zmin( ts_z_min = self.get_ts_zmin(