From aa548141733e60295eb4b2371aa965ca7c02f76b Mon Sep 17 00:00:00 2001 From: gac-x11ma Date: Wed, 15 May 2019 11:05:45 +0200 Subject: [PATCH] Closedown --- script/local.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ script/utils.py | 6 +++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/script/local.py b/script/local.py index acf5bd8..4967c2d 100644 --- a/script/local.py +++ b/script/local.py @@ -133,6 +133,53 @@ def before_sample(): def after_sample(): check_id_error() +##################### Convert_File function ############################# +""" +def convert_file(input_file_name, output_file_name): + sep = "\t" + line_sep = "\r\n" + field = caget('X11MA-XMCD:Ireadout') + with open(input_file_name) as inp: + lines = inp.readlines() + with open(output_file_name, "wb") as out: + out.write("Energy" + sep + "Io" + sep + "CADC2" + sep + "CADC3" + sep + "Mag" + line_sep) + s = sep + " " #File format has a space before numeric values + for line in lines[1:]: + line = line.strip() + if line=="": break + try: + (Ecrbk,CADC1, CADC2, NORM, CADC3, CADC4, MCurr, cffrbk, ID1Erbk, ID2Erbk, vTime) = line.split(" ") + out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + str(field) +line_sep) + except: + traceback.print_exc() +""" +def convert_file(input_file_name, output_file_name, pol = None): + print "Converting data file: " + input_file_name + " to " + output_file_name + #print "File converted to: ",output_file_name + sep = "\t" + line_sep = "\n" + MODE = pol_mode.read() + if pol is None: + pol = pol_angle.read() if (MODE == "LINEAR") else pol_mode.readback.read() + with open(input_file_name) as inp: + lines = inp.readlines() + with open(output_file_name, "wb") as out: + (db, st) = ("java.lang.Double", "java.lang.String") + out.write("#Energy" + sep + "CADC1" + sep + "CADC2" + sep + "CADC3" + sep + "NORMtey" + "Pol" + line_sep) + out.write("#"+ db + sep + db + sep + db + sep + db + sep + db + line_sep) + s = sep + for line in lines[1:]: + line = line.strip() + if line=="": break + try: + (Ecrbk, CADC1, CADC2, CADC3, CADC4, MCurr, cffrbk, IDErbk, time) = line.split(" ") + normtey=repr( float(CADC2)/float(CADC1)) +# normdiode=repr(float(CADC3)/float(CADC2)) + out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + normtey + s + str(pol) + line_sep) + except: + traceback.print_exc() + os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) + ################################################################################################### #OTF function ################################################################################################### diff --git a/script/utils.py b/script/utils.py index 1ac32eb..fdd2b83 100644 --- a/script/utils.py +++ b/script/utils.py @@ -18,7 +18,7 @@ def convert_file(input_file_name, output_file_name): out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + str(field) +line_sep) except: traceback.print_exc() -""" + def convert_file(input_file_name, output_file_name, pol = None): print "Converting data file: " + input_file_name + " to " + output_file_name #print "File converted to: ",output_file_name @@ -39,13 +39,13 @@ def convert_file(input_file_name, output_file_name, pol = None): if line=="": break try: (Ecrbk, CADC1, CADC2, CADC3, CADC4, MCurr, cffrbk, IDErbk, time) = line.split(" ") - normtey=repr( float(CADC3)/float(CADC1)) + normtey=repr( float(CADC2)/float(CADC1)) # normdiode=repr(float(CADC3)/float(CADC2)) out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + normtey + s + str(pol) + line_sep) except: traceback.print_exc() os.rename(input_file_name, get_context().setup.expandPath("{data}/OTF/" + ntpath.basename(input_file_name))) - +""" ##################### Plotting function ############################# """ task = None