2014-11-07 00:55:40 +01:00
|
|
|
import h5py
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2020-04-08 21:35:59 +02:00
|
|
|
print("Usage: python clear_h5_output.py archive")
|
2016-05-09 10:19:56 +02:00
|
|
|
sys.exit()
|
2014-11-07 00:55:40 +01:00
|
|
|
|
2020-04-08 21:35:59 +02:00
|
|
|
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.
|
2020-04-08 21:35:59 +02:00
|
|
|
""")
|
2014-11-07 00:55:40 +01:00
|
|
|
|
|
|
|
filename = sys.argv[1]
|
|
|
|
A = h5py.File(filename)
|
2016-05-09 10:19:56 +02:00
|
|
|
for group in ['dmft_output', 'user_data']:
|
|
|
|
if group in A:
|
|
|
|
del(A[group])
|
2014-11-07 00:55:40 +01:00
|
|
|
A.close()
|
|
|
|
|
|
|
|
# Repack to reclaim disk space
|
2016-05-09 10:19:56 +02:00
|
|
|
retcode = subprocess.call(["h5repack", "-i%s" % filename, "-otemphgfrt.h5"])
|
2014-11-07 00:55:40 +01:00
|
|
|
if retcode != 0:
|
2020-04-08 21:35:59 +02:00
|
|
|
print("h5repack failed!")
|
2014-11-07 00:55:40 +01:00
|
|
|
else:
|
2016-05-09 10:19:56 +02:00
|
|
|
subprocess.call(["mv", "-f", "temphgfrt.h5", "%s" % filename])
|