From c8f24a859e9cc88584ff58bcf8657722b0cf4a50 Mon Sep 17 00:00:00 2001 From: Urs Ganse Date: Wed, 13 Feb 2019 15:09:55 +0200 Subject: [PATCH] Wrap read_interpolated_variable's data size determination in a try block This catches the special case in which a derived variable evaluates to NaN (such as TPerpOverPar), gets masked away, creates an array with zero effective size, and then all hell breaks loose. --- pyVlsv/vlsvreader.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyVlsv/vlsvreader.py b/pyVlsv/vlsvreader.py index 8b62f5d8..0ab6d159 100644 --- a/pyVlsv/vlsvreader.py +++ b/pyVlsv/vlsvreader.py @@ -760,7 +760,11 @@ def read_interpolated_variable(self, name, coordinates, operator="pass",periodic test_val=self.read_variable(name,lower_cell_id,operator) if isinstance(test_val, Iterable): - value_length=len(test_val) + try: + value_length=len(test_val) + except Exception as e: + # Can't determine size, maybe some division by zero? + value_length=1 else: value_length=1