Skip to content

Commit

Permalink
Do not implicitly load matplotlib and numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgav committed Apr 21, 2022
1 parent d300595 commit c354a19
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ipython_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

# Pre-load matplotlib and numpy for interactive use, selecting a particular
# matplotlib backend and loop integration.
c.TerminalIPythonApp.pylab = 'auto'
# c.TerminalIPythonApp.pylab = 'auto'

# Create a massive crash report when IPython encounters what may be an internal
# error. The default is to append a short message to the usual traceback
Expand Down
18 changes: 9 additions & 9 deletions startup/12-endstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ def forward(self, position):
z2 = z1 + 380
d = 395.2

x_yaw = sin(gamma) * z_yaw / sin(beta + gamma)
R_yaw = sin(beta) * z_yaw / sin(beta + gamma)
x_yaw = np.sin(gamma) * z_yaw / np.sin(beta + gamma)
R_yaw = np.sin(beta) * z_yaw / np.sin(beta + gamma)
R1 = R_yaw - (z_yaw - z1)
R2 = R_yaw - (z_yaw - z2)
y1 = tan(delta) * R1
y2 = tan(delta) * R2
R_det = R1 / cos(delta) - d
y1 = np.tan(delta) * R1
y2 = np.tan(delta) * R2
R_det = R1 / np.cos(delta) - d
dz = r - R_det
if x_yaw > 787 or x_yaw < -200:
raise ValueError(f'diff_x = {-x_yaw}'
Expand Down Expand Up @@ -191,8 +191,8 @@ def inverse(self, position):
z2 = z1 + 380
d = 395.2

x_yaw = sin(gamma) * z_yaw / sin(beta + gamma)
R_yaw = sin(beta) * z_yaw / sin(beta + gamma)
x_yaw = np.sin(gamma) * z_yaw / np.sin(beta + gamma)
R_yaw = np.sin(beta) * z_yaw / np.sin(beta + gamma)
R1 = R_yaw - (z_yaw - z1)
R2 = R_yaw - (z_yaw - z2)

Expand All @@ -202,8 +202,8 @@ def inverse(self, position):
elif abs(diff_y1 / R1 - diff_y2 / R2) > 0.01:
gamma = delta = r = np.nan
else:
delta = arctan(diff_y1 / R1)
r = R1 / cos(delta) - d + diff_cz
delta = np.arctan(diff_y1 / R1)
r = R1 / np.cos(delta) - d + diff_cz

return self.PseudoPosition(gamma=np.rad2deg(gamma),
delta=np.rad2deg(delta),
Expand Down
46 changes: 23 additions & 23 deletions startup/70-users_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from scipy.ndimage.filters import gaussian_filter

#Add ctrl+c option to matplotlib
mpl.rcParams['toolbar'] = 'toolmanager'
matplotlib.rcParams['toolbar'] = 'toolmanager'


def focusmerlin(cnttime):
Expand Down Expand Up @@ -1406,7 +1406,7 @@ def zp_th_fly2d(th_start, th_end, num, x_start, x_end, x_num, y_start, y_end, y_
yield from bps.mov(zpssx,xc)
#yield from bps.movr(smarz,xc/1000)
xspress3.unstage()


'''
yield from fly1d(dets_fs,zpssy,0,3.5,100,0.03)
Expand All @@ -1421,7 +1421,7 @@ def zp_th_fly2d(th_start, th_end, num, x_start, x_end, x_num, y_start, y_end, y_
#cx,cy = return_center_of_mass(-1,'Mn')
#yield from bps.movr(smarx,cx/1000)
#yield from bps.movr(smary,cy/1000)

yield from fly2d(dets1, zpssx, x_start, x_end, x_num, zpssy, y_start, y_end, y_num, sec, dead_time=0.004, return_speed=40)


Expand Down Expand Up @@ -1673,13 +1673,13 @@ def mov_diff(gamma, delta, r=500, calc=0):
z2 = z1 + 380
d = 395.2

x_yaw = sin(gamma) * z_yaw / sin(beta + gamma)
R_yaw = sin(beta) * z_yaw / sin(beta + gamma)
x_yaw = np.sin(gamma) * z_yaw / np.sin(beta + gamma)
R_yaw = np.sin(beta) * z_yaw / np.sin(beta + gamma)
R1 = R_yaw - (z_yaw - z1)
R2 = R_yaw - (z_yaw - z2)
y1 = tan(delta) * R1
y2 = tan(delta) * R2
R_det = R1 / cos(delta) - d
y1 = np.tan(delta) * R1
y2 = np.tan(delta) * R2
R_det = R1 / np.cos(delta) - d
dz = r - R_det

print('Make sure all motors are zeroed properly, '
Expand Down Expand Up @@ -1740,8 +1740,8 @@ def wh_diff():
z2 = z1 + 380
d = 395.2

x_yaw = sin(gamma) * z_yaw / sin(beta + gamma)
R_yaw = sin(beta) * z_yaw / sin(beta + gamma)
x_yaw = np.sin(gamma) * z_yaw / np.sin(beta + gamma)
R_yaw = np.sin(beta) * z_yaw / np.sin(beta + gamma)
R1 = R_yaw - (z_yaw - z1)
R2 = R_yaw - (z_yaw - z2)

Expand All @@ -1751,8 +1751,8 @@ def wh_diff():
elif abs(diff_y1 / R1 - diff_y2 / R2) > 0.01:
print('Not a pure delta rotation')
else:
delta = arctan(diff_y1 / R1)
R_det = R1 / cos(delta) - d + diff_cz
delta = np.arctan(diff_y1 / R1)
R_det = R1 / np.cos(delta) - d + diff_cz
print('gamma = ', gamma * 180 / np.pi, ' delta = ',
delta * 180 / np.pi, ' r = ', R_det)

Expand Down Expand Up @@ -4027,12 +4027,12 @@ def peak_bpm_x(start,end,n_steps):
else:
y[i] = sclr2_ch4.get()
peak = x[y == np.max(y)]

plt.figure()
plt.plot(x,y)
#plt.hold(2)
plt.close()

#print(peak)
caput('XF:03ID-BI{EM:BPM1}fast_pidX.VAL',peak[0])
yield from bps.sleep(5)
Expand Down Expand Up @@ -4185,7 +4185,7 @@ def insert_xrf_map_to_pdf(scan = -1, element = 'Cr',title_ = 'energy', mon = 'sc
plt.close()

def insert_diffSum_to_pdf(scan = -1,det = "merlin1", thMotor = "zpsth"):

plot_img_sum(scan, det)

time_str = str((db[int(scan)].table("baseline")['time'].values)[-1])
Expand All @@ -4198,26 +4198,26 @@ def insert_diffSum_to_pdf(scan = -1,det = "merlin1", thMotor = "zpsth"):


def insert_multiple_xrf_map_to_pdf(scan = -1, elements = ['Pt_L', 'Fe'],title_ = 'energy', mon = 'sclr2_ch4'):
"""

"""
insert 2D-XRF maps to the pdf log from a single scan
- elements has to be in the list. eg:["Cr", "Ti"]
- a title can be added to the figure. Commonly: "energy", "zpsth", "dsth"
- a time stamp will be added to the bottom of the figure
"""

for elem in elements:
insert_xrf_map_to_pdf(scan = scan, element = elem,title_ = title_, mon = mon)

def insert_xrf_series_to_pdf(startSid,endSid, elements = ["Cr", "Ti"], figTitle = "energy",
def insert_xrf_series_to_pdf(startSid,endSid, elements = ["Cr", "Ti"], figTitle = "energy",
mon = 'sclr2_ch4', diffSum = False):
""" insert 2D-XRF maps to the pdf log from a series of scan.

""" insert 2D-XRF maps to the pdf log from a series of scan.
- elements has to be in the list. eg:["Cr", "Ti"]
- a title can be added to the figure. Commonly: "enegry", "zpsth", "dsth"
- a time stamp will be added to the bottom of the figure
"""

scan_nums = np.arange(startSid,endSid+1)
Expand Down
11 changes: 5 additions & 6 deletions startup/80-uscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def save_scan_info(sid):#,export_folder):
z2 = z1 + 380
d = 395.2

x_yaw = sin(gamma) * z_yaw / sin(beta + gamma)
R_yaw = sin(beta) * z_yaw / sin(beta + gamma)
x_yaw = np.sin(gamma) * z_yaw / np.sin(beta + gamma)
R_yaw = np.sin(beta) * z_yaw / np.sin(beta + gamma)
R1 = R_yaw - (z_yaw - z1)
R2 = R_yaw - (z_yaw - z2)

Expand All @@ -61,8 +61,8 @@ def save_scan_info(sid):#,export_folder):
R_det = R1 / np.cos(delta) - d + diff_cz

else:
delta = arctan(diff_y1 / R1)
R_det = R1 / cos(delta) - d + diff_cz
delta = np.arctan(diff_y1 / R1)
R_det = R1 / np.cos(delta) - d + diff_cz

print('gamma, delta, dist:', gamma*180/np.pi, delta*180/np.pi, R_det)
print('ROI: ', roi_x0, roi_y0, roi_nx, roi_ny )
Expand Down Expand Up @@ -582,7 +582,7 @@ def theta_dexela(motorName,angle_start,angle_end,angle_step,exposure_time):
caput('XF:03IDC-ES{Dexela:1}TIFF1:Capture',1)
yield from bps.sleep(exposure_time+0.2)
yield from bps.sleep(1)

yield from bps.mov(motorName,theta_zero)


Expand All @@ -597,4 +597,3 @@ def repeat_2d(zs,ze,z_num):
yield from bps.movr(zps.zpsz,z_step)

yield from bps.mov(zps.zpsz,z_0)

0 comments on commit c354a19

Please sign in to comment.