1
Fork 0
internship/olaflow/processing/pickle.py

40 lines
1.1 KiB
Python
Raw Normal View History

2022-04-13 14:08:55 +02:00
import argparse
import configparser
import logging
import pathlib
import pickle
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
from .olaflow import OFModel
parser = argparse.ArgumentParser(description="Post-process olaflow results")
parser.add_argument("-v", "--verbose", action="count", default=0)
parser.add_argument("-c", "--config", default="config.ini")
parser.add_argument("-o", "--output", type=pathlib.Path)
args = parser.parse_args()
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
log = logging.getLogger("ola_post")
log.info("Starting sws -> olaFlow converter")
config = configparser.ConfigParser()
config.read(args.config)
out = pathlib.Path(config.get("post", "pickle"))
out.parent.mkdir(parents=True, exist_ok=True)
olaflow_root = args.output
model = OFModel(olaflow_root)
model.read_mesh()
model.read_time()
model.read_field_all("alpha.water")
model.read_field_all("porosity")
model.read_field_all("p")
model.read_field_all("p_rgh")
model.read_field_all("U")
with out.open("wb") as f:
pickle.dump(model, f)