Skip to content

Commit

Permalink
some mode might not have an irrep
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Feb 6, 2024
1 parent 7020a95 commit e7d34ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions phonopy_vibspec/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def to_hdf5(self, path: pathlib.Path):
g_input = f.create_group('input')
g_input.create_dataset('modes', data=self.modes)
g_input.create_dataset('frequencies', data=self.frequencies)
g_input.create_dataset('irrep_labels', data=[x.encode('utf-8') for x in self.irrep_labels])
g_input.create_dataset('irrep_labels', data=[
(x.encode('utf-8') if x is not None else '?'.encode('utf-8')) for x in self.irrep_labels
])
g_input.create_dataset('dmu_dq', data=self.dmu_dq)

def compute_intensities(self) -> NDArray[float]:
Expand All @@ -130,7 +132,10 @@ def to_csv(
f.write('"Mode"\t"Frequency [cm⁻¹]"\t"Irrep."\t"Intensity [e²/AMU]"\n')
for i in range(len(self)):
f.write('{}\t{:.6f}\t"{}"\t{:.6f}\n'.format(
self.modes[i] + 1, self.frequencies[i], self.irrep_labels[i], intensities[i]
self.modes[i] + 1,
self.frequencies[i],
self.irrep_labels[i] if self.irrep_labels[i] is not None else '?',
intensities[i]
))

f.write('\n\n') # enough blank lines
Expand Down

0 comments on commit e7d34ff

Please sign in to comment.