Skip to content

Commit

Permalink
Merge pull request #17 from hz-b/headerString
Browse files Browse the repository at this point in the history
Corrected SPEC header formation from bluesky start doc
  • Loading branch information
danielballan authored Mar 31, 2022
2 parents 862f9c8 + d38db49 commit 793f6e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
16 changes: 11 additions & 5 deletions suitcase/specfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _get_plan_name(start):

def _get_motor_name(start):
plan_name = _get_plan_name(start)
if (plan_name not in _BLUESKY_PLAN_NAMES or
if (plan_name not in _SPEC_SCAN_NAMES or
plan_name in _SCANS_WITHOUT_MOTORS):
return 'seq_num'
motor_name = start['motors']
Expand All @@ -172,7 +172,7 @@ def _get_motor_name(start):
def _get_motor_position(start, event):
plan_name = _get_plan_name(start)
# make sure we are trying to get the motor position for an implemented scan
if (plan_name not in _BLUESKY_PLAN_NAMES or
if (plan_name not in _SPEC_SCAN_NAMES or
plan_name in _SCANS_WITHOUT_MOTORS):
return event['seq_num']
motor_name = _get_motor_name(start)
Expand Down Expand Up @@ -226,12 +226,18 @@ def to_spec_scan_header(start, primary_descriptor, baseline_event=None):
motor_name = _get_motor_name(start)
acq_time = _get_acq_time(start)
# can only grab start/stop/num if we are a dscan or ascan.
if (scan_command not in _BLUESKY_PLAN_NAMES or
if (scan_command not in _SPEC_SCAN_NAMES or
scan_command in _SCANS_WITHOUT_MOTORS):
command_args = []

else:
command_args = [start['plan_args'][k]
for k in ('start', 'stop', 'num')]

start_val = start['plan_args']['args'][-2]
stop_val = start['plan_args']['args'][-1]
num = start['plan_args']['num']

command_args = [start_val, stop_val, num]

command_list = ([scan_command, motor_name] + command_args + [acq_time])
# have to ensure all list elements are strings or join gets angry
md['command'] = ' '.join([str(s) for s in command_list])
Expand Down
12 changes: 6 additions & 6 deletions suitcase/specfile/tests/data_from_suitcase_v0.7.0/rel_scan.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#O0 SIM:motor1 SIM:motor1_setpoint SIM:motor2 SIM:motor2_setpoint
#o0 motor1 motor1_setpoint motor2 motor2_setpoint

#S 4 dscan seq_num -1
#S 4 dscan motor -1 1 3 -1
#D Wed Mar 06 11:01:18 2019
#T -1 (Seconds)
#P0 0 0 0 0
#N 6
#L seq_num Epoch Seconds det motor motor_setpoint
1 1551888078 -1 1.0 0.0 0.0
#N 4
#L motor Epoch Seconds det
0.0 1551888078 -1 1.0

2 1551888078 -1 0.6065306597126334 1.0 1.0
1.0 1551888078 -1 0.6065306597126334

3 1551888078 -1 0.1353352832366127 2.0 2.0
2.0 1551888078 -1 0.1353352832366127

12 changes: 6 additions & 6 deletions suitcase/specfile/tests/data_from_suitcase_v0.7.0/scan.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#O0 SIM:motor1 SIM:motor1_setpoint SIM:motor2 SIM:motor2_setpoint
#o0 motor1 motor1_setpoint motor2 motor2_setpoint

#S 3 ascan seq_num -1
#S 3 ascan motor -1 1 3 -1
#D Wed Mar 06 11:01:18 2019
#T -1 (Seconds)
#P0 0 0 0 0
#N 6
#L seq_num Epoch Seconds det motor motor_setpoint
1 1551888078 -1 0.6065306597126334 -1.0 -1.0
#N 4
#L motor Epoch Seconds det
-1.0 1551888078 -1 0.6065306597126334

2 1551888078 -1 1.0 0.0 0.0
0.0 1551888078 -1 1.0

3 1551888078 -1 0.6065306597126334 1.0 1.0
1.0 1551888078 -1 0.6065306597126334

0 comments on commit 793f6e5

Please sign in to comment.