Implemented minor change to output dictionary. keys meant to be dataset's attributes are now access to the key attributes_key, that take the value of a dictionary.
This commit is contained in:
@ -6,6 +6,8 @@ import plotly.graph_objects as go
|
|||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
from igor2.binarywave import load as loadibw
|
from igor2.binarywave import load as loadibw
|
||||||
|
|
||||||
|
#import h5py
|
||||||
|
import os
|
||||||
|
|
||||||
def read_xps_ibw_file_as_dict(filename):
|
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.')
|
raise ValueError('This is not a valid xps ibw file. It does not satisfy minimum adimissibility criteria.')
|
||||||
|
|
||||||
file_dict = {}
|
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'] = file_obj['wave']['wData']
|
||||||
file_dict['data_units'] = file_obj['wave']['data_units']
|
file_dict['data_units'] = file_obj['wave']['data_units']
|
||||||
file_dict['shape'] = file_dict['data'].shape
|
file_dict['shape'] = file_dict['data'].shape
|
||||||
file_dict['dtype'] = type(file_dict['data'])
|
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'.
|
# 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')
|
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('='))
|
key, value = tuple(item.split('='))
|
||||||
# TODO: check if value can be converted into a numeric type. Now all values are string type
|
# TODO: check if value can be converted into a numeric type. Now all values are string type
|
||||||
if not key in exclude_list:
|
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
|
# 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(']')
|
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
|
return file_dict
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
inputfile_dir = '\\\\fs101\\5505\\People\\Juan\\TypicalBeamTime'
|
inputfile_dir = '\\\\fs101\\5505\\People\\Juan\\TypicalBeamTime'
|
||||||
|
Reference in New Issue
Block a user