diff --git a/g5505_file_reader.py b/g5505_file_reader.py index 8d29410..ca99b80 100644 --- a/g5505_file_reader.py +++ b/g5505_file_reader.py @@ -6,6 +6,8 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots from igor2.binarywave import load as loadibw +#import h5py +import os def read_xps_ibw_file_as_dict(filename): @@ -18,11 +20,14 @@ def read_xps_ibw_file_as_dict(filename): raise ValueError('This is not a valid xps ibw file. It does not satisfy minimum adimissibility criteria.') file_dict = {} - file_dict['name'] = filename + path_tail, path_head = os.path.split(filename) + file_dict['name'] = path_head file_dict['data'] = file_obj['wave']['wData'] file_dict['data_units'] = file_obj['wave']['data_units'] file_dict['shape'] = file_dict['data'].shape file_dict['dtype'] = type(file_dict['data']) + + file_dict['attributes_dict'] = {} # Convert notes of bytes class to string class and split string into a list of elements separated by '\r'. notes_list = file_obj['wave']['note'].decode("utf-8").split('\r') @@ -32,15 +37,17 @@ def read_xps_ibw_file_as_dict(filename): key, value = tuple(item.split('=')) # TODO: check if value can be converted into a numeric type. Now all values are string type if not key in exclude_list: - file_dict[key] = value + file_dict['attributes_dict'][key] = value # TODO: talk to thorsten to see if there is an easier way to access the below attributes dimension_labels = file_obj['wave']['dimension_units'].decode("utf-8").split(']') - file_dict['dimension_units'] = [item+']' for item in dimension_labels[0:len(dimension_labels)-1]] + file_dict['attributes_dict']['dimension_units'] = [item+']' for item in dimension_labels[0:len(dimension_labels)-1]] return file_dict + + def main(): inputfile_dir = '\\\\fs101\\5505\\People\\Juan\\TypicalBeamTime'