From 0d3f08920ddd7ccaebd44fbca5a20525a67dd77b Mon Sep 17 00:00:00 2001 From: Duc Le Date: Tue, 16 Apr 2024 15:14:50 +0100 Subject: [PATCH] Add error for old castep_bin files #295 --- euphonic/readers/castep.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/euphonic/readers/castep.py b/euphonic/readers/castep.py index 65455a0d9..9661db5a5 100644 --- a/euphonic/readers/castep.py +++ b/euphonic/readers/castep.py @@ -469,8 +469,17 @@ def read_interpolation_data( np.reshape(_read_entry(f, float_type), (n_cells_in_sc, 3*n_atoms, 3*n_atoms)), axes=[0, 2, 1])) - cell_origins = np.reshape( - _read_entry(f, int_type), (n_cells_in_sc, 3)) + try: + cell_origins = np.reshape( + _read_entry(f, int_type), (n_cells_in_sc, 3)) + except ValueError: + raise ValueError('Old castep file detected: ' + 'Euphonic only supports post-Castep 17.1 files. ' + 'Please rerun the calculation with a newer version ' + 'of Castep with the original .cell file and a ' + '.castep file with a single line with the ' + '"continuation: " keyword and ' + 'use the new output .castep_bin file in Euphonic.') _ = _read_entry(f, int_type) # FC row not used elif header == b'BORN_CHGS': born = np.reshape(