mx-bluesky 0.0.2__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mx_bluesky/__main__.py +1 -2
- mx_bluesky/_version.py +14 -2
- mx_bluesky/example.py +4 -4
- mx_bluesky/i04/__init__.py +3 -0
- mx_bluesky/i04/callbacks/murko_callback.py +45 -0
- mx_bluesky/i04/thawing_plan.py +84 -0
- mx_bluesky/i24/serial/__init__.py +49 -0
- mx_bluesky/i24/serial/blueapi_config.yaml +12 -0
- mx_bluesky/{I24 → i24}/serial/dcid.py +53 -41
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/DiamondExtruder-I24-py3v1.edl +28 -32
- mx_bluesky/{I24 → i24}/serial/extruder/EX-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/i24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +513 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/CustomChip_py3v1.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DetStage.edl +1 -2
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/DiamondChipI24-py3v1.edl +46 -41
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/ME14E-GeneralPurpose.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/MappingLite-oxford_py3v1.edl +10 -11
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/PMAC_Command.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/Shutter_Control.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/microdrop_alignment.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/nudgechip.edl +0 -1
- mx_bluesky/{I24 → i24}/serial/fixed_target/FT-gui-edm/pumpprobe-py3v1.edl +273 -143
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short1-laser.png +0 -0
- mx_bluesky/i24/serial/fixed_target/FT-gui-edm/short2-laser.png +0 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/ft_utils.py +24 -1
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +798 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Manager_py3v1.py +374 -412
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_Chip_Mapping_py3v1.py +34 -40
- mx_bluesky/i24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +325 -0
- mx_bluesky/{I24 → i24}/serial/fixed_target/i24ssx_moveonclick.py +39 -41
- mx_bluesky/i24/serial/log.py +156 -0
- mx_bluesky/i24/serial/parameters/__init__.py +15 -0
- mx_bluesky/i24/serial/parameters/constants.py +47 -0
- mx_bluesky/i24/serial/parameters/experiment_parameters.py +124 -0
- mx_bluesky/i24/serial/parameters/fixed_target/cs/cs_maker.json +9 -0
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/cs/motor_direction.txt +1 -1
- mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/minichip-oxford.pvar +1 -1
- mx_bluesky/i24/serial/parameters/utils.py +40 -0
- mx_bluesky/i24/serial/run_extruder.sh +19 -0
- mx_bluesky/i24/serial/run_fixed_target.sh +22 -0
- mx_bluesky/i24/serial/run_serial.py +36 -0
- mx_bluesky/{I24 → i24}/serial/set_visit_directory.sh +6 -1
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv.py +1 -62
- mx_bluesky/{I24 → i24}/serial/setup_beamline/pv_abstract.py +6 -7
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_beamline.py +90 -269
- mx_bluesky/{I24 → i24}/serial/setup_beamline/setup_detector.py +47 -40
- mx_bluesky/i24/serial/setup_beamline/setup_zebra_plans.py +459 -0
- mx_bluesky/i24/serial/start_blueapi.sh +28 -0
- mx_bluesky/i24/serial/write_nexus.py +102 -0
- mx_bluesky/parameters/__init__.py +31 -0
- mx_bluesky/parameters/components.py +200 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-0.3.1.dist-info}/METADATA +33 -27
- mx_bluesky-0.3.1.dist-info/RECORD +67 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-0.3.1.dist-info}/WHEEL +1 -1
- mx_bluesky-0.3.1.dist-info/entry_points.txt +4 -0
- mx_bluesky/I24/serial/extruder/i24ssx_Extruder_Collect_py3v2.py +0 -476
- mx_bluesky/I24/serial/fixed_target/FT-gui-edm/ME14E-motors.edl +0 -1874
- mx_bluesky/I24/serial/fixed_target/__init__.py +0 -0
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_Collect_py3v1.py +0 -706
- mx_bluesky/I24/serial/fixed_target/i24ssx_Chip_StartUp_py3v1.py +0 -463
- mx_bluesky/I24/serial/log.py +0 -101
- mx_bluesky/I24/serial/parameters/__init__.py +0 -5
- mx_bluesky/I24/serial/parameters/constants.py +0 -39
- mx_bluesky/I24/serial/parameters/fixed_target/cs/cs_maker.json +0 -9
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_1.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/cs/fiducial_2.txt +0 -4
- mx_bluesky/I24/serial/parameters/fixed_target/litemaps/currentchip.map +0 -81
- mx_bluesky/I24/serial/parameters/fixed_target/parameters.txt +0 -13
- mx_bluesky/I24/serial/run_serial.py +0 -52
- mx_bluesky/I24/serial/write_nexus.py +0 -113
- mx_bluesky-0.0.2.dist-info/RECORD +0 -58
- mx_bluesky-0.0.2.dist-info/entry_points.txt +0 -4
- /mx_bluesky/{I24 → i24}/__init__.py +0 -0
- /mx_bluesky/{I24/serial → i24/serial/extruder}/__init__.py +0 -0
- /mx_bluesky/{I24/serial/extruder → i24/serial/fixed_target}/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/parameters/fixed_target/pvar_files/oxford.pvar +0 -0
- /mx_bluesky/{I24 → i24}/serial/run_ssx.sh +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/__init__.py +0 -0
- /mx_bluesky/{I24 → i24}/serial/setup_beamline/ca.py +0 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-0.3.1.dist-info}/LICENSE +0 -0
- {mx_bluesky-0.0.2.dist-info → mx_bluesky-0.3.1.dist-info}/top_level.txt +0 -0
|
File without changes
|
|
@@ -1,706 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Fixed target data collection
|
|
3
|
-
"""
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import logging
|
|
7
|
-
import os
|
|
8
|
-
import shutil
|
|
9
|
-
import sys
|
|
10
|
-
import time
|
|
11
|
-
from datetime import datetime
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
from time import sleep
|
|
14
|
-
from typing import Dict, List
|
|
15
|
-
|
|
16
|
-
import numpy as np
|
|
17
|
-
from dodal.beamlines import i24
|
|
18
|
-
from dodal.devices.i24.pmac import PMAC
|
|
19
|
-
|
|
20
|
-
from mx_bluesky.I24.serial import log
|
|
21
|
-
from mx_bluesky.I24.serial.dcid import DCID
|
|
22
|
-
from mx_bluesky.I24.serial.fixed_target.ft_utils import (
|
|
23
|
-
ChipType,
|
|
24
|
-
MappingType,
|
|
25
|
-
PumpProbeSetting,
|
|
26
|
-
)
|
|
27
|
-
from mx_bluesky.I24.serial.fixed_target.i24ssx_Chip_StartUp_py3v1 import (
|
|
28
|
-
get_format,
|
|
29
|
-
scrape_parameter_file,
|
|
30
|
-
)
|
|
31
|
-
from mx_bluesky.I24.serial.parameters import SSXType
|
|
32
|
-
from mx_bluesky.I24.serial.parameters.constants import LITEMAP_PATH, PARAM_FILE_PATH_FT
|
|
33
|
-
from mx_bluesky.I24.serial.setup_beamline import caget, cagetstring, caput, pv
|
|
34
|
-
from mx_bluesky.I24.serial.setup_beamline import setup_beamline as sup
|
|
35
|
-
from mx_bluesky.I24.serial.setup_beamline.setup_detector import get_detector_type
|
|
36
|
-
from mx_bluesky.I24.serial.write_nexus import call_nexgen
|
|
37
|
-
|
|
38
|
-
logger = logging.getLogger("I24ssx.fixed_target")
|
|
39
|
-
|
|
40
|
-
usage = "%(prog)s [options]"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def setup_logging():
|
|
44
|
-
# Log should now change name daily.
|
|
45
|
-
logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
|
|
46
|
-
log.config(logfile)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def flush_print(text):
|
|
50
|
-
sys.stdout.write(str(text))
|
|
51
|
-
sys.stdout.flush()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def copy_files_to_data_location(
|
|
55
|
-
dest_dir: Path | str,
|
|
56
|
-
param_path: Path = PARAM_FILE_PATH_FT,
|
|
57
|
-
map_file: Path = LITEMAP_PATH,
|
|
58
|
-
map_type: str = "1",
|
|
59
|
-
):
|
|
60
|
-
if not isinstance(dest_dir, Path):
|
|
61
|
-
dest_dir = Path(dest_dir)
|
|
62
|
-
dest_dir.mkdir(parents=True, exist_ok=True)
|
|
63
|
-
shutil.copy2(param_path / "parameters.txt", dest_dir / "parameters.txt")
|
|
64
|
-
if map_type == MappingType.Lite:
|
|
65
|
-
shutil.copy2(map_file / "currentchip.map", dest_dir / "currentchip.map")
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
@log.log_on_entry
|
|
69
|
-
def get_chip_prog_values(
|
|
70
|
-
chip_type,
|
|
71
|
-
pump_repeat,
|
|
72
|
-
pumpexptime,
|
|
73
|
-
pumpdelay,
|
|
74
|
-
prepumpexptime,
|
|
75
|
-
exptime=16,
|
|
76
|
-
n_exposures=1,
|
|
77
|
-
):
|
|
78
|
-
if chip_type in [ChipType.Oxford, ChipType.OxfordInner, ChipType.Minichip]:
|
|
79
|
-
logger.info("This is an Oxford chip %s" % chip_type)
|
|
80
|
-
# '1' = 'Oxford ' = [8, 8, 20, 20, 0.125, 3.175, 3.175]
|
|
81
|
-
(
|
|
82
|
-
xblocks,
|
|
83
|
-
yblocks,
|
|
84
|
-
x_num_steps,
|
|
85
|
-
y_num_steps,
|
|
86
|
-
w2w,
|
|
87
|
-
b2b_horz,
|
|
88
|
-
b2b_vert,
|
|
89
|
-
) = get_format(chip_type)
|
|
90
|
-
x_step_size = w2w
|
|
91
|
-
y_step_size = w2w
|
|
92
|
-
x_block_size = ((x_num_steps - 1) * w2w) + b2b_horz
|
|
93
|
-
y_block_size = ((y_num_steps - 1) * w2w) + b2b_vert
|
|
94
|
-
|
|
95
|
-
elif chip_type == ChipType.Custom:
|
|
96
|
-
# This is set by the user in the edm screen
|
|
97
|
-
# The chip format might change every time and is read from PVs.
|
|
98
|
-
logger.info("This is a Custom Chip")
|
|
99
|
-
x_num_steps = caget(pv.me14e_gp6)
|
|
100
|
-
y_num_steps = caget(pv.me14e_gp7)
|
|
101
|
-
x_step_size = caget(pv.me14e_gp8)
|
|
102
|
-
y_step_size = caget(pv.me14e_gp99)
|
|
103
|
-
xblocks = 1
|
|
104
|
-
yblocks = 1
|
|
105
|
-
x_block_size = 0 # placeholder
|
|
106
|
-
y_block_size = 0 # placeholder
|
|
107
|
-
else:
|
|
108
|
-
logger.warning("Unknown chip_type, chip_type = %s" % chip_type)
|
|
109
|
-
|
|
110
|
-
# this is where p variables for fast laser expts will be set
|
|
111
|
-
if pump_repeat in [
|
|
112
|
-
PumpProbeSetting.NoPP,
|
|
113
|
-
PumpProbeSetting.Short1,
|
|
114
|
-
PumpProbeSetting.Short2,
|
|
115
|
-
]:
|
|
116
|
-
pump_repeat_pvar = 0
|
|
117
|
-
elif pump_repeat == PumpProbeSetting.Repeat1:
|
|
118
|
-
pump_repeat_pvar = 1
|
|
119
|
-
elif pump_repeat == PumpProbeSetting.Repeat2:
|
|
120
|
-
pump_repeat_pvar = 2
|
|
121
|
-
elif pump_repeat == PumpProbeSetting.Repeat3:
|
|
122
|
-
pump_repeat_pvar = 3
|
|
123
|
-
elif pump_repeat == PumpProbeSetting.Repeat5:
|
|
124
|
-
pump_repeat_pvar = 5
|
|
125
|
-
elif pump_repeat == PumpProbeSetting.Repeat10:
|
|
126
|
-
pump_repeat_pvar = 10
|
|
127
|
-
else:
|
|
128
|
-
logger.warning("Unknown pump_repeat, pump_repeat = %s" % pump_repeat)
|
|
129
|
-
|
|
130
|
-
logger.info("Pump repeat is %s, PVAR set to %s" % (pump_repeat, pump_repeat_pvar))
|
|
131
|
-
|
|
132
|
-
if pump_repeat == PumpProbeSetting.Short2:
|
|
133
|
-
pump_in_probe = 1
|
|
134
|
-
else:
|
|
135
|
-
pump_in_probe = 0
|
|
136
|
-
|
|
137
|
-
logger.info("pump_in_probe set to %s" % pump_in_probe)
|
|
138
|
-
|
|
139
|
-
chip_dict = {
|
|
140
|
-
"X_NUM_STEPS": [11, x_num_steps],
|
|
141
|
-
"Y_NUM_STEPS": [12, y_num_steps],
|
|
142
|
-
"X_STEP_SIZE": [13, x_step_size],
|
|
143
|
-
"Y_STEP_SIZE": [14, y_step_size],
|
|
144
|
-
"DWELL_TIME": [15, exptime],
|
|
145
|
-
"X_START": [16, 0],
|
|
146
|
-
"Y_START": [17, 0],
|
|
147
|
-
"Z_START": [18, 0],
|
|
148
|
-
"X_NUM_BLOCKS": [20, xblocks],
|
|
149
|
-
"Y_NUM_BLOCKS": [21, yblocks],
|
|
150
|
-
"X_BLOCK_SIZE": [24, x_block_size],
|
|
151
|
-
"Y_BLOCK_SIZE": [25, y_block_size],
|
|
152
|
-
"COLTYPE": [26, 41],
|
|
153
|
-
"N_EXPOSURES": [30, n_exposures],
|
|
154
|
-
"PUMP_REPEAT": [32, pump_repeat_pvar],
|
|
155
|
-
"LASER_DWELL": [34, pumpexptime],
|
|
156
|
-
"LASERTWO_DWELL": [35, prepumpexptime],
|
|
157
|
-
"LASER_DELAY": [37, pumpdelay],
|
|
158
|
-
"PUMP_IN_PROBE": [38, pump_in_probe],
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
chip_dict["DWELL_TIME"][1] = 1000 * float(exptime)
|
|
162
|
-
chip_dict["LASER_DWELL"][1] = 1000 * float(pumpexptime)
|
|
163
|
-
chip_dict["LASERTWO_DWELL"][1] = 1000 * float(prepumpexptime)
|
|
164
|
-
chip_dict["LASER_DELAY"][1] = 1000 * float(pumpdelay)
|
|
165
|
-
|
|
166
|
-
return chip_dict
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
@log.log_on_entry
|
|
170
|
-
def load_motion_program_data(
|
|
171
|
-
pmac: PMAC, motion_program_dict: Dict[str, List], map_type: int, pump_repeat: int
|
|
172
|
-
):
|
|
173
|
-
logger.info("Loading motion program data for chip.")
|
|
174
|
-
logger.info("Pump_repeat is %s" % pump_repeat)
|
|
175
|
-
if pump_repeat == PumpProbeSetting.NoPP:
|
|
176
|
-
if map_type == MappingType.NoMap:
|
|
177
|
-
prefix = 11
|
|
178
|
-
logger.info(
|
|
179
|
-
"Map type is %s, setting program prefix to %s" % (map_type, prefix)
|
|
180
|
-
)
|
|
181
|
-
elif map_type == MappingType.Lite:
|
|
182
|
-
prefix = 12
|
|
183
|
-
elif map_type == MappingType.Full:
|
|
184
|
-
prefix = 13
|
|
185
|
-
else:
|
|
186
|
-
logger.warning("Unknown Map Type, map_type = %s" % map_type)
|
|
187
|
-
return
|
|
188
|
-
elif pump_repeat in [pp.value for pp in PumpProbeSetting if pp != 0]:
|
|
189
|
-
# Pump setting chosen
|
|
190
|
-
prefix = 14
|
|
191
|
-
logger.info("Setting program prefix to %s" % prefix)
|
|
192
|
-
pmac.pmac_string.set("P1439=0")
|
|
193
|
-
if bool(caget(pv.me14e_gp111)) is True:
|
|
194
|
-
logger.info("Checker pattern setting enabled.")
|
|
195
|
-
pmac.pmac_string.set("P1439=1")
|
|
196
|
-
else:
|
|
197
|
-
logger.warning("Unknown Pump repeat, pump_repeat = %s" % pump_repeat)
|
|
198
|
-
return
|
|
199
|
-
|
|
200
|
-
logger.info("Set PMAC_STRING pv.")
|
|
201
|
-
for key in sorted(motion_program_dict.keys()):
|
|
202
|
-
v = motion_program_dict[key]
|
|
203
|
-
pvar_base = prefix * 100
|
|
204
|
-
pvar = pvar_base + v[0]
|
|
205
|
-
value = str(v[1])
|
|
206
|
-
s = "P%s=%s" % (str(pvar), str(value))
|
|
207
|
-
logger.info("%s \t %s" % (key, s))
|
|
208
|
-
pmac.pmac_string.set(s)
|
|
209
|
-
sleep(0.02)
|
|
210
|
-
sleep(0.2)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
@log.log_on_entry
|
|
214
|
-
def get_prog_num(chip_type: int, map_type: int, pump_repeat: int):
|
|
215
|
-
logger.info("Get Program Number")
|
|
216
|
-
if pump_repeat == PumpProbeSetting.NoPP:
|
|
217
|
-
if chip_type in [ChipType.Oxford, ChipType.OxfordInner]:
|
|
218
|
-
logger.info("Pump_repeat: %s \tOxford Chip: %s" % (pump_repeat, chip_type))
|
|
219
|
-
if map_type == MappingType.NoMap:
|
|
220
|
-
logger.info("Map type 0 = None")
|
|
221
|
-
logger.info("Program number: 11")
|
|
222
|
-
return 11
|
|
223
|
-
elif map_type == MappingType.Lite:
|
|
224
|
-
logger.info("Map type 1 = Mapping Lite")
|
|
225
|
-
logger.info("Program number: 12")
|
|
226
|
-
return 12
|
|
227
|
-
elif map_type == MappingType.Full:
|
|
228
|
-
logger.info("Map type 1 = Full Mapping")
|
|
229
|
-
logger.info("Program number: 13") # once fixed return 13
|
|
230
|
-
msg = "Mapping Type FULL is broken as of 11.09.17"
|
|
231
|
-
logger.error(msg)
|
|
232
|
-
raise ValueError(msg)
|
|
233
|
-
else:
|
|
234
|
-
logger.debug("Unknown Mapping Type; map_type = %s" % map_type)
|
|
235
|
-
return 0
|
|
236
|
-
elif chip_type == ChipType.Custom:
|
|
237
|
-
logger.info("Pump_repeat: %s \tCustom Chip: %s" % (pump_repeat, chip_type))
|
|
238
|
-
logger.info("Program number: 11")
|
|
239
|
-
return 11
|
|
240
|
-
elif chip_type == ChipType.Minichip:
|
|
241
|
-
logger.info(
|
|
242
|
-
"Pump_repeat: %s \tMini Oxford Chip: %s" % (pump_repeat, chip_type)
|
|
243
|
-
)
|
|
244
|
-
logger.info("Program number: 11")
|
|
245
|
-
return 11
|
|
246
|
-
else:
|
|
247
|
-
logger.debug("Unknown chip_type, chip_tpe = = %s" % chip_type)
|
|
248
|
-
return 0
|
|
249
|
-
elif pump_repeat in [pp.value for pp in PumpProbeSetting if pp != 0]:
|
|
250
|
-
logger.info("Pump_repeat: %s \t Chip Type: %s" % (pump_repeat, chip_type))
|
|
251
|
-
logger.info("Map Type = Mapping Lite with Pump Probe")
|
|
252
|
-
logger.info("Program number: 14")
|
|
253
|
-
return 14
|
|
254
|
-
else:
|
|
255
|
-
logger.warning("Unknown pump_repeat, pump_repeat = = %s" % pump_repeat)
|
|
256
|
-
return 0
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
@log.log_on_entry
|
|
260
|
-
def datasetsizei24():
|
|
261
|
-
# Calculates how many images will be collected based on map type and N repeats
|
|
262
|
-
logger.info("Calculate total number of images expected in data collection.")
|
|
263
|
-
(
|
|
264
|
-
chip_name,
|
|
265
|
-
visit,
|
|
266
|
-
sub_dir,
|
|
267
|
-
n_exposures,
|
|
268
|
-
chip_type,
|
|
269
|
-
map_type,
|
|
270
|
-
pump_repeat,
|
|
271
|
-
pumpexptime,
|
|
272
|
-
pumpdelay,
|
|
273
|
-
exptime,
|
|
274
|
-
dcdetdist,
|
|
275
|
-
prepumpexptime,
|
|
276
|
-
det_type,
|
|
277
|
-
) = scrape_parameter_file()
|
|
278
|
-
|
|
279
|
-
if map_type == MappingType.NoMap:
|
|
280
|
-
if chip_type == ChipType.Custom:
|
|
281
|
-
total_numb_imgs = int(int(caget(pv.me14e_gp6)) * int(caget(pv.me14e_gp7)))
|
|
282
|
-
logger.info(
|
|
283
|
-
"Map type: None \tCustom chip \tNumber of images %s" % total_numb_imgs
|
|
284
|
-
)
|
|
285
|
-
else:
|
|
286
|
-
chip_format = get_format(chip_type)[:4]
|
|
287
|
-
total_numb_imgs = np.prod(chip_format)
|
|
288
|
-
logger.info(
|
|
289
|
-
"Map type: None \tOxford chip %s \tNumber of images %s"
|
|
290
|
-
% (chip_type, total_numb_imgs)
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
elif map_type == MappingType.Lite:
|
|
294
|
-
logger.info("Using Mapping Lite on chip type %s" % chip_type)
|
|
295
|
-
chip_format = get_format(chip_type)[2:4]
|
|
296
|
-
block_count = 0
|
|
297
|
-
with open(LITEMAP_PATH / "currentchip.map", "r") as f:
|
|
298
|
-
for line in f.readlines():
|
|
299
|
-
entry = line.split()
|
|
300
|
-
if entry[2] == "1":
|
|
301
|
-
block_count += 1
|
|
302
|
-
|
|
303
|
-
logger.info("Block count=%s" % block_count)
|
|
304
|
-
logger.info("Chip format=%s" % chip_format)
|
|
305
|
-
|
|
306
|
-
n_exposures = int(caget(pv.me14e_gp3))
|
|
307
|
-
logger.info("Number of exposures=%s" % n_exposures)
|
|
308
|
-
|
|
309
|
-
total_numb_imgs = np.prod(chip_format) * block_count * n_exposures
|
|
310
|
-
logger.info("Calculated number of images: %s" % total_numb_imgs)
|
|
311
|
-
|
|
312
|
-
elif map_type == MappingType.Full:
|
|
313
|
-
logger.error("Not Set Up For Full Mapping")
|
|
314
|
-
raise ValueError("The beamline is currently not set for Full Mapping.")
|
|
315
|
-
|
|
316
|
-
else:
|
|
317
|
-
logger.warning("Unknown Map Type, map_type = %s" % map_type)
|
|
318
|
-
raise ValueError("Unknown map type")
|
|
319
|
-
|
|
320
|
-
logger.info("Set PV to calculated number of images.")
|
|
321
|
-
caput(pv.me14e_gp10, total_numb_imgs)
|
|
322
|
-
|
|
323
|
-
return total_numb_imgs
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
@log.log_on_entry
|
|
327
|
-
def start_i24():
|
|
328
|
-
"""Returns a tuple of (start_time, dcid)"""
|
|
329
|
-
logger.info("Start I24 data collection.")
|
|
330
|
-
start_time = datetime.now()
|
|
331
|
-
logger.info("Collection start time %s" % start_time.ctime())
|
|
332
|
-
|
|
333
|
-
(
|
|
334
|
-
chip_name,
|
|
335
|
-
visit,
|
|
336
|
-
sub_dir,
|
|
337
|
-
n_exposures,
|
|
338
|
-
chip_type,
|
|
339
|
-
map_type,
|
|
340
|
-
pump_repeat,
|
|
341
|
-
pumpexptime,
|
|
342
|
-
pumpdelay,
|
|
343
|
-
exptime,
|
|
344
|
-
dcdetdist,
|
|
345
|
-
prepumpexptime,
|
|
346
|
-
det_type,
|
|
347
|
-
) = scrape_parameter_file()
|
|
348
|
-
|
|
349
|
-
logger.debug("Set up beamline")
|
|
350
|
-
sup.beamline("collect")
|
|
351
|
-
sup.beamline("quickshot", [dcdetdist])
|
|
352
|
-
logger.debug("Set up beamline DONE")
|
|
353
|
-
|
|
354
|
-
total_numb_imgs = datasetsizei24()
|
|
355
|
-
|
|
356
|
-
filepath = visit + sub_dir
|
|
357
|
-
filename = chip_name
|
|
358
|
-
|
|
359
|
-
logger.debug("Acquire Region")
|
|
360
|
-
|
|
361
|
-
num_gates = int(total_numb_imgs) / int(n_exposures)
|
|
362
|
-
|
|
363
|
-
logger.info("Total number of images: %d" % total_numb_imgs)
|
|
364
|
-
logger.info("Number of exposures: %s" % n_exposures)
|
|
365
|
-
logger.info("Number of gates (=Total images/N exposures): %.4f" % num_gates)
|
|
366
|
-
|
|
367
|
-
if det_type == "pilatus":
|
|
368
|
-
logger.info("Using Pilatus detector")
|
|
369
|
-
logger.info("Fastchip Pilatus setup: filepath %s" % filepath)
|
|
370
|
-
logger.info("Fastchip Pilatus setup: filepath %s" % filename)
|
|
371
|
-
logger.info("Fastchip Pilatus setup: number of images %d" % total_numb_imgs)
|
|
372
|
-
logger.info("Fastchip Pilatus setup: exposure time %s" % exptime)
|
|
373
|
-
|
|
374
|
-
sup.pilatus("fastchip", [filepath, filename, total_numb_imgs, exptime])
|
|
375
|
-
|
|
376
|
-
# DCID process depends on detector PVs being set up already
|
|
377
|
-
logger.debug("Start DCID process")
|
|
378
|
-
dcid = DCID(
|
|
379
|
-
emit_errors=False,
|
|
380
|
-
ssx_type=SSXType.FIXED,
|
|
381
|
-
visit=Path(visit).name,
|
|
382
|
-
image_dir=filepath,
|
|
383
|
-
start_time=start_time,
|
|
384
|
-
num_images=total_numb_imgs,
|
|
385
|
-
exposure_time=exptime,
|
|
386
|
-
detector=det_type,
|
|
387
|
-
shots_per_position=int(n_exposures),
|
|
388
|
-
pump_exposure_time=float(pumpexptime),
|
|
389
|
-
pump_delay=float(pumpdelay),
|
|
390
|
-
pump_status=int(pump_repeat),
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
logger.debug("Arm Pilatus. Arm Zebra.")
|
|
394
|
-
sup.zebra1("fastchip-pilatus", [num_gates, n_exposures, exptime])
|
|
395
|
-
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
396
|
-
caput(pv.zebra1_pc_arm, "1") # Arm zebra fastchip-pilatus
|
|
397
|
-
caput(pv.pilat_filename, filename)
|
|
398
|
-
time.sleep(1.5)
|
|
399
|
-
|
|
400
|
-
elif det_type == "eiger":
|
|
401
|
-
logger.info("Using Eiger detector")
|
|
402
|
-
|
|
403
|
-
logger.warning(
|
|
404
|
-
"""TEMPORARY HACK!
|
|
405
|
-
Running a Single image pilatus data collection to create directory."""
|
|
406
|
-
)
|
|
407
|
-
num_imgs = 1
|
|
408
|
-
sup.pilatus("quickshot-internaltrig", [filepath, filename, num_imgs, exptime])
|
|
409
|
-
logger.debug("Sleep 2s waiting for pilatus to arm")
|
|
410
|
-
sleep(2)
|
|
411
|
-
sleep(0.5)
|
|
412
|
-
caput(pv.pilat_acquire, "0") # Disarm pilatus
|
|
413
|
-
sleep(0.5)
|
|
414
|
-
caput(pv.pilat_acquire, "1") # Arm pilatus
|
|
415
|
-
logger.debug("Pilatus data collection DONE")
|
|
416
|
-
sup.pilatus("return to normal")
|
|
417
|
-
logger.info("Pilatus back to normal. Single image pilatus data collection DONE")
|
|
418
|
-
|
|
419
|
-
logger.info("Triggered Eiger setup: filepath %s" % filepath)
|
|
420
|
-
logger.info("Triggered Eiger setup: filename %s" % filename)
|
|
421
|
-
logger.info("Triggered Eiger setup: number of images %d" % total_numb_imgs)
|
|
422
|
-
logger.info("Triggered Eiger setup: exposure time %s" % exptime)
|
|
423
|
-
|
|
424
|
-
sup.eiger("triggered", [filepath, filename, total_numb_imgs, exptime])
|
|
425
|
-
|
|
426
|
-
# DCID process depends on detector PVs being set up already
|
|
427
|
-
logger.debug("Start DCID process")
|
|
428
|
-
dcid = DCID(
|
|
429
|
-
emit_errors=False,
|
|
430
|
-
ssx_type=SSXType.FIXED,
|
|
431
|
-
visit=Path(visit).name,
|
|
432
|
-
image_dir=filepath,
|
|
433
|
-
start_time=start_time,
|
|
434
|
-
num_images=total_numb_imgs,
|
|
435
|
-
exposure_time=exptime,
|
|
436
|
-
detector=det_type,
|
|
437
|
-
)
|
|
438
|
-
|
|
439
|
-
logger.debug("Arm Zebra.")
|
|
440
|
-
sup.zebra1("fastchip-eiger", [num_gates, n_exposures, exptime])
|
|
441
|
-
caput(pv.zebra1_pc_arm, "1") # Arm zebra fastchip-eiger
|
|
442
|
-
|
|
443
|
-
time.sleep(1.5)
|
|
444
|
-
|
|
445
|
-
else:
|
|
446
|
-
msg = "Unknown Detector Type, det_type = %s" % det_type
|
|
447
|
-
logger.error(msg)
|
|
448
|
-
raise ValueError(msg)
|
|
449
|
-
|
|
450
|
-
# Open the hutch shutter
|
|
451
|
-
|
|
452
|
-
caput("BL24I-PS-SHTR-01:CON", "Reset")
|
|
453
|
-
logger.debug("Reset, then sleep for 1s")
|
|
454
|
-
sleep(1.0)
|
|
455
|
-
caput("BL24I-PS-SHTR-01:CON", "Open")
|
|
456
|
-
logger.debug(" Open, then sleep for 2s")
|
|
457
|
-
sleep(2.0)
|
|
458
|
-
|
|
459
|
-
return start_time.ctime(), dcid
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
@log.log_on_entry
|
|
463
|
-
def finish_i24(chip_prog_dict, start_time):
|
|
464
|
-
det_type = get_detector_type()
|
|
465
|
-
logger.info("Finish I24 data collection with %s detector." % det_type)
|
|
466
|
-
|
|
467
|
-
(
|
|
468
|
-
chip_name,
|
|
469
|
-
visit,
|
|
470
|
-
sub_dir,
|
|
471
|
-
n_exposures,
|
|
472
|
-
chip_type,
|
|
473
|
-
map_type,
|
|
474
|
-
pump_repeat,
|
|
475
|
-
pumpexptime,
|
|
476
|
-
pumpdelay,
|
|
477
|
-
exptime,
|
|
478
|
-
dcdetdist,
|
|
479
|
-
prepumpexptime,
|
|
480
|
-
det_type,
|
|
481
|
-
) = scrape_parameter_file()
|
|
482
|
-
|
|
483
|
-
total_numb_imgs = datasetsizei24()
|
|
484
|
-
filepath = visit + sub_dir
|
|
485
|
-
filename = chip_name
|
|
486
|
-
transmission = (float(caget(pv.pilat_filtertrasm)),)
|
|
487
|
-
wavelength = float(caget(pv.dcm_lambda))
|
|
488
|
-
|
|
489
|
-
if det_type == "pilatus":
|
|
490
|
-
logger.info("Finish I24 Pilatus")
|
|
491
|
-
filename = filename + "_" + caget(pv.pilat_filenum)
|
|
492
|
-
logger.debug("Close the fast shutter.")
|
|
493
|
-
caput(pv.zebra1_soft_in_b1, "No")
|
|
494
|
-
logger.debug("Disarm the zebra.")
|
|
495
|
-
caput(pv.zebra1_pc_arm_out, "0")
|
|
496
|
-
sup.zebra1("return-to-normal")
|
|
497
|
-
sup.pilatus("return-to-normal")
|
|
498
|
-
sleep(0.2)
|
|
499
|
-
elif det_type == "eiger":
|
|
500
|
-
logger.info("Finish I24 Eiger")
|
|
501
|
-
logger.debug("Close the fast shutter.")
|
|
502
|
-
caput(pv.zebra1_soft_in_b1, "No")
|
|
503
|
-
logger.debug("Disarm the zebra.")
|
|
504
|
-
caput(pv.zebra1_pc_arm_out, "0")
|
|
505
|
-
sup.zebra1("return-to-normal")
|
|
506
|
-
sup.eiger("return-to-normal")
|
|
507
|
-
filename = cagetstring(pv.eiger_ODfilenameRBV)
|
|
508
|
-
|
|
509
|
-
# Detector independent moves
|
|
510
|
-
logger.info("Move chip back to home position by setting PMAC_STRING pv.")
|
|
511
|
-
caput(pv.me14e_pmac_str, "!x0y0z0")
|
|
512
|
-
logger.debug("Closing shutter")
|
|
513
|
-
caput("BL24I-PS-SHTR-01:CON", "Close")
|
|
514
|
-
|
|
515
|
-
end_time = time.ctime()
|
|
516
|
-
logger.info("Collection end time %s" % end_time)
|
|
517
|
-
|
|
518
|
-
# Copy parameter file and eventual chip map to collection directory
|
|
519
|
-
copy_files_to_data_location(Path(visit + sub_dir), map_type=map_type)
|
|
520
|
-
|
|
521
|
-
# Write a record of what was collected to the processing directory
|
|
522
|
-
userlog_path = visit + "processing/" + sub_dir + "/"
|
|
523
|
-
userlog_fid = filename + "_parameters.txt"
|
|
524
|
-
logger.debug("Write a user log in %s" % userlog_path)
|
|
525
|
-
|
|
526
|
-
os.makedirs(userlog_path, exist_ok=True)
|
|
527
|
-
|
|
528
|
-
with open(userlog_path + userlog_fid, "w") as f:
|
|
529
|
-
f.write("Fixed Target Data Collection Parameters\n")
|
|
530
|
-
f.write("Data directory \t%s\n" % filepath)
|
|
531
|
-
f.write("Filename \t%s\n" % filename)
|
|
532
|
-
f.write("Shots per pos \t%s\n" % n_exposures)
|
|
533
|
-
f.write("Total N images \t%s\n" % total_numb_imgs)
|
|
534
|
-
f.write("Exposure time \t%s\n" % exptime)
|
|
535
|
-
f.write("Det distance \t%s\n" % dcdetdist)
|
|
536
|
-
f.write("Transmission \t%s\n" % transmission)
|
|
537
|
-
f.write("Wavelength \t%s\n" % wavelength)
|
|
538
|
-
f.write("Detector type \t%s\n" % det_type)
|
|
539
|
-
f.write("Pump status \t%s\n" % pump_repeat)
|
|
540
|
-
f.write("Pump exp time \t%s\n" % pumpexptime)
|
|
541
|
-
f.write("Pump delay \t%s\n" % pumpdelay)
|
|
542
|
-
|
|
543
|
-
sleep(0.5)
|
|
544
|
-
|
|
545
|
-
return end_time
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
def main():
|
|
549
|
-
# Dodal devices
|
|
550
|
-
pmac = i24.pmac()
|
|
551
|
-
# ABORT BUTTON
|
|
552
|
-
logger.info("Running a chip collection on I24")
|
|
553
|
-
caput(pv.me14e_gp9, 0)
|
|
554
|
-
|
|
555
|
-
logger.info("Getting parameters from file.")
|
|
556
|
-
(
|
|
557
|
-
chip_name,
|
|
558
|
-
visit,
|
|
559
|
-
sub_dir,
|
|
560
|
-
n_exposures,
|
|
561
|
-
chip_type,
|
|
562
|
-
map_type,
|
|
563
|
-
pump_repeat,
|
|
564
|
-
pumpexptime,
|
|
565
|
-
pumpdelay,
|
|
566
|
-
exptime,
|
|
567
|
-
dcdetdist,
|
|
568
|
-
prepumpexptime,
|
|
569
|
-
det_type,
|
|
570
|
-
) = scrape_parameter_file()
|
|
571
|
-
|
|
572
|
-
logger.info("Chip name is %s" % chip_name)
|
|
573
|
-
logger.info("visit = %s" % visit)
|
|
574
|
-
logger.info("sub_dir = %s" % sub_dir)
|
|
575
|
-
logger.info("n_exposures = %s" % n_exposures)
|
|
576
|
-
logger.info("chip_type = %s" % chip_type)
|
|
577
|
-
logger.info("map_type = %s" % map_type)
|
|
578
|
-
logger.info("dcdetdist = %s" % dcdetdist)
|
|
579
|
-
logger.info("exptime = %s" % exptime)
|
|
580
|
-
logger.info("pump_repeat = %s" % pump_repeat)
|
|
581
|
-
logger.info("pumpexptime = %s" % pumpexptime)
|
|
582
|
-
logger.info("pumpdelay = %s" % pumpdelay)
|
|
583
|
-
logger.info("prepumpexptime = %s" % prepumpexptime)
|
|
584
|
-
logger.info("Getting Program Dictionary")
|
|
585
|
-
|
|
586
|
-
# If alignment type is Oxford inner it is still an Oxford type chip
|
|
587
|
-
if chip_type == ChipType.OxfordInner:
|
|
588
|
-
logger.debug("Change chip type Oxford Inner to Oxford.")
|
|
589
|
-
chip_type = ChipType.Oxford
|
|
590
|
-
|
|
591
|
-
chip_prog_dict = get_chip_prog_values(
|
|
592
|
-
chip_type,
|
|
593
|
-
pump_repeat,
|
|
594
|
-
pumpexptime,
|
|
595
|
-
pumpdelay,
|
|
596
|
-
prepumpexptime,
|
|
597
|
-
exptime=exptime,
|
|
598
|
-
n_exposures=n_exposures,
|
|
599
|
-
)
|
|
600
|
-
logger.info("Loading Motion Program Data")
|
|
601
|
-
load_motion_program_data(pmac, chip_prog_dict, map_type, pump_repeat)
|
|
602
|
-
|
|
603
|
-
start_time, dcid = start_i24()
|
|
604
|
-
|
|
605
|
-
logger.info("Moving to Start")
|
|
606
|
-
caput(pv.me14e_pmac_str, "!x0y0z0")
|
|
607
|
-
sleep(2.0)
|
|
608
|
-
|
|
609
|
-
prog_num = get_prog_num(chip_type, map_type, pump_repeat)
|
|
610
|
-
|
|
611
|
-
# Now ready for data collection. Open fast shutter
|
|
612
|
-
logger.debug("Opening fast shutter.")
|
|
613
|
-
caput(pv.zebra1_soft_in_b1, "1") # Open fast shutter (zebra gate)
|
|
614
|
-
|
|
615
|
-
logger.info("Run PMAC with program number %d" % prog_num)
|
|
616
|
-
logger.info("pmac str = &2b%dr" % prog_num)
|
|
617
|
-
caput(pv.me14e_pmac_str, "&2b%dr" % prog_num)
|
|
618
|
-
sleep(1.0)
|
|
619
|
-
|
|
620
|
-
# Kick off the StartOfCollect script
|
|
621
|
-
logger.debug("Notify DCID of the start of the collection.")
|
|
622
|
-
dcid.notify_start()
|
|
623
|
-
|
|
624
|
-
param_file_tuple = scrape_parameter_file()
|
|
625
|
-
tot_num_imgs = datasetsizei24()
|
|
626
|
-
if det_type == "eiger":
|
|
627
|
-
logger.debug("Start nexus writing service.")
|
|
628
|
-
call_nexgen(
|
|
629
|
-
chip_prog_dict,
|
|
630
|
-
start_time,
|
|
631
|
-
param_file_tuple,
|
|
632
|
-
total_numb_imgs=tot_num_imgs,
|
|
633
|
-
)
|
|
634
|
-
|
|
635
|
-
logger.info("Data Collection running")
|
|
636
|
-
|
|
637
|
-
aborted = False
|
|
638
|
-
timeout_time = time.time() + tot_num_imgs * float(exptime) + 60
|
|
639
|
-
|
|
640
|
-
# me14e_gp9 is the ABORT button
|
|
641
|
-
if int(caget(pv.me14e_gp9)) == 0:
|
|
642
|
-
i = 0
|
|
643
|
-
text_list = ["|", "/", "-", "\\"]
|
|
644
|
-
while True:
|
|
645
|
-
line_of_text = "\r\t\t\t Waiting " + 30 * ("%s" % text_list[i % 4])
|
|
646
|
-
flush_print(line_of_text)
|
|
647
|
-
sleep(0.5)
|
|
648
|
-
i += 1
|
|
649
|
-
if int(caget(pv.me14e_gp9)) != 0:
|
|
650
|
-
aborted = True
|
|
651
|
-
logger.warning("Data Collection Aborted")
|
|
652
|
-
caput(pv.me14e_pmac_str, "A")
|
|
653
|
-
sleep(1.0)
|
|
654
|
-
caput(pv.me14e_pmac_str, "P2401=0")
|
|
655
|
-
break
|
|
656
|
-
elif int(caget(pv.me14e_scanstatus)) == 0:
|
|
657
|
-
# As soon as me14e_scanstatus is set to 0, exit.
|
|
658
|
-
# Epics checks the geobrick and updates this PV every s or so.
|
|
659
|
-
# Once the collection is done, it will be set to 0.
|
|
660
|
-
print(caget(pv.me14e_scanstatus))
|
|
661
|
-
logger.warning("Data Collection Finished")
|
|
662
|
-
break
|
|
663
|
-
elif time.time() >= timeout_time:
|
|
664
|
-
aborted = True
|
|
665
|
-
logger.warning(
|
|
666
|
-
"""
|
|
667
|
-
Something went wrong and data collection timed out. Aborting.
|
|
668
|
-
"""
|
|
669
|
-
)
|
|
670
|
-
caput(pv.me14e_pmac_str, "A")
|
|
671
|
-
sleep(1.0)
|
|
672
|
-
caput(pv.me14e_pmac_str, "P2401=0")
|
|
673
|
-
break
|
|
674
|
-
else:
|
|
675
|
-
aborted = True
|
|
676
|
-
logger.info("Data Collection ended due to GP 9 not equalling 0")
|
|
677
|
-
|
|
678
|
-
logger.debug("Closing fast shutter")
|
|
679
|
-
caput(pv.zebra1_soft_in_b1, "No") # Close the fast shutter
|
|
680
|
-
sleep(2.0)
|
|
681
|
-
|
|
682
|
-
if det_type == "pilatus":
|
|
683
|
-
logger.debug("Pilatus Acquire STOP")
|
|
684
|
-
sleep(0.5)
|
|
685
|
-
caput(pv.pilat_acquire, 0)
|
|
686
|
-
elif det_type == "eiger":
|
|
687
|
-
logger.debug("Eiger Acquire STOP")
|
|
688
|
-
sleep(0.5)
|
|
689
|
-
caput(pv.eiger_acquire, 0)
|
|
690
|
-
caput(pv.eiger_ODcapture, "Done")
|
|
691
|
-
|
|
692
|
-
end_time = finish_i24(chip_prog_dict, start_time)
|
|
693
|
-
dcid.collection_complete(end_time, aborted=aborted)
|
|
694
|
-
logger.debug("Notify DCID of end of collection.")
|
|
695
|
-
dcid.notify_end()
|
|
696
|
-
|
|
697
|
-
logger.info("Quick summary of settings")
|
|
698
|
-
logger.info("Chip name = %s sub_dir = %s" % (chip_name, sub_dir))
|
|
699
|
-
logger.info("Start Time = % s" % start_time)
|
|
700
|
-
logger.info("End Time = %s" % end_time)
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
if __name__ == "__main__":
|
|
704
|
-
setup_logging()
|
|
705
|
-
|
|
706
|
-
main()
|