1
Fork 0

Added logging

This commit is contained in:
Edgar P. Burkhart 2022-03-02 11:51:53 +01:00
parent f329690c3d
commit 0461cb7e08
Signed by: edpibu
GPG Key ID: 9833D3C5A25BD227
1 changed files with 9 additions and 0 deletions

View File

@ -15,19 +15,23 @@ except ImportError:
logging.basicConfig(level="INFO")
log = logging.getLogger("bathy")
log.info("Starting bathymetry pre-processing")
config = configparser.ConfigParser()
config.read("config.ini")
root = pathlib.Path(config.get("data", "root"))
log.info(f"Reading input data from '{root}'")
bathy_hires = np.loadtxt(root.joinpath(config.get("data", "hires")))
bathy_lores = np.loadtxt(root.joinpath(config.get("data", "bathy")))
hstru = np.loadtxt(root.joinpath(config.get("data", "hstru")))
log.info("Generating grid")
x_hires = np.arange(-0.5 * bathy_hires.size, 0, 0.5)
x_lores = np.arange(-1 * bathy_lores.size, 0, 1)
x_hstru = np.arange(-0.5 * hstru.size, 0, 0.5)
log.info("Generating output data")
bathy_hires_pd = pd.Series(bathy_hires.copy(), index=x_hires)
bathy_lores_pd = pd.Series(bathy_lores.copy(), index=x_lores)
@ -42,6 +46,7 @@ bathy.hstru = 0
bathy.loc[x_hstru, "hstru"] = hstru
if config.has_section("out"):
log.info("Writing output data")
out = pathlib.Path(config.get("out", "root"))
np.savetxt(out.joinpath("bathy.dat"), bathy.z, newline=" ")
np.savetxt(out.joinpath("hstru.dat"), bathy.hstru, newline=" ")
@ -51,6 +56,8 @@ if config.getboolean("proc", "plot", fallback=False):
log.error("Could not import PyPlot")
sys.exit(1)
log.info("Plotting data")
fig, ax = plt.subplots()
ax.plot(x_hires, bathy_hires, label="High-res")
ax.plot(x_lores, bathy_lores, label="Low-res")
@ -60,3 +67,5 @@ if config.getboolean("proc", "plot", fallback=False):
ax.grid()
ax.legend()
plt.show(block=True)
log.info("Processing finished")