Fee Calib
fee_calib
Attributes
phil_scope
module-attribute
phil_scope = parse("\ncalibration {\n exp = None\n .type = str\n .help = Experiment name\n run_start = None\n .type = int\n .help = First run number\n energy_start = None\n .type = float\n .help = Starting photon energy in eV\n energy_step = None\n .type = float\n .help = Energy step size between runs in eV\n n_runs = None\n .type = int\n .help = Number of runs to process\n detector = 'feespec'\n .type = str\n .help = Detector name\n events_per_run = 1000\n .type = int\n .help = Maximum events to process per run\n fit_window = 300\n .type = int\n .help = Points around maximum for Gaussian peak fit\n savgol_window = 51\n .type = int\n .help = Window size for Savitzky-Golay filter\n savgol_order = 3\n .type = int\n .help = Polynomial order for Savitzky-Golay filter\n plot = True\n .type = bool\n .help = Generate diagnostic plots\n post_to_elog = True\n .type = bool\n .help = Post the calibration plot to the eLog (requires Kerberos token via kinit) # noqa: E501\n}\n")
Functions
calibrate_energy_scale
Fit a linear energy calibration to a set of peak positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
peak_positions
|
array-like of float
|
Pixel positions of spectral peaks, one per calibration run. |
required |
energies
|
array-like of float
|
Known photon energies (eV) corresponding to each peak. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
slope |
float
|
eV per pixel (dispersion). |
intercept |
float
|
Energy at pixel 0 (eV). |
r_value |
float
|
Pearson correlation coefficient of the fit. |
Source code in scripts/cctbx/fee_calib.py
find_peak_position
Find the peak position in a spectrum using a Gaussian fit.
A Savitzky-Golay filter is applied first to locate an approximate peak, then a Gaussian is fitted within a window around that peak to obtain a sub-pixel position estimate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrum
|
ndarray
|
1-D intensity spectrum. |
required |
fit_window
|
int
|
Number of pixels around the rough peak to include in the fit. |
required |
sg_window
|
int
|
Window length for the Savitzky-Golay filter (must be odd). |
required |
poly_order
|
int
|
Polynomial order for the Savitzky-Golay filter. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
peak_pos |
float
|
Sub-pixel peak position (Gaussian mean, or smoothed argmax on fit failure). |
smoothed |
ndarray
|
Savitzky-Golay smoothed spectrum. |
fit_y |
ndarray or None
|
Gaussian fit evaluated over the fit window, or None if the fit failed. |
fit_range |
tuple of int
|
|
Source code in scripts/cctbx/fee_calib.py
gaussian
Evaluate a Gaussian function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Independent variable. |
required |
amplitude
|
float
|
Peak amplitude. |
required |
mean
|
float
|
Centre position. |
required |
sigma
|
float
|
Standard deviation. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Gaussian evaluated at each point in x. |
Source code in scripts/cctbx/fee_calib.py
post_to_elog
Post the calibration figure and results to the LCLS eLog.
Authentication is performed via Kerberos; a valid token must exist
before calling this function (obtain one with kinit).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exp
|
str
|
Experiment name (used to construct the eLog endpoint URL). |
required |
fig
|
Figure
|
Calibration figure to attach to the eLog entry. |
required |
ev_per_pixel
|
float
|
Calibrated dispersion in eV per pixel. |
required |
intercept
|
float
|
Energy at pixel 0 in eV. |
required |
r_value
|
float
|
Pearson correlation coefficient of the linear fit. |
required |
run_start
|
int
|
First run number included in the calibration. |
required |
n_runs
|
int
|
Total number of runs included in the calibration. |
required |
Source code in scripts/cctbx/fee_calib.py
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 | |
process_run
Process a single run and return the accumulated spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exp
|
str
|
Experiment name. |
required |
run_num
|
int
|
Run number to process. |
required |
detector_name
|
str
|
Name of the FEE spectrometer detector. |
required |
max_events
|
int
|
Maximum number of good events to accumulate. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
data |
ndarray or None
|
Accumulated horizontal projection spectrum, or None if no valid events were found. |
total_events |
int
|
Number of good events accumulated. |
Source code in scripts/cctbx/fee_calib.py
run
Run the FEE spectrometer energy calibration pipeline.
Processes a sequence of psana runs taken at known photon energies, finds the spectral peak in each run, performs a linear regression to determine the eV-per-pixel dispersion, and optionally plots the results and posts them to the eLog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
list of str
|
Command-line arguments in PHIL format, e.g.
|
required |
Source code in scripts/cctbx/fee_calib.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | |