1
Fork 0
internship/swash/processing/mat_npz.py

43 lines
1.2 KiB
Python

import argparse
import configparser
from datetime import datetime, time
import logging
import pathlib
import re
from multiprocessing.pool import ThreadPool
import numpy as np
import scipy.io as sio
from .read_mat import ReadSwash
parser = argparse.ArgumentParser(description="Convert swash output to numpy")
parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
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(args.config)
sws_out = pathlib.Path(config.get("swash", "out"))
inp = pathlib.Path(config.get("post", "inp"))
inp.mkdir(parents=True, exist_ok=True)
log.info(f"Reading swash output from '{sws_out}'")
swr = ReadSwash(sws_out, inp)
swr.save("t")
swr.save("x")
swr.save("c", "botl", "Botlev")
swr.save("s", "watl", "Watlev")
swr.save("s", "press", "Press")
swr.save("v", "vel", "vel")
swr.save("sk", "zk", "zk")
swr.save("sk", "nhprsk", "Nprs_k")
swr.save("sk", "pressk", "Pres_k")
swr.save("sk", "vz", "w")
swr.save("vk", "velk", "vel_k")