fab.beamtime

Beamtime Management

This module provides utilities for managing beamtime information at the FLASH facility. It handles beamtime identification, path resolution, and integration with the fabtrack run tracking system when available.

The main Beamtime class provides access to beamtime metadata and run information, automatically detecting the beamtime number from the current working directory when running on the GPFS filesystem. Integration with fabtrack allows viewing and querying the run table for accessing DAQ run metadata.

Usage

The beamtime object is typically imported via fab.magic which automatically detects the current beamtime:

from fab.magic import config, beamtime

print(beamtime.id)        # Beamtime number
print(beamtime.basepath)  # Path to beamtime data
print(beamtime.fabtrack)  # Run tracker object (if fabtrack is available)
print(beamtime.runs)      # Run table as pandas DataFrame (if fabtrack is available)

Alternatively, you can create a beamtime object manually by specifying the beamtime number:

from fab.beamtime import Beamtime

bt = Beamtime(11020281)

Working with fabtrack

If fabtrack is installed and was used during the beamtime, the runs attribute provides a RunTracker instance that allows you to store, update, and query metadata for each DAQ run. This is useful for keeping track of experimental parameters, run status, and comments throughout your beamtime.

Viewing the run table

from fab.magic import beamtime

# Display interactive run table (in Jupyter)
beamtime

# Get run table as pandas DataFrame
df = beamtime.runs

# Search and filter runs interactively
beamtime.fabtrack.search()

Creating and updating run metadata

# Update metadata for an existing run
beamtime.fabtrack.update_run(run_id=2570, 
    aborted=False,
    comment='Good signal quality'
)

# Attach a figure to run metadata
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(data)
beamtime.fabtrack.set_figure(run_id=2570, fig=fig)

Metadata is automatically versioned - each update creates a new version while preserving the history. Metadata files are stored as YAML in /meta/fabtrack/ within your beamtime directory.

 1'''
 2## Beamtime Management
 3
 4This module provides utilities for managing beamtime information at the FLASH facility.
 5It handles beamtime identification, path resolution, and integration with the fabtrack
 6run tracking system when available.
 7
 8The main `Beamtime` class provides access to beamtime metadata and run information,
 9automatically detecting the beamtime number from the current working directory when
10running on the GPFS filesystem. Integration with fabtrack allows viewing and querying
11the run table for accessing DAQ run metadata.
12
13## Usage
14
15The beamtime object is typically imported via `fab.magic` which automatically detects
16the current beamtime:
17
18```python
19from fab.magic import config, beamtime
20
21print(beamtime.id)        # Beamtime number
22print(beamtime.basepath)  # Path to beamtime data
23print(beamtime.fabtrack)  # Run tracker object (if fabtrack is available)
24print(beamtime.runs)      # Run table as pandas DataFrame (if fabtrack is available)
25```
26
27Alternatively, you can create a beamtime object manually by specifying the beamtime number:
28
29```python
30from fab.beamtime import Beamtime
31
32bt = Beamtime(11020281)
33```
34
35## Working with fabtrack
36
37If fabtrack is installed and was used during the beamtime, the `runs` attribute provides a `RunTracker` 
38instance that allows you to store, update, and query metadata for each DAQ run. This is useful for 
39keeping track of experimental parameters, run status, and comments throughout your beamtime.
40
41### Viewing the run table
42
43```python
44from fab.magic import beamtime
45
46# Display interactive run table (in Jupyter)
47beamtime
48
49# Get run table as pandas DataFrame
50df = beamtime.runs
51
52# Search and filter runs interactively
53beamtime.fabtrack.search()
54```
55
56### Creating and updating run metadata
57
58```python
59# Update metadata for an existing run
60beamtime.fabtrack.update_run(run_id=2570, 
61    aborted=False,
62    comment='Good signal quality'
63)
64
65# Attach a figure to run metadata
66import matplotlib.pyplot as plt
67fig, ax = plt.subplots()
68ax.plot(data)
69beamtime.fabtrack.set_figure(run_id=2570, fig=fig)
70```
71
72Metadata is automatically versioned - each update creates a new version while preserving
73the history. Metadata files are stored as YAML in `/meta/fabtrack/` within your beamtime directory.
74'''
75
76from .beamtime import Beamtime, autodetect_beamtime, beamtime_basepath