import os import sys import struct import numpy as np from matplotlib import pyplot as plt """ Convert ARPES raw data file to text file """ #================================ # global parameters #================================ infile = "PbSe_ARPES_25K.pxt" outcsvfile = None #=================================== # figure configuration #=================================== figsize = [8, 8] fontsize = 12 legend_fontsize = 8 rIoffset = 0.5 #============================= # Treat argments #============================= def pfloat(str): try: return float(str) except: return None def pint(str): try: return int(str) except: return None def getarg(position, defval = None): try: return sys.argv[position] except: return defval def getfloatarg(position, defval = None): return pfloat(getarg(position, defval)) def getintarg(position, defval = None): return pint(getarg(position, defval)) def usage(): print("") print("Usage:") print(" python {} infile" .format(sys.argv[0])) print(" ex: python {} {}".format(sys.argv[0], infile)) def terminate(message = None): if message is not None: print("") print(message) print("") usage() print("") exit() def updatevars(): global infile, outcsvfile argv = sys.argv # if len(argv) == 1: # terminate() infile = getarg ( 1, infile) header, ext = os.path.splitext(infile) filebody = os.path.basename(header) infile = filebody + '.pxt' outcsvfile = filebody + '.csv' def read_ARPESdata(infile, is_print = 0): inf = {} inf["filename"] = infile try: f = open(infile, 'rb') except: terminate("Error: Can not read [{}]".format(infile)) if f is None: return None data = f.read() f.close() # print("data:", data) s = '' for i in range(40): c, = struct.unpack_from('B', data, 0x64 + i) if c == 0: break s += chr(c) inf["Sample"] = s inf["nE"], = struct.unpack_from('>", end = '') input() terminate() if __name__ == '__main__': main()