mirror of
https://github.com/Findus23/rebound-collisions.git
synced 2024-09-19 15:53:48 +02:00
23 lines
813 B
Python
23 lines
813 B
Python
|
"""
|
||
|
The .energylog.csv files logged the energy every 100 years which resulted in huge files.
|
||
|
This script converts the data to a compressed hdf5 archive.
|
||
|
"""
|
||
|
import h5py
|
||
|
|
||
|
from utils import filename_from_argv
|
||
|
|
||
|
times = []
|
||
|
values = []
|
||
|
fn = filename_from_argv()
|
||
|
with fn.with_suffix(".energylog.csv").open() as f:
|
||
|
for line in f:
|
||
|
time_str, val_str = line.split(",")
|
||
|
times.append(int(float(time_str)))
|
||
|
values.append(float(val_str))
|
||
|
print("creating hdf5 file")
|
||
|
with h5py.File(fn.with_suffix(".energylog.hdf5"), "w") as f:
|
||
|
times_dset = f.create_dataset("times", data=times, compression="gzip", shuffle=True, fletcher32=True)
|
||
|
print(times_dset.dtype)
|
||
|
values_dset = f.create_dataset("values", data=values, compression="gzip", shuffle=True, fletcher32=True)
|
||
|
print(values_dset.dtype)
|