From 35e51424a2d01b6ea57a93ae91fd215d3f888846 Mon Sep 17 00:00:00 2001
From: jmcchesn <jmcchesn@aps.anl.gov>
Date: Wed, 5 Oct 2022 14:47:46 -0500
Subject: [PATCH] diverged

---
 iexcode/instruments/ARPES.py             |  8 ---
 iexcode/instruments/Octupole.py          |  3 --
 iexcode/instruments/electron_analyzer.py | 63 ++++++++++++++----------
 iexcode/instruments/xrays.py             | 16 +++---
 4 files changed, 44 insertions(+), 46 deletions(-)

diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py
index 9f394e9..82954d1 100644
--- a/iexcode/instruments/ARPES.py
+++ b/iexcode/instruments/ARPES.py
@@ -780,11 +780,7 @@ def scanfocus(x_start,x_stop,x_step,**kwargs):
 
    
 
-<<<<<<< HEAD
 def ARPES_map_sample(y_start=-2,y_stop=2,y_step=0.5,z_start=12,z_stop=16,z_step=0.5,**kwargs):
-=======
-def ARPES_map_sample(inner_loop=["y",0,4,0.5],outer_loop=["z",12,16,0.5]):
->>>>>>> 95226a1fe706ac74c0a7efeef77197a87c943634
     """
     2D map of sample area in ARPES chamber
 
@@ -795,10 +791,6 @@ def ARPES_map_sample(inner_loop=["y",0,4,0.5],outer_loop=["z",12,16,0.5]):
 
     Previously: Map_ARPES_Sample
     """
-<<<<<<< HEAD
     kwargs.setdefault('snake',True)
     ARPES_Motors.scan_2D(["y",y_start,y_stop,y_step],["z",z_start,z_stop,z_step],**kwargs)
-=======
-    ARPES_Motors.scan_2D(inner_loop,outer_loop)
->>>>>>> 95226a1fe706ac74c0a7efeef77197a87c943634
 
diff --git a/iexcode/instruments/Octupole.py b/iexcode/instruments/Octupole.py
index 9924a74..fc72314 100644
--- a/iexcode/instruments/Octupole.py
+++ b/iexcode/instruments/Octupole.py
@@ -424,13 +424,10 @@ def _Octupole_scan_after_sequence(**kwargs):
     kwargs.setdefault('scan_dim',1)
     scan_dim = kwargs['scan_dim']
 
-<<<<<<< HEAD
-=======
     scan_ioc = iex.BL.ioc
 
     after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num)
     
->>>>>>> 95226a1fe706ac74c0a7efeef77197a87c943634
     #clear and write the after scan user sequence
     after_scan_pv,after_scan_proc = _Octupole_scan_after_pvs(clear=True,**kwargs)
 
diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py
index 028f506..d3aa577 100644
--- a/iexcode/instruments/electron_analyzer.py
+++ b/iexcode/instruments/electron_analyzer.py
@@ -447,7 +447,7 @@ def scanEA(EAlist,**kwargs):
 
 
         
-def scanFM(RoughPositions,thList,EAlist,**kwargs):
+def scanFM(EAlist,thList,RoughPositions,**kwargs):
     """
     New FermiMap using ScanRecord table scans to move motors
     RoughPositions is a List rough positions from which to interpolate (use RoughPositions_Find())
@@ -545,11 +545,11 @@ def mvth_interp(RoughPositions, thVal,**kwargs):
     #print("Pos = ",Pos)
     EA.Motors.mvsample(Pos)
 
-def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs):    
+def scanEA_hv(EAlist,hv_lists,**kwargs):    
     """
     triggers and EAscan for each photon energy in *hvs
     
-    hv_start_stop_step_lists, listoflist ... see scanXAS for more info
+    hv_list, listoflist ... see scanXAS for more info
     
     EAlist = 
         Fixed Mode: EAlist=["KE/BE",CenterEnergy,PassEnergy,Frames,Sweeps] (5)
@@ -561,8 +561,9 @@ def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs):
             (-) BE is negative above Ef
    
     usage:
-        scanEA_hv([400,500,1200],EAlist=["BE",-5,200,17*60,1])
-        NOTE that EAlist = needs to be written explicitly
+        hv_list=[400,500,10]
+        EAlist=["BE",-5,200,17*60,1]
+        scanEA_hv(EAlist,hv_lists)
         
     **kwargs
         execute: True/False to start the scan => True (default)
@@ -590,9 +591,9 @@ def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs):
     #Setting up the ScanRecord for Mono and ID in Table mode
     kwargs["scan_dim"]=2
     kwargs["execute"]=False
-    mono_array,ID_array = BL_energy_tables(hv_start_stop_step_lists,**kwargs)
+    mono_array,ID_array = BL_energy_tables(hv_lists,**kwargs)
     kwargs.update({"ID_tracking":True})
-    scanXAS(hv_start_stop_step_lists,**kwargs)
+    scanXAS(hv_lists,**kwargs)
    
     if scanGo == True:
         #Setting the beamline energy to the first point, and EA at first KE
@@ -604,11 +605,11 @@ def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs):
         scanEA_reset(**kwargs)
         iex.BL.mda.table_reset_after(**kwargs)
 
-def scanEA_y(EAlist, start,stop,step,mode='absolute',**kwargs):
-    scanEA_motor(EAlist,'y',start,stop,step,mode=mode,**kwargs)
+def scanEA_y(EAlist, y_start,y_stop,y_step,mode='absolute',**kwargs):
+    scanEA_motor(EAlist,'y',y_start,y_stop,y_step,mode=mode,**kwargs)
 
-def scanEA_z(EAlist, start,stop,step,mode='absolute',**kwargs):
-    scanEA_motor(EAlist,'z',start,stop,step,mode=mode,**kwargs)
+def scanEA_z(EAlist,z_start,z_stop,z_step,mode='absolute',**kwargs):
+    scanEA_motor(EAlist,'z',z_start,z_stop,z_step,mode=mode,**kwargs)
 
     
 def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs):
@@ -655,11 +656,11 @@ def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs):
         #After scan
         scanEA_reset(**kwargs)
 
-def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs):
+def scanEA_map_sample(EAlist,y_list,z_list,**kwargs):
     """
     2D scan mesh (y/z) while triggering the EA: scan_dim=1
-    y_start_stop_step=[start1,stop1,step1] #y: scan_dim=2
-    z_start_stop_step=[start2,stop2,step2] #z: scan_dim=3
+    y_list=[start1,stop1,step1] #y: scan_dim=2
+    z_list=[start2,stop2,step2] #z: scan_dim=3
     
        
     EAlist = 
@@ -687,8 +688,8 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs):
 
     #Setting up the ScanRecord for motor scans
     outer_scan_dim=3 #hard coded 
-    inner_loop_list = y_start_stop_step.insert(0,"y")
-    outer_loop_list = z_start_stop_step.insert(0,"z")
+    inner_loop_list = y_list.insert(0,"y")
+    outer_loop_list = z_list.insert(0,"z")
     EA.Motors.scan_2D(inner_loop_list,outer_loop_list,outer_scan_dim,**kwargs)
     
     if kwargs['debug']:
@@ -702,10 +703,7 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs):
 
         #After scan
         scanEA_reset(**kwargs)
-
-        
-        
-        
+             
     
 def hv2kz(lattice,V0,hv):
     """
@@ -776,13 +774,24 @@ def Print_Gamma_hv(lattice,V0,hv1,hv2):
     print("\n hv2 = "+str(hv2)+" eV:  " +str(GZ_n2)+" * pi/c = " +str(G_n2)+" * 2pi/c")
     return n1,n2
 
-def kx2deg(lattice,hv):
-    a=np.pi/lattice
-    b=0.5124*np.sqrt(hv)
-    c=a/b
-    theta_rad=np.asin(c)
-    theta_deg=rad2deg(theta_rad)
-    print(" 1/2-BZ (GX) = "+str(round(theta_deg,1))+" deg")
+def deg2kx(th,hv,verbose=True):
+    """
+    kx = 0.5124*sqrt(hv)*sin(theta)
+    """
+    kx = 0.5124*np.sqrt(hv)*np.sin(th/180*np.pi)
+    if verbose:
+        print('kx = '+str(round(kx,3))+' 1/A')
+    return kx
+
+def kx2deg(kx,hv,verbose=True):
+    """
+    theta = asin(kx/0.5124/sqrt(hv))
+    """
+    th = np.asin(kx/0.5124/np.sqrt(hv))*180/np.pi
+    if verbose:
+        print('th = '+str(round(th,3))+' deg')
+    return th
+
     
 def resolution_EA(PE,slit_SES):    # updated 10/30/17: straight slits scaled to slit width not area
     SES_Table={}
diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py
index 0f85692..76a00cc 100644
--- a/iexcode/instruments/xrays.py
+++ b/iexcode/instruments/xrays.py
@@ -237,7 +237,7 @@ def qp(QP_ratio):
 ##############################################################################################################
 ################################             beamline slits  = apertures          ##############################
 ############################################################################################################## 
-def aperture_fit(hv,slit_num):
+def _aperture_fit(hv,slit_num):
     """
     used close the beamline apertures/slits to only take the center of the beam, 
         i.e. no heat bump (determined emperically by looking at the the shift in energy vs slit position)
@@ -283,8 +283,8 @@ def apertures_set(c_2B=1,c_1A=1,verbose=True):
     V1_center= slit_position[grt]['S1V']
     H1_center= slit_position[grt]['S1H']
 
-    Size1A=( aperture_fit(hv,1)[0]*c_1A,       aperture_fit(hv,1)[1]*c_1A )
-    Size2B=( aperture_fit(hv,2)[0]*c_2B, round(aperture_fit(hv,2)[1]*c_2B*V,3))
+    Size1A=( _aperture_fit(hv,1)[0]*c_1A,       _aperture_fit(hv,1)[1]*c_1A )
+    Size2B=( _aperture_fit(hv,2)[0]*c_2B, round(_aperture_fit(hv,2)[1]*c_2B*V,3))
     
     slit1A_set(Size1A[0],Size1A[1],center=(H1_center,V1_center),verbose=verbose)    # standard operating
     slit2B_set(Size2B[0],Size2B[1],center=(H2_center,V2_center),verbose=verbose)
@@ -383,14 +383,14 @@ def scanmono(start,stop,step,average_pnts=1,**kwargs):
 
 
 
-def scanXAS(start_stop_step_lists,ID_tracking=False, **kwargs):
+def scanXAS(hv_list,ID_tracking=False, **kwargs):
     """
     scans the beamline energy:
         ID_eV = None        => the ID stays at the current value (default) 
         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
-        start_stop_step_lists = [[start1,stop1,step1], [start1,stop1,step1],...]
+        hv_list = [[start1,stop1,step1], [start1,stop1,step1],...]
         Note duplicates are removed and the resulting array is sorted in ascending order
 
     **kwargs:
@@ -415,7 +415,7 @@ def scanXAS(start_stop_step_lists,ID_tracking=False, **kwargs):
     scan_dim=kwargs['scan_dim']
     
     #Setting up the ScanRecord for Mono and ID in Table mode
-    mono_array,ID_array = BL_energy_tables(start_stop_step_lists,**kwargs)
+    mono_array,ID_array = BL_energy_tables(hv_list,**kwargs)
     #break is mono_array has no points
     if len(list(mono_array)) == 0:
         return
@@ -455,7 +455,7 @@ def scanXAS(start_stop_step_lists,ID_tracking=False, **kwargs):
             print("WARNING: Mesh"+iex.BL.branch+" is still In")        
 
 
-def BL_energy_tables(start_stop_step_lists,**kwargs):
+def BL_energy_tables(hv_lists,**kwargs):
     """
     returns mono_array and ID_array for BL energy scans
     *energies:
@@ -466,7 +466,7 @@ def BL_energy_tables(start_stop_step_lists,**kwargs):
     Previously: Tables_BLenergy
     """
     kwargs.setdefault('QP_ratio', 100)
-    mono_array = make_table(start_stop_step_lists)
+    mono_array = make_table(hv_lists)
     if len(list(mono_array)) == 0:
         print_warning_message('mono_array is length 0, check start_stop_step_lists')
     ID_array=np.array([])
-- 
GitLab