diff --git a/eos/file_reader.py b/eos/file_reader.py index 28d6459..56d8f16 100644 --- a/eos/file_reader.py +++ b/eos/file_reader.py @@ -605,8 +605,9 @@ class AmorEventData(AmorHeader): output = np.recarray(a1.shape[0]+a2.shape[0], dtype=new_fields) for field in new_fields.fields.keys(): output[field] = np.concatenate([a1[field], a2[field]]) - logging.warning("Missing data when combining datasets, " - f"{tuple(a1.dtype.fields.keys())} != {tuple(a2.dtype.fields.keys())}") + logging.warning(" Missing data when combining datasets,\n" + f" {tuple(a1.dtype.fields.keys())} \n" + f" !={tuple(a2.dtype.fields.keys())}") return output def append(self, other): @@ -626,7 +627,15 @@ class AmorEventData(AmorHeader): else: new_device_logs = {} for key, slog in self.data.device_logs.items(): - olog = other.data.device_logs[key] + try: + olog = other.data.device_logs[key] + except KeyError: + if getattr(other.experiment, 'end_date', None) is None: + logging.warning(f" Device logs for '{key}' not found in dataset to be added, " + f"ignoring key as file is not finalized") + continue + else: + raise KeyError(f"Device logs for '{key}' not found in dataset to be added") new_device_logs[key] = np.recarray(slog.shape[0]+olog.shape[0], dtype = slog.dtype) new_device_logs[key].time = np.concatenate([slog.time, olog.time])