2014-11-07 00:55:40 +01:00
|
|
|
import h5py
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2014-11-13 21:38:32 +01:00
|
|
|
print "Usage: python clear_h5_output.py archive"
|
2014-11-07 00:55:40 +01:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
print """
|
2014-11-18 11:30:26 +01:00
|
|
|
This script is to remove any SumkDFT generated output from the h5 archive
|
2014-11-07 00:55:40 +01:00
|
|
|
and to restore it to the original post-converter state.
|
|
|
|
"""
|
|
|
|
|
|
|
|
filename = sys.argv[1]
|
|
|
|
A = h5py.File(filename)
|
2014-12-03 23:12:39 +01:00
|
|
|
for group in ['dft_output','user_data']:
|
2014-11-13 21:38:32 +01:00
|
|
|
if group in A: del(A[group])
|
2014-11-07 00:55:40 +01:00
|
|
|
A.close()
|
|
|
|
|
|
|
|
# Repack to reclaim disk space
|
|
|
|
retcode = subprocess.call(["h5repack","-i%s"%filename, "-otemphgfrt.h5"])
|
|
|
|
if retcode != 0:
|
|
|
|
print "h5repack failed!"
|
|
|
|
else:
|
|
|
|
subprocess.call(["mv","-f","temphgfrt.h5","%s"%filename])
|