137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337 | class FindPeaksPsocakeParameters(ThirdPartyParameters):
"""Parameters for crystallographic (Bragg) peak finding using Psocake.
This peak finding Task optionally has the ability to compress/decompress
data with SZ for the purpose of compression validation.
NOTE: This Task is deprecated and provided for compatibility only.
"""
class Config(TaskParameters.Config):
set_result: bool = True
"""Whether the Executor should mark a specified parameter as a result."""
result_from_params: str = ""
"""Defines a result from the parameters. Use a validator to do so."""
class SZParameters(BaseModel):
compressor: Literal["qoz", "sz3"] = Field(
"qoz", description="SZ compression algorithm (qoz, sz3)"
)
binSize: int = Field(2, description="SZ compression's bin size paramater")
roiWindowSize: int = Field(
2, description="SZ compression's ROI window size paramater"
)
absError: float = Field(10, descriptionp="Maximum absolute error value")
executable: str = Field("mpirun", description="MPI executable.", flag_type="")
np: PositiveInt = Field(
max(int(os.environ.get("SLURM_NPROCS", len(os.sched_getaffinity(0)))) - 1, 1),
description="Number of processes",
flag_type="-",
)
mca: str = Field(
"btl ^openib", description="Mca option for the MPI executable", flag_type="--"
)
p_arg1: str = Field(
"python", description="Executable to run with mpi (i.e. python).", flag_type=""
)
u: str = Field(
"", description="Python option for unbuffered output.", flag_type="-"
)
p_arg2: str = Field(
"findPeaksSZ.py",
description="Executable to run with mpi (i.e. python).",
flag_type="",
)
d: str = Field(description="Detector name", flag_type="-")
e: str = Field("", description="Experiment name", flag_type="-")
r: int = Field(-1, description="Run number", flag_type="-")
outDir: str = Field(
description="Output directory where .cxi will be saved", flag_type="--"
)
algorithm: int = Field(1, description="PyAlgos algorithm to use", flag_type="--")
alg_npix_min: float = Field(
1.0, description="PyAlgos algorithm's npix_min parameter", flag_type="--"
)
alg_npix_max: float = Field(
45.0, description="PyAlgos algorithm's npix_max parameter", flag_type="--"
)
alg_amax_thr: float = Field(
250.0, description="PyAlgos algorithm's amax_thr parameter", flag_type="--"
)
alg_atot_thr: float = Field(
330.0, description="PyAlgos algorithm's atot_thr parameter", flag_type="--"
)
alg_son_min: float = Field(
10.0, description="PyAlgos algorithm's son_min parameter", flag_type="--"
)
alg1_thr_low: float = Field(
80.0, description="PyAlgos algorithm's thr_low parameter", flag_type="--"
)
alg1_thr_high: float = Field(
270.0, description="PyAlgos algorithm's thr_high parameter", flag_type="--"
)
alg1_rank: int = Field(
3, description="PyAlgos algorithm's rank parameter", flag_type="--"
)
alg1_radius: int = Field(
3, description="PyAlgos algorithm's radius parameter", flag_type="--"
)
alg1_dr: int = Field(
1, description="PyAlgos algorithm's dr parameter", flag_type="--"
)
psanaMask_on: str = Field(
"True", description="Whether psana's mask should be used", flag_type="--"
)
psanaMask_calib: str = Field(
"True", description="Psana mask's calib parameter", flag_type="--"
)
psanaMask_status: str = Field(
"True", description="Psana mask's status parameter", flag_type="--"
)
psanaMask_edges: str = Field(
"True", description="Psana mask's edges parameter", flag_type="--"
)
psanaMask_central: str = Field(
"True", description="Psana mask's central parameter", flag_type="--"
)
psanaMask_unbond: str = Field(
"True", description="Psana mask's unbond parameter", flag_type="--"
)
psanaMask_unbondnrs: str = Field(
"True", description="Psana mask's unbondnbrs parameter", flag_type="--"
)
mask: str = Field(
"", description="Path to an additional mask to apply", flag_type="--"
)
clen: str = Field(
description="Epics variable storing the camera length", flag_type="--"
)
coffset: float = Field(0, description="Camera offset in m", flag_type="--")
minPeaks: int = Field(
15,
description="Minimum number of peaks to mark frame for indexing",
flag_type="--",
)
maxPeaks: int = Field(
15,
description="Maximum number of peaks to mark frame for indexing",
flag_type="--",
)
minRes: int = Field(
0,
description="Minimum peak resolution to mark frame for indexing ",
flag_type="--",
)
sample: str = Field("", description="Sample name", flag_type="--")
instrument: Union[None, str] = Field(
None, description="Instrument name", flag_type="--"
)
pixelSize: float = Field(0.0, description="Pixel size", flag_type="--")
auto: str = Field(
"False",
description=(
"Whether to automatically determine peak per event peak "
"finding parameters"
),
flag_type="--",
)
detectorDistance: float = Field(
0.0, description="Detector distance from interaction point in m", flag_type="--"
)
access: Literal["ana", "ffb"] = Field(
"ana", description="Data node type: {ana,ffb}", flag_type="--"
)
szfile: str = Field("qoz.json", description="Path to SZ's JSON configuration file")
lute_template_cfg: TemplateConfig = Field(
TemplateConfig(
template_name="sz.json",
output_path="", # Will want to change where this goes...
),
description="Template information for the sz.json file",
)
sz_parameters: SZParameters = Field(
description="Configuration parameters for SZ Compression", flag_type=""
)
@validator("e", always=True)
def validate_e(cls, e: str, values: Dict[str, Any]) -> str:
if e == "":
return values["lute_config"].experiment
return e
@validator("r", always=True)
def validate_r(cls, r: int, values: Dict[str, Any]) -> int:
if r == -1:
return values["lute_config"].run
return r
@validator("lute_template_cfg", always=True)
def set_output_path(
cls, lute_template_cfg: TemplateConfig, values: Dict[str, Any]
) -> TemplateConfig:
if lute_template_cfg.output_path == "":
lute_template_cfg.output_path = values["szfile"]
return lute_template_cfg
@validator("sz_parameters", always=True)
def set_sz_compression_parameters(
cls, sz_parameters: SZParameters, values: Dict[str, Any]
) -> None:
values["compressor"] = sz_parameters.compressor
values["binSize"] = sz_parameters.binSize
values["roiWindowSize"] = sz_parameters.roiWindowSize
if sz_parameters.compressor == "qoz":
values["pressio_opts"] = {
"pressio:abs": sz_parameters.absError,
"qoz": {"qoz:stride": 8},
}
else:
values["pressio_opts"] = {"pressio:abs": sz_parameters.absError}
return None
@root_validator(pre=False)
def define_result(cls, values: Dict[str, Any]) -> Dict[str, Any]:
exp: str = values["lute_config"].experiment
run: int = int(values["lute_config"].run)
directory: str = values["outDir"]
fname: str = f"{exp}_{run:04d}.lst"
cls.Config.result_from_params = f"{directory}/{fname}"
return values
|