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

41 lines
1.1 KiB
Python

import argparse
import gzip
import configparser
import logging
import pathlib
import pickle
from time import time
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", "out"))
out.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 gzip.open(out.joinpath("pickle.gz"), "wb") as f:
pickle.dump(model, f)