from pathlib import Path import numpy as np OUT = Path("geoclaw_topo_sample") OUT.mkdir(exist_ok=True) nx, ny = 120, 80 x = np.linspace(0.0, 1200.0, nx) y = np.linspace(0.0, 800.0, ny) xx, yy = np.meshgrid(x, y) z = -2.0 + 0.006 * xx + 0.8 * np.sin(2 * np.pi * yy / 800.0) z += 1.5 * np.exp(-((yy - 400.0) / 90.0) ** 2) topo_path = OUT / "sample_topography_topotype3.txt" with topo_path.open("w", encoding="utf-8") as f: f.write(f"{nx} ncols\n") f.write(f"{ny} nrows\n") f.write(f"{x.min()} xll\n") f.write(f"{y.min()} yll\n") f.write(f"{x[1] - x[0]} cellsize\n") f.write("-9999 nodata_value\n") for row in z[::-1]: f.write(" ".join(f"{v:.3f}" for v in row) + "\n") print("GeoClaw topography template exported:", topo_path)