From 20262cb5aafd0d34d6f7f22f4e5aaa667b742db3 Mon Sep 17 00:00:00 2001
From: jmcchesn <jmcchesn@aps.anl.gov>
Date: Tue, 27 Sep 2022 14:50:29 -0500
Subject: [PATCH] cleaning up

---
 build/lib/iexcode/instruments/ARPES.py |  4 ++--
 build/lib/iexcode/instruments/Kappa.py |  4 ++--
 iexcode/cheatsheet.txt                 |  1 +
 iexcode/instruments/ARPES.py           | 19 +++++++----------
 iexcode/instruments/Kappa.py           |  4 ++--
 iexcode/instruments/Octupole.py        | 28 ++++++--------------------
 iexcode/instruments/xrays.py           | 13 ++++++------
 7 files changed, 27 insertions(+), 46 deletions(-)

diff --git a/build/lib/iexcode/instruments/ARPES.py b/build/lib/iexcode/instruments/ARPES.py
index 11c2263..cd042ec 100644
--- a/build/lib/iexcode/instruments/ARPES.py
+++ b/build/lib/iexcode/instruments/ARPES.py
@@ -11,7 +11,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras
 from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv
 from iexcode.instruments.Logfile import Logfile
 from iexcode.instruments.staff import staff_detector_dictionary
-from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary
+from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary
 
 from iexcode.instruments.conversions_constants import *
 from iexcode.instruments.utilities import *
@@ -140,7 +140,7 @@ def _ARPES_detector_dictionary():
 
     #add detectors related to beamline
     if iex.BL.xrays: 
-        det_dict.update(_xrays_detector_dictionary())
+        det_dict.update(xrays_detector_dictionary())
 
     return det_dict
 
diff --git a/build/lib/iexcode/instruments/Kappa.py b/build/lib/iexcode/instruments/Kappa.py
index 3df3d6d..cb565d1 100644
--- a/build/lib/iexcode/instruments/Kappa.py
+++ b/build/lib/iexcode/instruments/Kappa.py
@@ -12,7 +12,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras
 from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv
 from iexcode.instruments.Logfile import Logfile
 from iexcode.instruments.staff import staff_detector_dictionary
-from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all
+from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all
 
 from iexcode.instruments.conversions_constants import *
 from iexcode.instruments.utilities import *
@@ -185,7 +185,7 @@ def _kappa_detector_dictionary(**kwargs):
 
     #add detectors related to beamline
     if iex.BL.xrays: 
-        det_dict.update(_xrays_detector_dictionary())
+        det_dict.update(xrays_detector_dictionary())
 
     return det_dict
 
diff --git a/iexcode/cheatsheet.txt b/iexcode/cheatsheet.txt
index 894ddba..59a4a88 100644
--- a/iexcode/cheatsheet.txt
+++ b/iexcode/cheatsheet.txt
@@ -285,6 +285,7 @@ mono_cff_set
 mono_arm_set
 
 #xrays
+safe_state
 energy_get_all
 energy_get => retuns the mono energy
 getE => same as energy_get
diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py
index b472dc8..1d6912c 100644
--- a/iexcode/instruments/ARPES.py
+++ b/iexcode/instruments/ARPES.py
@@ -12,7 +12,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras
 from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv
 from iexcode.instruments.Logfile import Logfile
 from iexcode.instruments.staff import staff_detector_dictionary
-from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary
+from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary
 
 from iexcode.instruments.conversions_constants import *
 from iexcode.instruments.utilities import *
@@ -142,7 +142,7 @@ def _ARPES_detector_dictionary():
 
     #add detectors related to beamline
     if iex.BL.xrays: 
-        det_dict.update(_xrays_detector_dictionary())
+        det_dict.update(xrays_detector_dictionary())
 
     return det_dict
 
@@ -309,13 +309,6 @@ def ARPES_get_all(verbose=True):
 ##############################################################################################################
 ##############################             logging           ##############################
 ##############################################################################################################
-def _ARPES_log_header():
-    header_list={
-        'EA': "scan,x,y,z,th,chi,phi,T,scan_mode,E1,E2,step,i,f,PE,lens_mode,SES slit #,hv,exit_slit,GRT,ID_SP,ID_RBV,ID_Mode,ID_QP,TEY1,TEY2,time,comment",
-        'ARPES':"scan,motor,start,stop,step,x,y,z,th,chi,phi,T,hv,exit_slit,GRT,ID_SP,ID_RBV,ID_Mode,ID_QP,TEY_1,TEY_2,time,comment"
-        }
-    return header_list
-
 def _ARPES_log_dictionary():
     """
     endstation info for log file
@@ -446,6 +439,7 @@ def _ARPES_detector_triggers_sequence(**kwargs):
     userStringSeq_clear(scan_ioc,seq_num=kwargs['seq_num'])
     caput(detector_triggers_pv+".DESC","ARPES_Trigger1")
     
+    #trigger Keithleys if any
     ca_list = _ARPES_ca_list()
     last = len(ca_list)
     for i,ca in enumerate(ca_list):
@@ -453,6 +447,8 @@ def _ARPES_detector_triggers_sequence(**kwargs):
         caput(detector_triggers_pv+".LNK" +str(i+1),ca_pv)
         caput(detector_triggers_pv+".WAIT"+str(i+1),"After"+str(last))
 
+    #trigger scaler if any
+
     return detector_triggers_proc
 
 def _ARPES_trigger_dictionary(**kwargs):
@@ -720,12 +716,11 @@ def scanfocus(x_start,x_stop,x_step,**kwargs):
 
    
 
-def ARPES_sample_map2D(step_y=0.5,step_z=0.5):
+def ARPES_map_sample(inner_loop=["y",0,4,0.5],outer_loop=["z",12,16,0.5]):
     """
     2D map of sample area in ARPES chamber
 
     Previously: Map_ARPES_Sample
     """
-    print("Scan_ARPES_2Dmotor(\"y\",0,4,"+str(step_y)+",\"z\",12,16,"+str(step_z)+")")
-    ARPES_Motors.scan_2D(["y",0,4,step_y],["z",12,16,step_z])
+    ARPES_Motors.scan_2D(inner_loop,outer_loop)
 
diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py
index 3df3d6d..cb565d1 100644
--- a/iexcode/instruments/Kappa.py
+++ b/iexcode/instruments/Kappa.py
@@ -12,7 +12,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras
 from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv
 from iexcode.instruments.Logfile import Logfile
 from iexcode.instruments.staff import staff_detector_dictionary
-from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all
+from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all
 
 from iexcode.instruments.conversions_constants import *
 from iexcode.instruments.utilities import *
@@ -185,7 +185,7 @@ def _kappa_detector_dictionary(**kwargs):
 
     #add detectors related to beamline
     if iex.BL.xrays: 
-        det_dict.update(_xrays_detector_dictionary())
+        det_dict.update(xrays_detector_dictionary())
 
     return det_dict
 
diff --git a/iexcode/instruments/Octupole.py b/iexcode/instruments/Octupole.py
index e319508..e7f4539 100644
--- a/iexcode/instruments/Octupole.py
+++ b/iexcode/instruments/Octupole.py
@@ -12,7 +12,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras
 from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv
 from iexcode.instruments.Logfile import Logfile
 from iexcode.instruments.staff import staff_detector_dictionary
-from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all
+from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all
 
 from iexcode.instruments.conversions_constants import *
 from iexcode.instruments.utilities import *
@@ -175,6 +175,7 @@ def _Octupole_detector_dictionary(**kwargs):
     }
     #hkl are listed just a place holders, they are filled in by thier scanning functions
     det_dict.update(sample_temp)
+    det_dict.update(m3r)
     det_dict.update(scalers)
     det_dict.update(xmcd_raw)
     det_dict.update(xmcd_norm)
@@ -183,7 +184,7 @@ def _Octupole_detector_dictionary(**kwargs):
 
     #add detectors related to beamline
     if iex.BL.xrays: 
-        det_dict.update(_xrays_detector_dictionary())
+        det_dict.update(xrays_detector_dictionary())
 
     return det_dict
 
@@ -328,15 +329,6 @@ def Octupole_get_all(verbose=True):
 ##############################################################################################################
 ##############################                         logging                  ##############################
 ##############################################################################################################
-def _Octupole_log_header():
-    """
-    header for the log file
-    """
-    h = "scan,motor,start,stop,step,x,y,z,th,tth,TA"
-    h += "hv,exit_slit,GRT,ID_SP,ID_RBV,ID_Mode,ID_QP,TEY,mesh,det_name,mpa_HV,m3r_centroid,time,comment"
-    header_list = {'Octupole':h}
-    return header_list 
-
 def _Octupole_log_dictionary():
     """
     enstation info for log file
@@ -409,15 +401,6 @@ def _Octupole_scan_after_sequence(**kwargs):
 
     scan_ioc = iex.BL.ioc
 
-    if 'scan_ioc' in kwargs:
-        scan_ioc = kwargs['scan_ioc']
-        try:
-            iex.BL.ioc = kwargs['scan_ioc']
-        except:
-            error = 'undefined'
-    else:
-        scan_ioc = iex.BL.ioc
-
     after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num)
     
     #clear and write the after scan user sequence
@@ -433,7 +416,7 @@ def _Octupole_scan_after_sequence(**kwargs):
     caput(after_scan_pv+".LNK3",scan_pv+".PDLY NPP NMS")
     caput(after_scan_pv+".DO3",0.1)
 
-    ## Clear DetTriggers 2 to 4:
+    ## Clear DetTriggers 2 :
     caput(after_scan_pv+".LNK4",scan_pv+".T2PV NPP NMS")    #remove trigger 2 (used for EA) after scan
 
     if kwargs['snake']:
@@ -460,6 +443,7 @@ def _Octupole_detector_triggers_sequence(**kwargs):    # do we need to add 29idb
     userStringSeq_clear(scan_ioc,seq_num=kwargs['seq_num'])
     caput(detector_triggers_pv+".DESC","Octupole_Trigger1")
    
+   #trigger Keithleys if any
     ca_list = _Octupole_ca_list()
     last = len(ca_list)
     if last !=0:
@@ -468,9 +452,9 @@ def _Octupole_detector_triggers_sequence(**kwargs):    # do we need to add 29idb
             caput(detector_triggers_pv+".LNK" +str(i+2),ca_pv)
             caput(detector_triggers_pv+".WAIT"+str(i+2),"After"+str(last))
 
+    #trigger scaler if any
     last+=1
     scaler_pv = Octupole_scaler_pv()
-
     caput(detector_triggers_pv+".LNK" +str(1),scaler_pv)
     caput(detector_triggers_pv+".WAIT"+str(1),"After"+str(last))
 
diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py
index 5d57f2d..262a2b0 100644
--- a/iexcode/instruments/xrays.py
+++ b/iexcode/instruments/xrays.py
@@ -57,7 +57,7 @@ def _xrays_detector_list():
     return ca_list
 
 
-def _xrays_detector_dictionary():
+def xrays_detector_dictionary():
     """
     returns a dictionary of the default detectors
     
@@ -382,11 +382,10 @@ def scanmono(start,stop,step,average_pnts=1,**kwargs):
 
 
 
-def scanXAS(start_stop_step_lists,ID_eV=None,ID_tracking=False, **kwargs):
+def scanXAS(start_stop_step_lists,ID_tracking=False, **kwargs):
     """
     scans the beamline energy:
         ID_eV = None        => the ID stays at the current value (default) 
-        ID_eV = value       => set the ID 
         ID_track = True     => ID will follow with the mono (SLOW but required in ARPES)
       
     start_stop_step_lists is a list of lists for the different scan ranges
@@ -395,6 +394,7 @@ def scanXAS(start_stop_step_lists,ID_eV=None,ID_tracking=False, **kwargs):
 
     **kwargs:
         scan_dim = 1 (default)
+        ID_eV: sets the ID, only works if ID_tracking is False 
         average_pnts: if using Keithlys this set the averaging; None for no averaging
         m3r: if True the mirror is optimized before the start of the scan
         mcp
@@ -424,9 +424,10 @@ def scanXAS(start_stop_step_lists,ID_eV=None,ID_tracking=False, **kwargs):
         kwargs.update({'positioner_num':2})
         ID_scan_fillin_table(ID_array,**kwargs)
         energy(ID_array[0],m3r=kwargs["m3r"])
-    elif ID_eV != None:
-        #Setting the beamline energy
-        energy(ID_eV,m3r=kwargs["m3r"])
+    else:
+        if ID_eV != None:
+            #Setting the beamline energy
+            energy(ID_eV,m3r=kwargs["m3r"])
 
     #Averaging and Normalization
     ca_average(kwargs['average_pnts'])
-- 
GitLab