Removed file, which is now in src folder
This commit is contained in:
@ -1,67 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import pandas as np
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import plotly.express as px
|
|
||||||
import plotly.graph_objects as go
|
|
||||||
from plotly.subplots import make_subplots
|
|
||||||
from igor2.binarywave import load as loadibw
|
|
||||||
|
|
||||||
#import h5py
|
|
||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
def read_xps_ibw_file_as_dict(filename):
|
|
||||||
|
|
||||||
""" Reads ibw files from multiphase chemistry group, which contain xps spectra and acquisition settings."""
|
|
||||||
|
|
||||||
file_obj = loadibw(filename)
|
|
||||||
|
|
||||||
required_keys = ['wData','data_units','dimension_units','note']
|
|
||||||
if sum([item in required_keys for item in file_obj['wave'].keys()]) < len(required_keys):
|
|
||||||
raise ValueError('This is not a valid xps ibw file. It does not satisfy minimum adimissibility criteria.')
|
|
||||||
|
|
||||||
file_dict = {}
|
|
||||||
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')
|
|
||||||
exclude_list = ['Excitation Energy']
|
|
||||||
for item in notes_list:
|
|
||||||
if '=' in item:
|
|
||||||
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['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['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'
|
|
||||||
|
|
||||||
file_dict = read_xps_ibw_file_as_dict(inputfile_dir+'\\SES\\0069069_N1s_495eV.ibw')
|
|
||||||
|
|
||||||
for key in file_dict.keys():
|
|
||||||
print(key,file_dict[key])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
print(':)')
|
|
Reference in New Issue
Block a user