From 88f406b2db43095832665811c8b19064b39e3a7e Mon Sep 17 00:00:00 2001
From: "FR@29iduser" <rodolakis@anl.gov>
Date: Mon, 29 Aug 2022 12:37:59 -0500
Subject: [PATCH] debugging with Fanny

---
 iexcode/instruments/ARPES.py                  |  4 +-
 iexcode/instruments/IEX_endstations.py        |  2 +
 iexcode/instruments/xrays.py                  | 48 ++-----------------
 iexcode/macros/ARPES_macros.py                |  2 +-
 iexcode/macros/Kappa_optimization.py          |  2 +-
 iexcode/macros/commissioning.py               |  2 +-
 .../{ScanFunctions_plot.py => quick_plot.py}  |  0
 iexcode/macros/start_of_the_week.py           |  6 +--
 8 files changed, 14 insertions(+), 52 deletions(-)
 rename iexcode/macros/{ScanFunctions_plot.py => quick_plot.py} (100%)

diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py
index 90001dd..64dac15 100644
--- a/iexcode/instruments/ARPES.py
+++ b/iexcode/instruments/ARPES.py
@@ -137,7 +137,7 @@ def _ARPES_motor_dictionary():
     """
     returns a dictionary with  {name:[rbv,val,spmg,pv]}
     """
-    
+    p = '29idc:m'
     motor_nums = {'x': 1,
       'y':2,
       'z':3,
@@ -148,7 +148,7 @@ def _ARPES_motor_dictionary():
     
     motor_dictionary={}
     for name in motor_nums.keys():
-        pv = '29idc:m'+str(motor_nums[name])
+        p = '29idc:m'+str(motor_nums[name])
         motor_dictionary.update({name:[pv+'.RBV',pv+'.VAL',pv+'.SPMG',pv]})
 
     return motor_dictionary
diff --git a/iexcode/instruments/IEX_endstations.py b/iexcode/instruments/IEX_endstations.py
index d937acd..49cfa34 100644
--- a/iexcode/instruments/IEX_endstations.py
+++ b/iexcode/instruments/IEX_endstations.py
@@ -46,12 +46,14 @@ class Endstation:
             BL.branch => BL branch 'c' or 'd' only (used for shutter checks)
             BL.xrays => True/False 
             BL.mode => 'user'/'staff' previously: BL_Mode_Set
+            BL.mda => scanRecord class used for scanning
             BL.folder => 'b','c','d'
             BL.prefix => 'ARPES_','Kappa_'
             BL.ioc => previously: BL_ioc()
             BL.Motors => motor calls
             BL.safe_state => function to put endstation in a 'safe state'
             BL.endstation_get => function to return endstation status
+            BL.log => log class
 
             Note intialization does not set default detectors and logging for .mda
             
diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py
index 7f70c3f..237efd8 100644
--- a/iexcode/instruments/xrays.py
+++ b/iexcode/instruments/xrays.py
@@ -277,7 +277,7 @@ def _energy_range_check(hv):
     hv = np.max(hv_min,hv)
     return hv
 
-def mvid_SP(val):
+def mvID(val):
     """
     Sets the ID absolute set point (not optimized , mono & apertures stay fixed).
     
@@ -286,7 +286,7 @@ def mvid_SP(val):
     ID_energy_set(val)
     ID_SP_set(val)
 
-def mvid(val):
+def mvID_calibrated(val):
     """
     Sets the ID peak to val (calibrated).
 
@@ -314,7 +314,7 @@ def getE():
     """
     return mono_energy_get()
 
-def switch_gratings(grating):
+def grating(grating):
     """
     used to switch between gratings
         grating = 'HEG' / 'MEG'
@@ -340,14 +340,6 @@ def switch_gratings(grating):
     else: 
         print("grating: "+grating)
 
-def mvgrating(grating):
-    """
-    Change mono grating: 
-        HEG = high resolution, low flux
-        MEG = medium resolution, high flux
-    """
-    switch_gratings(grating)
-
 def polarization(ID_mode):
     """
     Change beam polarization: ID_mode = 'H', 'V', 'RCP' or 'LCP'
@@ -360,7 +352,7 @@ def polarization_get():
     """
     ID_mode_get()
 
-def scanhv(start,stop,step,average_pnts=1,**kwargs):
+def scanmono(start,stop,step,average_pnts=1,**kwargs):
     """
     scans the mono at the current ID value
 
@@ -376,38 +368,6 @@ def scanhv(start,stop,step,average_pnts=1,**kwargs):
     mono_scan_after(iex.BL.mda)
 
 
-def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kwargs):
-    """ 
-    sets the ID and then scans the mono
-    
-    hv_start,hv_stop,hv_step: are the mono start, stop, step energies
-    ID_offset: used to position the ID
-        None => the ID does not move
-        otherwise ID_energy_set = (stop-start)/2 + ID_offset
-    mesh: used to specifiy mesh status (for normalization)
-        => mesh='y': drops in the mesh for normalization (D branch only); retracts it at the end.
-        => mesh='stay': to leave the mesh in after the scan is finished
-        => mesh='n': no mesh.
-    **kwargs
-        scan_dim
-        positioner_settling_time = 0.2
-    """
-
-    mda = iex.BL.mda
-    ca_average(average_pnts)
-
-    if ID_offset != None:
-        ID_energy_set = (start+stop)/2.0 + ID_offset
-        
-    slits_set_BL()
-
-    mono_scan_fillin(mda,scan_dim,start,stop,step,**kwargs)
-    
-    mono_energy_set(start)
-    iex.BL.mda.go(scan_dim)
-    
-    mono_scan_after(mda,scan_dim)
-
 
 def scanXAS(ID_eV,start_stop_step_lists,**kwargs):
     """
diff --git a/iexcode/macros/ARPES_macros.py b/iexcode/macros/ARPES_macros.py
index 240e6d8..d62a31a 100644
--- a/iexcode/macros/ARPES_macros.py
+++ b/iexcode/macros/ARPES_macros.py
@@ -2,7 +2,7 @@ import numpy as np
 
 from epics import caget,caput
 
-from .ScanFunctions_plot import mda_1D,fit_gauss
+from .quick_plot import mda_1D,fit_gauss
 
 from ..instruments.electron_analyzer import scanEA
 from ..instruments.slits import slit3C_set
diff --git a/iexcode/macros/Kappa_optimization.py b/iexcode/macros/Kappa_optimization.py
index 378f9c5..07ac00a 100644
--- a/iexcode/macros/Kappa_optimization.py
+++ b/iexcode/macros/Kappa_optimization.py
@@ -4,7 +4,7 @@ from epics import caget,caput
 from ..instruments.Kappa import *
 from ..instruments.Motors import *
 
-from .ScanFunctions_plot import fit_mda, mda_1D
+from .quick_plot import fit_mda, mda_1D
 
 ##### Kappa Optimization scans #####
 def Opt_d4(iteration,moveZ,graph='y',srs=None,start=-0.5,stop=0.5,step=0.04):
diff --git a/iexcode/macros/commissioning.py b/iexcode/macros/commissioning.py
index 80046bc..f04c827 100644
--- a/iexcode/macros/commissioning.py
+++ b/iexcode/macros/commissioning.py
@@ -25,7 +25,7 @@ from ..instruments.electron_analyzer import *
 from ..instruments.Kappa import *
 
 
-from .ScanFunctions_plot import fit_mda, mda_1D
+from .quick_plot import fit_mda, mda_1D
 
 ##############################################################################################################
 ################################            setting  the mda folder             ##############################
diff --git a/iexcode/macros/ScanFunctions_plot.py b/iexcode/macros/quick_plot.py
similarity index 100%
rename from iexcode/macros/ScanFunctions_plot.py
rename to iexcode/macros/quick_plot.py
diff --git a/iexcode/macros/start_of_the_week.py b/iexcode/macros/start_of_the_week.py
index ce69923..0cc64c5 100644
--- a/iexcode/macros/start_of_the_week.py
+++ b/iexcode/macros/start_of_the_week.py
@@ -14,7 +14,7 @@ from ..instruments.Kappa import *
 from ..instruments.ARPES import *
 
 from .commissioning import *
-from .ScanFunctions_plot import *
+from .quick_plot import *
 
 def start_of_the_week(grt,branch,wait=False,**kwargs):
     """
@@ -73,7 +73,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
         
     ### Stuff that doesn't need beam & does not need to be run if repeating SoTW:
     print("\n\n================== Sets Beamline & Scans:")
-    switch_gratings(grt)
+    grating(grt)
 
     if not kwargs['repeat']: 
         switch_branch(branch)
@@ -274,7 +274,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs):
             check_flux(stay=True)
             exit_slit(50)
             energy(500)
-            scanhv(475,525,1,comment='Mono Scan @ 500eV')
+            scanmono(475,525,1,comment='Mono Scan @ 500eV')
             try:
                 m=BL.mda.lastFileNum()
                 plot_mda(m,detDiode,flux=3);plt.show()
-- 
GitLab