Skip to content

Commit

Permalink
add: support flydmesh, flysdcan in utils.scanparsers
Browse files Browse the repository at this point in the history
  • Loading branch information
keara-soloway committed Feb 2, 2024
1 parent b319659 commit 5665845
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions CHAP/utils/scanparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def get_spec_scan_motor_mnes(self):
m2_mne_i = 5
m2_mne = self.spec_args[m2_mne_i]
return (m1_mne, m2_mne)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
return (self.spec_args[0],)
if self.spec_macro in ('tseries', 'loopscan'):
return ('Time',)
Expand Down Expand Up @@ -584,11 +584,19 @@ def get_spec_scan_motor_vals(self):
m2_npt = int(self.spec_args[m2_nint_i]) + 1
fast_mot_vals = np.linspace(m1_start, m1_end, m1_npt)
slow_mot_vals = np.linspace(m2_start, m2_end, m2_npt)
if self.spec_macro in ('flydmesh', 'dmesh'):
fast_mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[0])
slow_mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[1])
return (fast_mot_vals, slow_mot_vals)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
mot_vals = np.linspace(float(self.spec_args[1]),
float(self.spec_args[2]),
int(self.spec_args[3])+1)
if self.spec_macro == 'flydscan':
mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[0])
return (mot_vals,)
if self.spec_macro in ('tseries', 'loopscan'):
return self.spec_scan.data[:,0]
Expand All @@ -608,7 +616,7 @@ def get_spec_scan_shape(self):
m2_nint_i = 8
slow_mot_npts = int(self.spec_args[m2_nint_i]) + 1
return (fast_mot_npts, slow_mot_npts)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
mot_npts = int(self.spec_args[3])+1
return (mot_npts,)
if self.spec_macro in ('tseries', 'loopscan'):
Expand All @@ -625,7 +633,7 @@ def get_spec_scan_dwell(self):
# Accommodate pre-summer-2022 format
dwell = float(self.spec_args[8])
return dwell
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
return float(self.spec_args[4])
if self.spec_macro in ('tseries', 'loopscan'):
return float(self.spec_args[1])
Expand Down Expand Up @@ -716,15 +724,15 @@ class SMBLinearScanParser(LinearScanParser, SMBScanParser):
"""

def get_spec_scan_dwell(self):
if self.spec_macro in ('flymesh', 'mesh'):
if self.spec_macro in ('flymesh', 'mesh', 'flydmesh'):
try:
# Try post-summer-2022 format
dwell = float(self.spec_args[4])
except:
# Accommodate pre-summer-2022 format
dwell = float(self.spec_args[8])
return dwell
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
return float(self.spec_args[4])
if self.spec_macro == 'tseries':
return float(self.spec_args[1])
Expand All @@ -734,7 +742,7 @@ def get_spec_scan_dwell(self):
f'for scans of type {self.spec_macro}')

def get_spec_scan_motor_mnes(self):
if self.spec_macro in ('flymesh', 'mesh'):
if self.spec_macro in ('flymesh', 'mesh', 'flydmesh'):
m1_mne = self.spec_args[0]
try:
# Try post-summer-2022 format
Expand All @@ -746,15 +754,15 @@ def get_spec_scan_motor_mnes(self):
m2_mne_i = 5
m2_mne = self.spec_args[m2_mne_i]
return (m1_mne, m2_mne)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
return (self.spec_args[0],)
if self.spec_macro in ('tseries', 'loopscan'):
return ('Time',)
raise RuntimeError(f'{self.scan_title}: cannot determine scan motors '
f'for scans of type {self.spec_macro}')

def get_spec_scan_motor_vals(self):
if self.spec_macro in ('flymesh', 'mesh'):
if self.spec_macro in ('flymesh', 'mesh', 'flydmesh'):
m1_start = float(self.spec_args[1])
m1_end = float(self.spec_args[2])
m1_npt = int(self.spec_args[3]) + 1
Expand All @@ -775,19 +783,27 @@ def get_spec_scan_motor_vals(self):
m2_npt = int(self.spec_args[m2_nint_i]) + 1
fast_mot_vals = np.linspace(m1_start, m1_end, m1_npt)
slow_mot_vals = np.linspace(m2_start, m2_end, m2_npt)
if self.spec_macro == 'flydmesh':
fast_mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[0])
slow_mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[1])
return (fast_mot_vals, slow_mot_vals)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
mot_vals = np.linspace(float(self.spec_args[1]),
float(self.spec_args[2]),
int(self.spec_args[3])+1)
if self.spec_macro == 'flydscan':
mot_vals += self.get_positioner_value(
self.spec_scan_motor_mnes[0])
return (mot_vals,)
if self.spec_macro in ('tseries', 'loopscan'):
return (self.spec_scan.data[:,0],)
raise RuntimeError(f'{self.scan_title}: cannot determine scan motors '
f'for scans of type {self.spec_macro}')

def get_spec_scan_shape(self):
if self.spec_macro in ('flymesh', 'mesh'):
if self.spec_macro in ('flymesh', 'mesh', 'flydmesh'):
fast_mot_npts = int(self.spec_args[3]) + 1
try:
# Try post-summer-2022 format
Expand All @@ -799,7 +815,7 @@ def get_spec_scan_shape(self):
m2_nint_i = 8
slow_mot_npts = int(self.spec_args[m2_nint_i]) + 1
return (fast_mot_npts, slow_mot_npts)
if self.spec_macro in ('flyscan', 'ascan'):
if self.spec_macro in ('flyscan', 'ascan', 'flydscan'):
mot_npts = int(self.spec_args[3])+1
return (mot_npts,)
if self.spec_macro in ('tseries', 'loopscan'):
Expand Down

0 comments on commit 5665845

Please sign in to comment.