diff --git a/src/Solver/Mage.py b/src/Solver/Mage.py index 4836d39fb0d1f8b7ac916568b2fd3b2066db7775..f6346b66bf64a3b0d31cbb8ea77d59869a0632e1 100644 --- a/src/Solver/Mage.py +++ b/src/Solver/Mage.py @@ -149,19 +149,25 @@ class Mage(AbstractSolver): c1 = f"{profile.code1:>6}" c2 = f"{profile.code2:>6}" t = f"{len(profile.points):>6}" - kp = f"{profile.kp:>13.4f}" + kp = f"{profile.kp:>12f}"[0:12] pname = profile.name if profile.name == "": - pname = f"p{profile.id:>3}".replace(" ", "p") - name = f"{pname}" + # Generate name from profile id prefixed with + # 'p' (and replace space char with '0' char) + pname = f"p{profile.id:>3}".replace(" ", "0") + name = f"{pname:<19}" + # Generate sediment additional data if available sediment = "" if profile.sl is not None: if not any(filter(lambda f: ".GRA" in f, files)): files.append(gra_file) + # Number of layers nl = len(profile.sl) sediment = f" {nl:>3}" + + # Layers data for layer in profile.sl.layers: sediment += ( f" {layer.height:>10} {layer.d50:>10} " + @@ -169,20 +175,26 @@ class Mage(AbstractSolver): f"{layer.critical_constraint:>10}" ) - f.write(f"{num}{c1}{c2}{t}{kp} {name} {sediment}\n") + # Profile header line + f.write(f"{num}{c1}{c2}{t} {kp} {name} {sediment}\n") cnt_num += 1 + # Points for point in profile.points: - x = f"{point.x:>13.4f}" - y = f"{point.y:>13.4f}" - z = f"{point.z:>13.4f}" + x = f"{point.x:<12f}"[0:12] + y = f"{point.y:<12f}"[0:12] + z = f"{point.z:<12f}"[0:12] n = f"{point.name:<3}" + # Generate sediment additional data if available sediment = "" prev = point.z if point.sl is not None: + # Number of layers nl = len(point.sl) sediment = f"{nl:>3}" + + # Layers data for layer in point.sl.layers: prev = round(prev - layer.height, 5) sediment += ( @@ -191,8 +203,10 @@ class Mage(AbstractSolver): f"{layer.critical_constraint:>10}" ) - f.write(f"{x}{y}{z} {n} {sediment}\n") + # Point line + f.write(f"{x} {y} {z}{n} {sediment}\n") + # Profile last line f.write(f" 999.9990 999.9990 999.9990\n") return files