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
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Startup utilities for chip
|
|
3
|
-
|
|
4
|
-
This version changed to python3 March2020 by RLO
|
|
5
|
-
"""
|
|
6
|
-
from __future__ import annotations
|
|
7
|
-
|
|
8
|
-
import logging
|
|
9
|
-
import os
|
|
10
|
-
import string
|
|
11
|
-
import time
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
from typing import Dict, List
|
|
14
|
-
|
|
15
|
-
import numpy as np
|
|
16
|
-
|
|
17
|
-
from mx_bluesky.I24.serial import log
|
|
18
|
-
from mx_bluesky.I24.serial.fixed_target.ft_utils import ChipType
|
|
19
|
-
from mx_bluesky.I24.serial.parameters.constants import (
|
|
20
|
-
HEADER_FILES_PATH,
|
|
21
|
-
PARAM_FILE_PATH_FT,
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
logger = logging.getLogger("I24ssx.chip_startup")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def setup_logging():
|
|
28
|
-
# Log should now change name daily.
|
|
29
|
-
logfile = time.strftime("i24fixedtarget_%d%B%y.log").lower()
|
|
30
|
-
log.config(logfile)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def scrape_parameter_file(param_path: Path | str = PARAM_FILE_PATH_FT):
|
|
34
|
-
if not isinstance(param_path, Path):
|
|
35
|
-
param_path = Path(param_path)
|
|
36
|
-
|
|
37
|
-
with open(param_path / "parameters.txt", "r") as filein:
|
|
38
|
-
f = filein.readlines()
|
|
39
|
-
for line in f:
|
|
40
|
-
entry = line.rstrip().split()
|
|
41
|
-
if "chip_name" in entry[0].lower():
|
|
42
|
-
chip_name = entry[1]
|
|
43
|
-
elif line.startswith("visit"):
|
|
44
|
-
visit = entry[1]
|
|
45
|
-
elif line.startswith("sub_dir"):
|
|
46
|
-
sub_dir = entry[1]
|
|
47
|
-
elif line.startswith("protein_name"):
|
|
48
|
-
sub_dir = entry[1]
|
|
49
|
-
elif "n_exposures" in entry[0].lower():
|
|
50
|
-
n_exposures = int(entry[1])
|
|
51
|
-
elif "chip_type" in entry[0].lower():
|
|
52
|
-
chip_type = int(entry[1])
|
|
53
|
-
elif "map_type" in entry[0].lower():
|
|
54
|
-
map_type = int(entry[1])
|
|
55
|
-
elif "pump_repeat" in entry[0].lower():
|
|
56
|
-
pump_repeat = int(entry[1])
|
|
57
|
-
|
|
58
|
-
for line in f:
|
|
59
|
-
entry = line.rstrip().split()
|
|
60
|
-
if "pumpexptime" == entry[0].lower().strip():
|
|
61
|
-
pumpexptime = float(entry[1])
|
|
62
|
-
if "exptime" in entry[0].lower():
|
|
63
|
-
exptime = float(entry[1])
|
|
64
|
-
if "dcdetdist" in entry[0].lower():
|
|
65
|
-
dcdetdist = float(entry[1])
|
|
66
|
-
if "prepumpexptime" in entry[0].lower():
|
|
67
|
-
prepumpexptime = float(entry[1])
|
|
68
|
-
if "pumpdelay" in entry[0].lower():
|
|
69
|
-
pumpdelay = float(entry[1])
|
|
70
|
-
if "det_type" in entry[0].lower():
|
|
71
|
-
det_type = entry[1]
|
|
72
|
-
return (
|
|
73
|
-
chip_name,
|
|
74
|
-
visit,
|
|
75
|
-
sub_dir,
|
|
76
|
-
n_exposures,
|
|
77
|
-
chip_type,
|
|
78
|
-
map_type,
|
|
79
|
-
pump_repeat,
|
|
80
|
-
pumpexptime,
|
|
81
|
-
pumpdelay,
|
|
82
|
-
exptime,
|
|
83
|
-
dcdetdist,
|
|
84
|
-
prepumpexptime,
|
|
85
|
-
det_type,
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def read_parameters(
|
|
90
|
-
param_path: Path | str = PARAM_FILE_PATH_FT, filename: str | None = None
|
|
91
|
-
) -> Dict[str, str]:
|
|
92
|
-
"""
|
|
93
|
-
Read the parameter file into a lookup dictionary.
|
|
94
|
-
|
|
95
|
-
Does the same thing as scrape_parameter_file except doesn't rely on you
|
|
96
|
-
getting the order of arguments right every time (or having to load every one
|
|
97
|
-
if you don't need them all).
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
filename: The file to read. If None, will load from default location.
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
A dictionary with a string entry for every key in the file.
|
|
104
|
-
"""
|
|
105
|
-
if not isinstance(param_path, Path):
|
|
106
|
-
param_path = Path(param_path)
|
|
107
|
-
if filename is None:
|
|
108
|
-
filename = "parameters.txt"
|
|
109
|
-
datafile = param_path / filename
|
|
110
|
-
data = datafile.read_text()
|
|
111
|
-
args = {}
|
|
112
|
-
for line in data.splitlines():
|
|
113
|
-
key, value = line.split(maxsplit=1)
|
|
114
|
-
args[key.lower()] = value
|
|
115
|
-
return args
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@log.log_on_entry
|
|
119
|
-
def fiducials(chip_type: int):
|
|
120
|
-
if chip_type in [ChipType.Oxford, ChipType.OxfordInner, ChipType.Minichip]:
|
|
121
|
-
fiducial_list: list = []
|
|
122
|
-
# No fiducial for custom
|
|
123
|
-
elif chip_type == ChipType.Custom:
|
|
124
|
-
logger.warning("No fiducials for custom chip")
|
|
125
|
-
else:
|
|
126
|
-
logger.warning("Unknown chip_type, %s, in fiducials" % chip_type)
|
|
127
|
-
return fiducial_list
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
@log.log_on_entry
|
|
131
|
-
def get_format(chip_type: int):
|
|
132
|
-
if chip_type == ChipType.Oxford:
|
|
133
|
-
w2w = 0.125
|
|
134
|
-
b2b_horz = 0.800
|
|
135
|
-
b2b_vert = 0.800
|
|
136
|
-
chip_format = [8, 8, 20, 20]
|
|
137
|
-
elif chip_type == ChipType.OxfordInner:
|
|
138
|
-
w2w = 0.600
|
|
139
|
-
b2b_horz = 0.0
|
|
140
|
-
b2b_vert = 0.0
|
|
141
|
-
chip_format = [1, 1, 25, 25]
|
|
142
|
-
elif chip_type == ChipType.Minichip:
|
|
143
|
-
w2w = 0.125
|
|
144
|
-
b2b_horz = 0
|
|
145
|
-
b2b_vert = 0
|
|
146
|
-
chip_format = [1, 1, 20, 20]
|
|
147
|
-
else:
|
|
148
|
-
msg = "Unknown chip_type, %s" % chip_type
|
|
149
|
-
logger.error(msg)
|
|
150
|
-
raise ValueError(msg)
|
|
151
|
-
cell_format = chip_format + [w2w, b2b_horz, b2b_vert]
|
|
152
|
-
logger.info("Cell format for chip type %s: %s" % (chip_type, cell_format))
|
|
153
|
-
return cell_format
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
def get_xy(addr: str, chip_type: int):
|
|
157
|
-
entry = addr.split("_")[-2:]
|
|
158
|
-
R, C = entry[0][0], entry[0][1]
|
|
159
|
-
r2, c2 = entry[1][0], entry[1][1]
|
|
160
|
-
blockR = string.ascii_uppercase.index(R)
|
|
161
|
-
blockC = int(C) - 1
|
|
162
|
-
lowercase_list = list(string.ascii_lowercase + string.ascii_uppercase + "0")
|
|
163
|
-
windowR = lowercase_list.index(r2)
|
|
164
|
-
windowC = lowercase_list.index(c2)
|
|
165
|
-
|
|
166
|
-
(
|
|
167
|
-
x_block_num,
|
|
168
|
-
y_block_num,
|
|
169
|
-
x_window_num,
|
|
170
|
-
y_window_num,
|
|
171
|
-
w2w,
|
|
172
|
-
b2b_horz,
|
|
173
|
-
b2b_vert,
|
|
174
|
-
) = get_format(chip_type)
|
|
175
|
-
|
|
176
|
-
x = (blockC * b2b_horz) + (blockC * (x_window_num - 1) * w2w) + (windowC * w2w)
|
|
177
|
-
y = (blockR * b2b_vert) + (blockR * (y_window_num - 1) * w2w) + (windowR * w2w)
|
|
178
|
-
return x, y
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def pathli(l_in=[], way="typewriter", reverse=False):
|
|
182
|
-
if reverse is True:
|
|
183
|
-
li = list(reversed(l_in))
|
|
184
|
-
else:
|
|
185
|
-
li = list(l_in)
|
|
186
|
-
long_list = []
|
|
187
|
-
if li:
|
|
188
|
-
if way == "typewriter":
|
|
189
|
-
for i in range(len(li) ** 2):
|
|
190
|
-
long_list.append(li[i % len(li)])
|
|
191
|
-
elif way == "snake":
|
|
192
|
-
lr = list(reversed(li))
|
|
193
|
-
for rep in range(len(li)):
|
|
194
|
-
if rep % 2 == 0:
|
|
195
|
-
long_list += li
|
|
196
|
-
else:
|
|
197
|
-
long_list += lr
|
|
198
|
-
elif way == "snake53":
|
|
199
|
-
lr = list(reversed(li))
|
|
200
|
-
for rep in range(53):
|
|
201
|
-
if rep % 2 == 0:
|
|
202
|
-
long_list += li
|
|
203
|
-
else:
|
|
204
|
-
long_list += lr
|
|
205
|
-
elif way == "expand":
|
|
206
|
-
for entry in li:
|
|
207
|
-
for rep in range(len(li)):
|
|
208
|
-
long_list.append(entry)
|
|
209
|
-
elif way == "expand28":
|
|
210
|
-
for entry in li:
|
|
211
|
-
for rep in range(28):
|
|
212
|
-
long_list.append(entry)
|
|
213
|
-
elif way == "expand25":
|
|
214
|
-
for entry in li:
|
|
215
|
-
for rep in range(25):
|
|
216
|
-
long_list.append(entry)
|
|
217
|
-
else:
|
|
218
|
-
logger.warning("No known path, way = %s" % way)
|
|
219
|
-
else:
|
|
220
|
-
logger.warning("No list written")
|
|
221
|
-
return long_list
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
def zippum(list_1_args, list_2_args):
|
|
225
|
-
list_1, type_1, reverse_1 = list_1_args
|
|
226
|
-
list_2, type_2, reverse_2 = list_2_args
|
|
227
|
-
A_path = pathli(list_1, type_1, reverse_1)
|
|
228
|
-
B_path = pathli(list_2, type_2, reverse_2)
|
|
229
|
-
zipped_list = []
|
|
230
|
-
for a, b in zip(A_path, B_path):
|
|
231
|
-
zipped_list.append(a + b)
|
|
232
|
-
return zipped_list
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
def get_alphanumeric(chip_type):
|
|
236
|
-
cell_format = get_format(chip_type)
|
|
237
|
-
blk_num = cell_format[0]
|
|
238
|
-
wnd_num = cell_format[2]
|
|
239
|
-
uppercase_list = list(string.ascii_uppercase)[:blk_num]
|
|
240
|
-
lowercase_list = list(string.ascii_lowercase + string.ascii_uppercase + "0")[
|
|
241
|
-
:wnd_num
|
|
242
|
-
]
|
|
243
|
-
number_list = [str(x) for x in range(1, blk_num + 1)]
|
|
244
|
-
|
|
245
|
-
block_list = zippum([uppercase_list, "expand", 0], [number_list, "typewriter", 0])
|
|
246
|
-
window_list = zippum(
|
|
247
|
-
[lowercase_list, "expand", 0], [lowercase_list, "typewriter", 0]
|
|
248
|
-
)
|
|
249
|
-
|
|
250
|
-
alphanumeric_list = []
|
|
251
|
-
for block in block_list:
|
|
252
|
-
for window in window_list:
|
|
253
|
-
alphanumeric_list.append(block + "_" + window)
|
|
254
|
-
logger.info("Length of alphanumeric list = %s" % len(alphanumeric_list))
|
|
255
|
-
return alphanumeric_list
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
@log.log_on_entry
|
|
259
|
-
def get_shot_order(chip_type):
|
|
260
|
-
cell_format = get_format(chip_type)
|
|
261
|
-
blk_num = cell_format[0]
|
|
262
|
-
wnd_num = cell_format[2]
|
|
263
|
-
uppercase_list = list(string.ascii_uppercase)[:blk_num]
|
|
264
|
-
number_list = [str(x) for x in range(1, blk_num + 1)]
|
|
265
|
-
lowercase_list = list(string.ascii_lowercase + string.ascii_uppercase + "0")[
|
|
266
|
-
:wnd_num
|
|
267
|
-
]
|
|
268
|
-
|
|
269
|
-
block_list = zippum([uppercase_list, "snake", 0], [number_list, "expand", 0])
|
|
270
|
-
window_dn = zippum([lowercase_list, "expand", 0], [lowercase_list, "snake", 0])
|
|
271
|
-
window_up = zippum([lowercase_list, "expand", 1], [lowercase_list, "snake", 0])
|
|
272
|
-
|
|
273
|
-
switch = 0
|
|
274
|
-
count = 0
|
|
275
|
-
collect_list = []
|
|
276
|
-
for block in block_list:
|
|
277
|
-
if switch == 0:
|
|
278
|
-
for window in window_dn:
|
|
279
|
-
collect_list.append(block + "_" + window)
|
|
280
|
-
count += 1
|
|
281
|
-
if count == blk_num:
|
|
282
|
-
count = 0
|
|
283
|
-
switch = 1
|
|
284
|
-
else:
|
|
285
|
-
for window in window_up:
|
|
286
|
-
collect_list.append(block + "_" + window)
|
|
287
|
-
count += 1
|
|
288
|
-
if count == blk_num:
|
|
289
|
-
count = 0
|
|
290
|
-
switch = 0
|
|
291
|
-
|
|
292
|
-
logger.info("Length of collect list = %s" % len(collect_list))
|
|
293
|
-
return collect_list
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
@log.log_on_entry
|
|
297
|
-
def write_file(
|
|
298
|
-
location: str = "i24",
|
|
299
|
-
suffix: str = ".addr",
|
|
300
|
-
order: str = "alphanumeric",
|
|
301
|
-
param_file_path: Path = PARAM_FILE_PATH_FT,
|
|
302
|
-
save_path: Path = HEADER_FILES_PATH,
|
|
303
|
-
):
|
|
304
|
-
if location == "i24":
|
|
305
|
-
(
|
|
306
|
-
chip_name,
|
|
307
|
-
visit,
|
|
308
|
-
sub_dir,
|
|
309
|
-
n_exposures,
|
|
310
|
-
chip_type,
|
|
311
|
-
map_type,
|
|
312
|
-
pump_repeat,
|
|
313
|
-
pumpexptime,
|
|
314
|
-
exptime,
|
|
315
|
-
dcdetdist,
|
|
316
|
-
prepumpexptime,
|
|
317
|
-
) = scrape_parameter_file(param_file_path)
|
|
318
|
-
else:
|
|
319
|
-
msg = "Unknown location, %s" % location
|
|
320
|
-
logger.error(msg)
|
|
321
|
-
raise ValueError(msg)
|
|
322
|
-
chip_file_path = save_path / f"chips/{sub_dir}/{chip_name}{suffix}"
|
|
323
|
-
|
|
324
|
-
fiducial_list = fiducials(chip_type)
|
|
325
|
-
if order == "alphanumeric":
|
|
326
|
-
addr_list = get_alphanumeric(chip_type)
|
|
327
|
-
|
|
328
|
-
elif order == "shot":
|
|
329
|
-
addr_list = get_shot_order(chip_type)
|
|
330
|
-
|
|
331
|
-
with open(chip_file_path, "a") as g:
|
|
332
|
-
for addr in addr_list:
|
|
333
|
-
xtal_name = "_".join([chip_name, addr])
|
|
334
|
-
(x, y) = get_xy(xtal_name, chip_type)
|
|
335
|
-
if addr in fiducial_list:
|
|
336
|
-
pres = "0"
|
|
337
|
-
else:
|
|
338
|
-
if "rand" in suffix:
|
|
339
|
-
pres = str(np.random.randint(2))
|
|
340
|
-
else:
|
|
341
|
-
pres = "-1"
|
|
342
|
-
line = "\t".join([xtal_name, str(x), str(y), "0.0", pres]) + "\n"
|
|
343
|
-
g.write(line)
|
|
344
|
-
|
|
345
|
-
logger.info("Write %s completed" % chip_file_path)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
@log.log_on_entry
|
|
349
|
-
def check_files(
|
|
350
|
-
location: str,
|
|
351
|
-
suffix_list: List[str],
|
|
352
|
-
param_file_path: Path | str = PARAM_FILE_PATH_FT,
|
|
353
|
-
save_path: Path = HEADER_FILES_PATH,
|
|
354
|
-
):
|
|
355
|
-
if location == "i24":
|
|
356
|
-
(
|
|
357
|
-
chip_name,
|
|
358
|
-
visit,
|
|
359
|
-
sub_dir,
|
|
360
|
-
n_exposures,
|
|
361
|
-
chip_type,
|
|
362
|
-
map_type,
|
|
363
|
-
exptime,
|
|
364
|
-
pump_repeat,
|
|
365
|
-
pumpdelay,
|
|
366
|
-
pumpexptime,
|
|
367
|
-
dcdetdist,
|
|
368
|
-
prepumpexptime,
|
|
369
|
-
det_type,
|
|
370
|
-
) = scrape_parameter_file(param_path=param_file_path)
|
|
371
|
-
else:
|
|
372
|
-
msg = "Unknown location, %s" % location
|
|
373
|
-
logger.error(msg)
|
|
374
|
-
raise ValueError(msg)
|
|
375
|
-
chip_file_path = save_path / f"chips/{sub_dir}/{chip_name}"
|
|
376
|
-
|
|
377
|
-
try:
|
|
378
|
-
os.stat(chip_file_path)
|
|
379
|
-
except Exception:
|
|
380
|
-
os.makedirs(chip_file_path)
|
|
381
|
-
for suffix in suffix_list:
|
|
382
|
-
full_fid = chip_file_path.with_suffix(suffix)
|
|
383
|
-
if full_fid.is_file():
|
|
384
|
-
time_str = time.strftime("%Y%m%d_%H%M%S_")
|
|
385
|
-
timestamp_fid = ( # noqa: F841
|
|
386
|
-
full_fid.parent / f"{time_str}_{chip_name}{full_fid.suffix}"
|
|
387
|
-
)
|
|
388
|
-
# FIXME hack / fix. Actually move the file
|
|
389
|
-
logger.info("File %s Already Exists" % full_fid)
|
|
390
|
-
logger.debug("Check files done")
|
|
391
|
-
return 1
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
@log.log_on_entry
|
|
395
|
-
def write_headers(
|
|
396
|
-
location: str,
|
|
397
|
-
suffix_list: List[str],
|
|
398
|
-
param_file_path: Path = PARAM_FILE_PATH_FT,
|
|
399
|
-
save_path: Path = HEADER_FILES_PATH,
|
|
400
|
-
):
|
|
401
|
-
if location == "i24":
|
|
402
|
-
(
|
|
403
|
-
chip_name,
|
|
404
|
-
visit,
|
|
405
|
-
sub_dir,
|
|
406
|
-
n_exposures,
|
|
407
|
-
chip_type,
|
|
408
|
-
map_type,
|
|
409
|
-
pump_repeat,
|
|
410
|
-
pumpexptime,
|
|
411
|
-
pumpdelay,
|
|
412
|
-
exptime,
|
|
413
|
-
dcdetdist,
|
|
414
|
-
prepumpexptime,
|
|
415
|
-
det_type,
|
|
416
|
-
) = scrape_parameter_file(param_path=PARAM_FILE_PATH_FT)
|
|
417
|
-
chip_file_path = save_path / f"chips/{sub_dir}/{chip_name}"
|
|
418
|
-
|
|
419
|
-
for suffix in suffix_list:
|
|
420
|
-
full_fid = chip_file_path.with_suffix(suffix)
|
|
421
|
-
with open(full_fid, "w") as g:
|
|
422
|
-
g.write(
|
|
423
|
-
"#23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n#\n"
|
|
424
|
-
)
|
|
425
|
-
g.write("#&i24\tchip_name = %s\n" % chip_name)
|
|
426
|
-
g.write("#&i24\tvisit = %s\n" % visit)
|
|
427
|
-
g.write("#&i24\tsub_dir = %s\n" % sub_dir)
|
|
428
|
-
g.write("#&i24\tn_exposures = %s\n" % n_exposures)
|
|
429
|
-
g.write("#&i24\tchip_type = %s\n" % chip_type)
|
|
430
|
-
g.write("#&i24\tmap_type = %s\n" % map_type)
|
|
431
|
-
g.write("#&i24\tpump_repeat = %s\n" % pump_repeat)
|
|
432
|
-
g.write("#&i24\tpumpexptime = %s\n" % pumpexptime)
|
|
433
|
-
g.write("#&i24\texptime = %s\n" % exptime)
|
|
434
|
-
g.write("#&i24\tdcdetdist = %s\n" % dcdetdist)
|
|
435
|
-
g.write("#&i24\tprepumpexptime = %s\n" % prepumpexptime)
|
|
436
|
-
g.write("#&i24\tdet_Type = %s\n" % det_type)
|
|
437
|
-
g.write("#\n")
|
|
438
|
-
g.write(
|
|
439
|
-
"#XtalAddr XCoord YCoord ZCoord Present Shot Spare04 Spare03 Spare02 Spare01\n"
|
|
440
|
-
)
|
|
441
|
-
else:
|
|
442
|
-
msg = "Unknown location, %s" % location
|
|
443
|
-
logger.error(msg)
|
|
444
|
-
raise ValueError(msg)
|
|
445
|
-
logger.debug("Write headers done")
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
def run():
|
|
449
|
-
logger.debug("Run Startup")
|
|
450
|
-
check_files("i24", [".addr", ".shot"])
|
|
451
|
-
logger.info("Checked Files")
|
|
452
|
-
write_headers("i24", [".addr", ".shot"])
|
|
453
|
-
logger.info("Written Headers")
|
|
454
|
-
logger.info("Writing to Files has been disabled. Headers Only")
|
|
455
|
-
# Makes a file with random crystal positions
|
|
456
|
-
check_files("i24", ["rando.spec"])
|
|
457
|
-
write_headers("i24", ["rando.spec"])
|
|
458
|
-
logger.debug("StartUp Done")
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if __name__ == "__main__":
|
|
462
|
-
setup_logging()
|
|
463
|
-
run()
|
mx_bluesky/I24/serial/log.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import functools
|
|
4
|
-
import logging
|
|
5
|
-
import logging.config
|
|
6
|
-
from os import environ
|
|
7
|
-
from pathlib import Path
|
|
8
|
-
from typing import Optional
|
|
9
|
-
|
|
10
|
-
# Logging set up
|
|
11
|
-
logging.getLogger("I24ssx").addHandler(logging.NullHandler())
|
|
12
|
-
|
|
13
|
-
logging_config = {
|
|
14
|
-
"version": 1,
|
|
15
|
-
"disable_existing_loggers": False,
|
|
16
|
-
"formatters": {
|
|
17
|
-
"default": {
|
|
18
|
-
"class": "logging.Formatter",
|
|
19
|
-
"format": "%(message)s",
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"handlers": {
|
|
23
|
-
"console": {
|
|
24
|
-
"level": "DEBUG",
|
|
25
|
-
"class": "logging.StreamHandler",
|
|
26
|
-
"formatter": "default",
|
|
27
|
-
"stream": "ext://sys.stdout",
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"loggers": {
|
|
31
|
-
"I24ssx": {
|
|
32
|
-
"handlers": ["console"],
|
|
33
|
-
"level": "DEBUG",
|
|
34
|
-
"propagate": True,
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
logging.config.dictConfig(logging_config)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _get_logging_file_path() -> Path:
|
|
43
|
-
"""Get the path to write the artemis log files to.
|
|
44
|
-
If on a beamline, this will be written to the according area depending on the
|
|
45
|
-
BEAMLINE envrionment variable. If no envrionment variable is found it will default
|
|
46
|
-
it to the tmp/dev directory.
|
|
47
|
-
Returns:
|
|
48
|
-
logging_path (Path): Path to the log file for the file handler to write to.
|
|
49
|
-
"""
|
|
50
|
-
beamline: Optional[str] = environ.get("BEAMLINE")
|
|
51
|
-
logging_path: Path
|
|
52
|
-
|
|
53
|
-
if beamline:
|
|
54
|
-
logging_path = Path("/dls_sw/" + beamline + "/logs/serial/")
|
|
55
|
-
else:
|
|
56
|
-
logging_path = Path("./tmp/logs/")
|
|
57
|
-
|
|
58
|
-
try:
|
|
59
|
-
Path(logging_path).mkdir(parents=True, exist_ok=True)
|
|
60
|
-
except OSError:
|
|
61
|
-
# Until https://github.com/DiamondLightSource/mx_bluesky/issues/45 is fixed
|
|
62
|
-
# Logs could also go to the current visit directory, but not always possible
|
|
63
|
-
# when testing
|
|
64
|
-
logging_path = Path("~/serial_logs/").expanduser().resolve()
|
|
65
|
-
Path(logging_path).mkdir(parents=True, exist_ok=True)
|
|
66
|
-
return logging_path
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def config(logfile: str | None = None, write_mode: str = "a", delayed: bool = False):
|
|
70
|
-
"""
|
|
71
|
-
Configure the logging.
|
|
72
|
-
|
|
73
|
-
Args:
|
|
74
|
-
logfile (str, optional): Filename for logfile. If passed, create a file handler\
|
|
75
|
-
for the logger to write to file the log output. Defaults to None.
|
|
76
|
-
write_mode (str, optional): String indicating writing mode for the output \
|
|
77
|
-
.log file. Defaults to "a".
|
|
78
|
-
"""
|
|
79
|
-
logger = logging.getLogger("I24ssx")
|
|
80
|
-
if logfile:
|
|
81
|
-
logs = _get_logging_file_path() / logfile
|
|
82
|
-
fileFormatter = logging.Formatter(
|
|
83
|
-
"%(asctime)s %(levelname)s: \t(%(name)s) %(message)s",
|
|
84
|
-
datefmt="%d-%m-%Y %I:%M:%S",
|
|
85
|
-
)
|
|
86
|
-
FH = logging.FileHandler(logs, mode=write_mode, encoding="utf-8", delay=delayed)
|
|
87
|
-
FH.setLevel(logging.DEBUG)
|
|
88
|
-
FH.setFormatter(fileFormatter)
|
|
89
|
-
logger.addHandler(FH)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def log_on_entry(func):
|
|
93
|
-
logger = logging.getLogger("I24ssx")
|
|
94
|
-
|
|
95
|
-
@functools.wraps(func)
|
|
96
|
-
def decorator(*args, **kwargs):
|
|
97
|
-
name = func.__name__
|
|
98
|
-
logger.debug("Running %s " % name)
|
|
99
|
-
return func(*args, **kwargs)
|
|
100
|
-
|
|
101
|
-
return decorator
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class SSXType(Enum):
|
|
6
|
-
FIXED = "Serial Fixed"
|
|
7
|
-
EXTRUDER = "Serial Jet"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
OAV_CONFIG_FILES = {
|
|
11
|
-
"zoom_params_file": "/dls_sw/i24/software/gda/config/xml/jCameraManZoomLevels.xml",
|
|
12
|
-
"oav_config_json": "/dls_sw/i24/software/daq_configuration/json/OAVCentring.json",
|
|
13
|
-
"display_config": "/dls_sw/i24/software/gda_versions/var/display.configuration",
|
|
14
|
-
}
|
|
15
|
-
OAV1_CAM = "http://bl24i-di-serv-01.diamond.ac.uk:8080/OAV1.mjpg.mjpg"
|
|
16
|
-
|
|
17
|
-
PARAM_FILE_PATH = Path("src/mx_bluesky/I24/serial/parameters").expanduser().resolve()
|
|
18
|
-
PARAM_FILE_PATH_FT = (
|
|
19
|
-
Path("src/mx_bluesky/I24/serial/parameters/fixed_target").expanduser().resolve()
|
|
20
|
-
)
|
|
21
|
-
LITEMAP_PATH = (
|
|
22
|
-
Path("src/mx_bluesky/I24/serial/parameters/fixed_target/litemaps")
|
|
23
|
-
.expanduser()
|
|
24
|
-
.resolve()
|
|
25
|
-
)
|
|
26
|
-
FULLMAP_PATH = (
|
|
27
|
-
Path("src/mx_bluesky/I24/serial/parameters/fixed_target/fullmaps")
|
|
28
|
-
.expanduser()
|
|
29
|
-
.resolve()
|
|
30
|
-
)
|
|
31
|
-
PVAR_FILE_PATH = (
|
|
32
|
-
Path("src/mx_bluesky/I24/serial/parameters/fixed_target/pvar_files")
|
|
33
|
-
.expanduser()
|
|
34
|
-
.resolve()
|
|
35
|
-
)
|
|
36
|
-
HEADER_FILES_PATH = Path("/dls_sw/i24/scripts/fastchips/").expanduser().resolve()
|
|
37
|
-
CS_FILES_PATH = (
|
|
38
|
-
Path("src/mx_bluesky/I24/serial/parameters/fixed_target/cs").expanduser().resolve()
|
|
39
|
-
)
|