mirror of https://gitlab.com/pamhyr/pamhyr2
Mage: Update mage gra file reader for mage 83.
parent
dfff8d2fcb
commit
e6de528b7f
|
|
@ -998,7 +998,7 @@ class Mage8(Mage):
|
|||
logger.debug(f"read_gra: nb_profile = {nb_profile}")
|
||||
logger.debug(f"read_gra: mage_version = {mage_version}")
|
||||
|
||||
if mage_version <= 80:
|
||||
if mage_version < 80:
|
||||
msg = (
|
||||
"Read GRA files: " +
|
||||
f"Possible incompatible mage version '{mage_version}', " +
|
||||
|
|
@ -1066,60 +1066,69 @@ class Mage8(Mage):
|
|||
def ip_to_ri(r, i): return i - reach_offset[r]
|
||||
|
||||
ts = set()
|
||||
ind = 0
|
||||
end = False
|
||||
|
||||
newline()
|
||||
while not end:
|
||||
n = read_int(1)[0]
|
||||
timestamp = read_float64(1)[0]
|
||||
with_bedload = read_int(1)[0]
|
||||
|
||||
logger.debug(f"read_gra: Number of cross section: {n}")
|
||||
logger.debug(f"read_gra: Timestamp: {timestamp}")
|
||||
logger.debug(f"read_gra: Type of bedload: {with_bedload}")
|
||||
|
||||
endline()
|
||||
|
||||
npts = [1] * n
|
||||
if with_bedload == 1:
|
||||
newline()
|
||||
npts = read_int(n)
|
||||
endline()
|
||||
sum_npts = sum(npts)
|
||||
logger.debug(f"read_gra: Number of points: {sum_npts}")
|
||||
|
||||
newline()
|
||||
nsl = read_int(sum_npts)
|
||||
logger.debug(f"read_gra: Number of sedimentary layers: {nsl}")
|
||||
endline()
|
||||
|
||||
newline()
|
||||
data = read_float64(sum(nsl) * 3)
|
||||
endline()
|
||||
|
||||
logger.debug(f"read_gra: timestamp = {timestamp} sec")
|
||||
ts.add(timestamp)
|
||||
|
||||
endline()
|
||||
|
||||
i_pts = 0
|
||||
i_data = 0
|
||||
# Loop on cross section
|
||||
for i in range(n):
|
||||
newline()
|
||||
nsl = read_int(1)[0]
|
||||
endline()
|
||||
|
||||
# Get current profile id
|
||||
sec_sl = []
|
||||
reach = ip_to_r(i)
|
||||
ri = ip_to_ri(reach, i)
|
||||
|
||||
if nsl > 1:
|
||||
logger.warning(
|
||||
"read_gra: " +
|
||||
"Multiple sediment layers for one profile " +
|
||||
"is not implemented yet..."
|
||||
)
|
||||
|
||||
for j in range(nsl):
|
||||
newline()
|
||||
nl = read_int(1)[0]
|
||||
endline()
|
||||
p_i = ip_to_ri(reach, i)
|
||||
|
||||
# Loop on cross section points
|
||||
for j in range(npts[i]):
|
||||
sl = []
|
||||
|
||||
for k in range(nl):
|
||||
newline()
|
||||
data = read_float64(3)
|
||||
endline()
|
||||
|
||||
h = data[0]
|
||||
d50 = data[1]
|
||||
sigma = data[2]
|
||||
# Loop on sediment layers
|
||||
for k in range(nsl[i_pts]):
|
||||
h = data[i_data]
|
||||
d50 = data[i_data + 1]
|
||||
sigma = data[i_data + 2]
|
||||
|
||||
sl.append((h, d50, sigma))
|
||||
i_data += 3
|
||||
|
||||
reach.set(ri, timestamp, "sl", sl)
|
||||
i_pts += 1
|
||||
sec_sl.append(sl)
|
||||
|
||||
ind += 1
|
||||
reach.set(p_i, timestamp, "sl", sec_sl)
|
||||
|
||||
logger.debug(f"read_gra: data size = {len(data)} ({i_data} readed)")
|
||||
end = newline().size <= 0
|
||||
|
||||
logger.debug(reachs[0].profiles[0]._data)
|
||||
results.set("timestamps", ts)
|
||||
results.set("sediment_timestamps", ts)
|
||||
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
||||
|
||||
@timer
|
||||
|
|
|
|||
Loading…
Reference in New Issue