import argparse import configparser import logging import pathlib import numpy as np import pandas as pd from .read_swash import ReadSwash parser = argparse.ArgumentParser(description="Convert swash output to numpy") parser.add_argument("-v", "--verbose", action="count", default=0) args = parser.parse_args() logging.basicConfig(level=max((10, 20 - 10 * args.verbose))) log = logging.getLogger("sws_npz") log.info("Starting sws -> npz converter") config = configparser.ConfigParser() config.read("config.ini") sws_out = pathlib.Path(config.get("swash", "out")) inp = pathlib.Path(config.get("post", "inp")) log.info(f"Reading swash output from '{sws_out}'") rsws = ReadSwash() rsws.read_time(sws_out.joinpath("tsec.dat")) rsws.read_x(sws_out.joinpath("xp.dat")) log.info("Reading 'dep'") rsws.read_scalar(sws_out.joinpath("dep.dat")) log.info("Reading 'botl'") rsws.read_scalar(sws_out.joinpath("botl.dat")) log.info("Reading 'watl'") rsws.read_scalar(sws_out.joinpath("watl.dat")) # log.info("Reading 'press'") # rsws.read_scalar(sws_out.joinpath("press.dat")) # log.info("Reading 'disch'") # rsws.read_vector(sws_out.joinpath("disch.dat")) # log.info("Reading 'ustar'") # rsws.read_scalar(sws_out.joinpath("ustar.dat")) log.info("Reading 'vel'") rsws.read_vector(sws_out.joinpath("vel.dat")) # log.info("Reading 'vz'") # rsws.read_scalar_lay(sws_out.joinpath("vz.dat")) # log.info("Reading 'velk'") # rsws.read_vector_lay(sws_out.joinpath("velk.dat")) # log.info("Reading 'zk'") # rsws.read_scalar_lay(sws_out.joinpath("zk.dat")) # log.info("Reading 'brkp'") # rsws.read_scalar(sws_out.joinpath("brkp.dat")) log.info(f"Writing npz file in '{inp}'") inp.mkdir(exist_ok=True) np.savez_compressed(inp.joinpath("sws"), t=rsws.t, x=rsws.x, *rsws.data)