mirror of https://gitlab.com/pamhyr/pamhyr2
Solver: RubarBE: Factorise some code.
parent
21e6c410e2
commit
df3b3b604d
|
|
@ -557,6 +557,17 @@ class Rubar3(CommandLineSolver):
|
|||
line = f.readline().split()
|
||||
return tuple(map(float, line))
|
||||
|
||||
def set_and_compute_limites(reach, ind, z, q, s):
|
||||
reach.set(0, timestamp, "Z", z)
|
||||
reach.set(0, timestamp, "Q", q)
|
||||
reach.set(0, timestamp, "V", s)
|
||||
|
||||
profile = reach.profile(ind)
|
||||
limits = profile.geometry.get_water_limits(z)
|
||||
reach.set(
|
||||
ind, timestamp, "water_limits", limits
|
||||
)
|
||||
|
||||
ts = set()
|
||||
end = False
|
||||
while True:
|
||||
|
|
@ -565,31 +576,33 @@ class Rubar3(CommandLineSolver):
|
|||
return
|
||||
|
||||
timestamp = float(line)
|
||||
ts.add(timestamp)
|
||||
|
||||
for reach, lm in reachs:
|
||||
# First profile
|
||||
z, s, q, e = read_data_line(f)
|
||||
reach.set(0, timestamp, "Z", z)
|
||||
reach.set(0, timestamp, "Q", q)
|
||||
reach.set(0, timestamp, "V", s)
|
||||
set_and_compute_limites(reach, 0, z, q, s)
|
||||
|
||||
# For each profile
|
||||
ind = 1
|
||||
pz, ps, pq, pe = read_data_line(f)
|
||||
while ind < lm - 2:
|
||||
z, s, q, e = read_data_line(f)
|
||||
reach.set(ind, timestamp, "Z", (z + pz) / 2)
|
||||
reach.set(ind, timestamp, "Q", (q + pq) / 2)
|
||||
reach.set(ind, timestamp, "V", (q + ps) / 2)
|
||||
set_and_compute_limites(
|
||||
reach, ind,
|
||||
(pz + z) / 2,
|
||||
(pq + q) / 2,
|
||||
(ps + s) / 2
|
||||
)
|
||||
|
||||
pz, ps, pq, pe = z, s, q, e
|
||||
ind += 1
|
||||
|
||||
# Last profile
|
||||
z, s, q, e = read_data_line(f)
|
||||
reach.set(ind, timestamp, "Z", z)
|
||||
reach.set(ind, timestamp, "Q", q)
|
||||
reach.set(ind, timestamp, "V", s)
|
||||
set_and_compute_limites(reach, ind, z, q, s)
|
||||
|
||||
results.set("timestamps", ts)
|
||||
|
||||
@timer
|
||||
def results(self, study, repertory, qlog=None, name="0"):
|
||||
|
|
|
|||
Loading…
Reference in New Issue