From here
#!/usr/bin/env python3
import sys
import numpy as np
file_name = sys.argv[1]
with open(file_name, 'rb') as f:
f.seek(24)
offset = int.from_bytes(f.read(8), byteorder='little')
f.seek(offset)
operators = np.fromstring(f.read(4), dtype='<i4')[0]
dimension = np.fromstring(f.read(4), dtype='<i4')[0]
print('Offset: {}'.format(offset))
print('Number of Operators: {}'.format(operators))
print('Basis Dimension: {}'.format(dimension))
for i in range(operators):
print('\nOperator: {}'.format(i))
coefficients = np.fromstring(f.read(8*dimension**2), dtype='<f8')
occupations = np.fromstring(f.read(8*dimension), dtype='<f8')
energies = np.fromstring(f.read(8*dimension), dtype='<f8')
irreps = np.fromstring(f.read(4*dimension), dtype='<i4')
cores = np.fromstring(f.read(4*dimension), dtype='<i4')
print('Coefficients')
for coef in coefficients:
print('{:16.12f}'.format(coef))
print('Occupations')
for occupation in occupations:
print('{:16.12f}'.format(occupation))
print('Energies')
for energy in energies:
print('{:16.12f}'.format(energy))
print('Irreps')
for irrep in irreps:
print('{}'.format(irrep))
print('Core')
for core in cores:
print('{}'.format(core))