mirror of https://gitlab.com/pamhyr/pamhyr2
Solver: Mage: read_bin: Optimize iprofiles.
parent
388368adad
commit
d87db5fd48
|
|
@ -1083,7 +1083,7 @@ class Mage8(Mage):
|
||||||
newline()
|
newline()
|
||||||
|
|
||||||
reachs = []
|
reachs = []
|
||||||
iprofiles = {}
|
iprofiles = []
|
||||||
profile_len = []
|
profile_len = []
|
||||||
reach_offset = {}
|
reach_offset = {}
|
||||||
|
|
||||||
|
|
@ -1099,14 +1099,14 @@ class Mage8(Mage):
|
||||||
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)
|
for key in range(i1, i2 + 1):
|
||||||
iprofiles[key] = r
|
iprofiles.append(i)
|
||||||
|
|
||||||
# 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 = {iprofiles}")
|
logger.debug(f"read_bin: iprofiles = {len(iprofiles)}")
|
||||||
|
|
||||||
endline()
|
endline()
|
||||||
|
|
||||||
|
|
@ -1124,18 +1124,6 @@ class Mage8(Mage):
|
||||||
# Data
|
# Data
|
||||||
newline()
|
newline()
|
||||||
|
|
||||||
@timer
|
|
||||||
def ip_to_r(i): return iprofiles[
|
|
||||||
next(
|
|
||||||
filter(
|
|
||||||
lambda k: k[0] <= i <= k[1],
|
|
||||||
iprofiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
@timer
|
|
||||||
def ip_to_ri(r, i): return i - reach_offset[r]
|
|
||||||
|
|
||||||
# check results and geometry consistency
|
# check results and geometry consistency
|
||||||
for i, r in enumerate(reachs):
|
for i, r in enumerate(reachs):
|
||||||
lp = len(r.profiles)
|
lp = len(r.profiles)
|
||||||
|
|
@ -1165,9 +1153,9 @@ class Mage8(Mage):
|
||||||
if key in ["Z", "Q"]:
|
if key in ["Z", "Q"]:
|
||||||
for i, d in enumerate(data):
|
for i, d in enumerate(data):
|
||||||
# Get reach corresponding to profile ID
|
# Get reach corresponding to profile ID
|
||||||
reach = ip_to_r(i)
|
reach = reachs[iprofiles[i]]
|
||||||
# Get profile id in reach
|
# Get profile id in reach
|
||||||
ri = ip_to_ri(reach, i)
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue