Compress pickled object
This commit is contained in:
parent
3d2b20a9a1
commit
1114754da4
3 changed files with 12 additions and 16 deletions
|
@ -17,6 +17,6 @@ tf = 14300
|
||||||
x0 = -150
|
x0 = -150
|
||||||
|
|
||||||
[post]
|
[post]
|
||||||
pickle = out_post/model.pickle
|
out = out_post
|
||||||
x = -50
|
x = -50
|
||||||
z = 5
|
z = 5
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import configparser
|
import configparser
|
||||||
|
import gzip
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import pathlib
|
import pathlib
|
||||||
|
@ -23,10 +24,10 @@ log = logging.getLogger("ola_post")
|
||||||
log.info("Starting sws -> olaFlow converter")
|
log.info("Starting sws -> olaFlow converter")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(args.config)
|
config.read(args.config)
|
||||||
out = pathlib.Path(config.get("post", "pickle"))
|
out = pathlib.Path(config.get("post", "out"))
|
||||||
out.parent.mkdir(parents=True, exist_ok=True)
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with out.open("rb") as f:
|
with gzip.open(out.joinpath("pickle.gz"), "rb") as f:
|
||||||
model = pickle.load(f)
|
model = pickle.load(f)
|
||||||
|
|
||||||
x0 = config.getfloat("post", "x")
|
x0 = config.getfloat("post", "x")
|
||||||
|
@ -115,12 +116,5 @@ def animU(i):
|
||||||
ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24)
|
ani = animation.FuncAnimation(fig, anim, frames=model.t.size, interval=1/24)
|
||||||
aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24)
|
aniU = animation.FuncAnimation(figU, animU, frames=model.t.size, interval=1/24)
|
||||||
|
|
||||||
a = mp.Process(target=ani.save, args=(out.parent.joinpath("anim.mp4"),), kwargs={"fps": 24})
|
ani.save(out.joinpath("anim.mp4"), fps=24)
|
||||||
aU = mp.Process(target=aniU.save, args=(out.parent.joinpath("animU.mp4"),), kwargs={"fps": 24})
|
aniU.save(out.joinpath("animU.mp4"), fps=24)
|
||||||
|
|
||||||
a.start()
|
|
||||||
aU.start()
|
|
||||||
|
|
||||||
a.join()
|
|
||||||
aU.join()
|
|
||||||
#plt.show()
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
import gzip
|
||||||
import configparser
|
import configparser
|
||||||
import logging
|
import logging
|
||||||
import pathlib
|
import pathlib
|
||||||
import pickle
|
import pickle
|
||||||
|
from time import time
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -22,8 +24,8 @@ log = logging.getLogger("ola_post")
|
||||||
log.info("Starting sws -> olaFlow converter")
|
log.info("Starting sws -> olaFlow converter")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(args.config)
|
config.read(args.config)
|
||||||
out = pathlib.Path(config.get("post", "pickle"))
|
out = pathlib.Path(config.get("post", "out"))
|
||||||
out.parent.mkdir(parents=True, exist_ok=True)
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
olaflow_root = args.output
|
olaflow_root = args.output
|
||||||
model = OFModel(olaflow_root)
|
model = OFModel(olaflow_root)
|
||||||
|
@ -35,5 +37,5 @@ model.read_field_all("p")
|
||||||
model.read_field_all("p_rgh")
|
model.read_field_all("p_rgh")
|
||||||
model.read_field_all("U")
|
model.read_field_all("U")
|
||||||
|
|
||||||
with out.open("wb") as f:
|
with gzip.open(out.joinpath("pickle.gz"), "wb") as f:
|
||||||
pickle.dump(model, f)
|
pickle.dump(model, f)
|
||||||
|
|
Loading…
Reference in a new issue