From 38a941fe1ddd6bfaf675d642f663d889e954132c Mon Sep 17 00:00:00 2001 From: Ivo Alxneit Date: Thu, 20 Jul 2017 12:14:05 +0200 Subject: [PATCH 1/2] don't crash if matadata are not available Signed-off-by: Ivo Alxneit --- spc/spc.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spc/spc.py b/spc/spc.py index cdd7cb1..22f3b6a 100644 --- a/spc/spc.py +++ b/spc/spc.py @@ -596,12 +596,15 @@ def write_file(self, path, delimiter='\t', newline='\n'): f.write(self.data_txt(delimiter, newline)) def print_metadata(self): - """ Print out select metadata""" - print("Scan: ", self.log_dict['Comment'], "\n", - float(self.log_dict['Start']), "to ", - float(self.log_dict['End']), "; ", - float(self.log_dict['Increment']), "cm-1;", - float(self.log_dict['Integration Time']), "s integration time") + """ Try print out select metadata""" + try: + print("Scan: ", self.log_dict['Comment'], "\n", + float(self.log_dict['Start']), "to ", + float(self.log_dict['End']), "; ", + float(self.log_dict['Increment']), "cm-1;", + float(self.log_dict['Integration Time']), "s integration time") + except: + print("") def plot(self): """ Plots data, and use column headers, returns figure object plotted From 81f82e65775ca2c75c9d0398d8f18c252bbb999b Mon Sep 17 00:00:00 2001 From: Ivo Alxneit Date: Thu, 20 Jul 2017 12:18:09 +0200 Subject: [PATCH 2/2] put strings into dictionary not byte strings This prevents e.g. axes labels like "b'Transmission'" in python 3.x Signed-off-by: Ivo Alxneit --- spc/spc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spc/spc.py b/spc/spc.py index 22f3b6a..b49865c 100644 --- a/spc/spc.py +++ b/spc/spc.py @@ -236,7 +236,7 @@ def __init__(self, filename): if x.find(b'=') >= 0: # stop it from breaking if there is more than 1 = key, value = x.split(b'=')[:2] - self.log_dict[key] = value + self.log_dict[key.decode()] = value.decode() else: self.log_other.append(x)