Skip to content

Pulse patterns

extra.components.XrayPulses ¤

XrayPulses(data, source=None, sase=None)

Bases: TimeserverPulses

An interface to X-ray free electron laser pulses.

The pulse structure of each train at European XFEL is described by the bunch pattern table and accesssible in recorded data through the timeserver device or in decoded form through pulse pattern decoders.

This component aids in locating and reading the bunch pattern table, as well as providing utility methods to apply the pulse patterns to other recorded data. It only considers the X-ray laser pulses generated by one of the SASE beamlines and is thus a good choice for exclusive use of X-rays or pump-probe experiments with congruent optical laser pulses.

This class only deals with X-ray pulses of a particular SASE beamline. Please see OpticalLaserPulses to access pulses of the optical laser sources or PumpProbePulses to combine both into a single pattern.

Parameters:

Name Type Description Default
data DataCollection

Data to access bunch pattern data from.

required
source str

Source name of a timeserver or pulse pattern decoder, only needed if the data includes more than one such device or none could not be detected automatically.

None
sase int

SASE beamline to interpret pulses of, only needed if the data includes sources from more than one beamline or it could not be detected automatically.

None

master_clock property ¤

master_clock: float

European XFEL timing system master clock in Hz.

bunch_clock_divider property ¤

bunch_clock_divider: int

Divider to generate repetition rate from master clock.

bunch_repetition_rate property ¤

bunch_repetition_rate: float

European XFEL fundamental bunch repetition rate in Hz.

Generated from the master clock using a divider of 288, resulting in 4.5 MHz.

source property ¤

source: SourceData

Source used for pulse information.

timeserver property ¤

timeserver: SourceData

Used timeserver source.

pulse_pattern_decoder property ¤

pulse_pattern_decoder: SourceData

Used PulsePatternDecoder source.

bunch_pattern_table property ¤

bunch_pattern_table: KeyData

Used bunch pattern table key.

sase property ¤

sase: int

Used SASE beamline.

pulse_ids ¤

pulse_ids(labelled=True, copy=True)

Get pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
copy bool

Whether a copy is returned (default) or potentially a reference to an internal object. In the latter case, modifying the returned value will likely break other methods.

True

Returns:

Type Description
Series or ndarray

Pulse ID indexed by train ID and pulse index if labelled is True.

peek_pulse_ids ¤

peek_pulse_ids(labelled=True)

Get pulse IDs for the first train.

This method may be significantly faster than to pulse_ids() by only reading data for the very first train of data.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse ID in the first train of this data.

pulse_mask ¤

pulse_mask(labelled=True)

Get boolean pulse mask.

The returned mask has the same shape as the full bunch pattern table but only contains boolean flags whether a given pulse was present in this pattern.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled xarray DataArray (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
DataArray or ndarray

is_constant_pattern ¤

is_constant_pattern(*, include_empty_trains=False)

Whether pulse IDs are constant in this data.

Parameters:

Name Type Description Default
include_empty_trains bool

Whether trains without any pulses cause a pulse pattern to not be considered constant, False by default.

False

Returns:

Type Description
bool

Whether pulse IDs are identical in every train.

is_interleaved_with ¤

is_interleaved_with(other: PulsePattern) -> Optional[bool]

Check whether pulses are interleaved with other pattern.

This method returns True if and only if it can safely determine that the pulse pattern described by this component and the passed component are interleaved, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether pulses are interleaved or None if the pulse patterns do not allow the determination.

pulse_counts ¤

pulse_counts(labelled=True)

Get number of pulses per train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Number of pulses per train, indexed by train ID if labelled is True.

pulse_periods ¤

pulse_periods(
    labelled=True,
    single_pulse_value=None,
    no_pulse_value=None,
)

Get pulse periods per train.

The pulse period is expressed in units of the fundamental bunch repetition rate of 4.5 MHz. Its exact value can be accessed via PulsePattern.bunch_repetition_rate.

In each train, the smallest period between consecutive pulses is considered if the pulses do not have equal distances. For trains with a single pulse, the value can be specified or is filled by the largest value encountered across other trains with more pulses.

The resulting series is cast to integers unless it contains non-finite values as a result of fill values.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
single_pulse_value number

Fill value for trains with a single pulse. If omitted the largest period encountered in the data is used or an exception raised if there are no trains with more than one pulse.

None
no_pulse_value number

Fill value for trains without any pulse, 0 if omitted.

None

Returns:

Type Description
Series or ndarray

Pulse period per train train, indexed by train ID if labelled is True.

pulse_repetition_rates ¤

pulse_repetition_rates(labelled=True)

Get pulse repetition rate per train in Hz.

In each train, the highest repetition rate is used if the pulses do not have equal distances.

For trains with a single pulse, 0.0 is returned while trains without any pulse return NaN. If different fill values are desired, PulsePattern.bunch_repetition_rate can be divided manually by the result from PulsePattern.pulse_periods().

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse repetition rate per train, indexed by train ID if labelled is True.

train_durations ¤

train_durations(labelled=True)

Get durations of each train in seconds.

The duration is the time difference between the first and last pulse in each train. For trains with no pulses, NaN is returned.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Train duration in seconds per train, indexed by train ID if labelled is True.

build_pulse_index ¤

build_pulse_index(
    pulse_dim="pulseId", include_extra_dims=True
)

Get a multi-level index for pulse-resolved data.

Parameters:

Name Type Description Default
pulse_dim {pulseId, pulseIndex, time}

Label for pulse dimension, pulse ID by default.

'pulseId'
include_extra_dims bool

Whether to include any additional dimensions of this particular implementation beyond train ID and pulse dimension.

True

Returns:

Type Description
MultiIndex

Multi-level index covering train ID, pulse ID or pulse index and potentially any additonal extra index dimensions.

search_pulse_patterns ¤

search_pulse_patterns(labelled=True)

Search identical pulse patterns in this data.

Reads the bunch pattern table and gathers contiguous train regions of constant pulse pattern. It returns a list of train slices and corresponding pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
list of (slice, pandas.Series or ndarray) tuples

List of train regions identified by index slices with identical pulse IDs.

trains ¤

trains(labelled=True)

Iterate over pulse IDs by train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Yields:

Type Description
(int, Series or ndarray)

Train ID and pulse IDs.

machine_pulses ¤

machine_pulses(**kwargs) -> MachinePulses

Get MachinePulses component for the same data.

Any additional keyword arguments are passed to the MachinePulses initializer.

Returns:

Type Description
MachinePulses

(MachinePulses) Corresponding component using the same data as this component.

machine_repetition_rate cached ¤

machine_repetition_rate() -> float

Actual machine repetition rate.

is_sa1_interleaved_with_sa3 cached ¤

is_sa1_interleaved_with_sa3() -> Optional[bool]

Check whether SASE1 and SASE3 pulses are interleaved.

Due to their unique geometry, the pulses of the SASE1 and SASE3 beamlines can either occur after each other on the pulse train or be interleaved. Here, each beamline generally receives their first pulse directly after each other, with their relative pulse patterns following afterwards in a back-and-forth fashion.

This method returns True if and only if it can be safely determined the SA1 and SA3 pulses are intereavled, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether SA1 and SA3 are interleaved or None if the pulse patterns do not allow the determination.

extra.components.OpticalLaserPulses ¤

OpticalLaserPulses(data, source=None, ppl_seed=None)

Bases: TimeserverPulses

An interface to optical laser pulses.

The pump-probe lasers (LAS or PPL) are optical lasers commonly used in conjunction with X-ray pulses for pump-probe experiments. There are multiple laser sources called seeds distributed across the SASE beamlines and instruments with their pulse patterns also contained in the bunch pattern table.

However, an important difference to the FEL pulses is that only the number of pulses and their spacing can be inferred from the bunch pattern table. Optical laser pulses always starts at offset 0 for technical reasons, even if they temporally overlap with FEL pulses by means of optical delay.

For experiments where all FEL and PPL laser pulses overlap, it is recommended to just use the XrayPulses component. In the case of more complex or non-overlapping patterns, the PumpProbePulses allows to combine both into a single pulse pattern.

Parameters:

Name Type Description Default
data DataCollection

Data to access bunch pattern data from.

required
source str

Source name of a timeserver or pulse pattern decoder, only needed if the data includes more than one such device or none could not be detected automatically.

None
ppl_seed PPL_BITS or str

PPL seed to interpret pulses of, only needed if the data includes sources from more than one instrument or it could not be detected automatically. May either be an explicit seed value or an instrument as a string.

None

master_clock property ¤

master_clock: float

European XFEL timing system master clock in Hz.

bunch_clock_divider property ¤

bunch_clock_divider: int

Divider to generate repetition rate from master clock.

bunch_repetition_rate property ¤

bunch_repetition_rate: float

European XFEL fundamental bunch repetition rate in Hz.

Generated from the master clock using a divider of 288, resulting in 4.5 MHz.

source property ¤

source: SourceData

Source used for pulse information.

timeserver property ¤

timeserver: SourceData

Used timeserver source.

pulse_pattern_decoder property ¤

pulse_pattern_decoder: SourceData

Used PulsePatternDecoder source.

bunch_pattern_table property ¤

bunch_pattern_table: KeyData

Used bunch pattern table key.

ppl_seed property ¤

ppl_seed: Optional[PPL_BITS]

Used laser seed.

pulse_ids ¤

pulse_ids(labelled=True, copy=True)

Get pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
copy bool

Whether a copy is returned (default) or potentially a reference to an internal object. In the latter case, modifying the returned value will likely break other methods.

True

Returns:

Type Description
Series or ndarray

Pulse ID indexed by train ID and pulse index if labelled is True.

peek_pulse_ids ¤

peek_pulse_ids(labelled=True)

Get pulse IDs for the first train.

This method may be significantly faster than to pulse_ids() by only reading data for the very first train of data.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse ID in the first train of this data.

pulse_mask ¤

pulse_mask(labelled=True)

Get boolean pulse mask.

The returned mask has the same shape as the full bunch pattern table but only contains boolean flags whether a given pulse was present in this pattern.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled xarray DataArray (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
DataArray or ndarray

is_constant_pattern ¤

is_constant_pattern(*, include_empty_trains=False)

Whether pulse IDs are constant in this data.

Parameters:

Name Type Description Default
include_empty_trains bool

Whether trains without any pulses cause a pulse pattern to not be considered constant, False by default.

False

Returns:

Type Description
bool

Whether pulse IDs are identical in every train.

is_interleaved_with ¤

is_interleaved_with(other: PulsePattern) -> Optional[bool]

Check whether pulses are interleaved with other pattern.

This method returns True if and only if it can safely determine that the pulse pattern described by this component and the passed component are interleaved, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether pulses are interleaved or None if the pulse patterns do not allow the determination.

pulse_counts ¤

pulse_counts(labelled=True)

Get number of pulses per train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Number of pulses per train, indexed by train ID if labelled is True.

pulse_periods ¤

pulse_periods(
    labelled=True,
    single_pulse_value=None,
    no_pulse_value=None,
)

Get pulse periods per train.

The pulse period is expressed in units of the fundamental bunch repetition rate of 4.5 MHz. Its exact value can be accessed via PulsePattern.bunch_repetition_rate.

In each train, the smallest period between consecutive pulses is considered if the pulses do not have equal distances. For trains with a single pulse, the value can be specified or is filled by the largest value encountered across other trains with more pulses.

The resulting series is cast to integers unless it contains non-finite values as a result of fill values.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
single_pulse_value number

Fill value for trains with a single pulse. If omitted the largest period encountered in the data is used or an exception raised if there are no trains with more than one pulse.

None
no_pulse_value number

Fill value for trains without any pulse, 0 if omitted.

None

Returns:

Type Description
Series or ndarray

Pulse period per train train, indexed by train ID if labelled is True.

pulse_repetition_rates ¤

pulse_repetition_rates(labelled=True)

Get pulse repetition rate per train in Hz.

In each train, the highest repetition rate is used if the pulses do not have equal distances.

For trains with a single pulse, 0.0 is returned while trains without any pulse return NaN. If different fill values are desired, PulsePattern.bunch_repetition_rate can be divided manually by the result from PulsePattern.pulse_periods().

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse repetition rate per train, indexed by train ID if labelled is True.

train_durations ¤

train_durations(labelled=True)

Get durations of each train in seconds.

The duration is the time difference between the first and last pulse in each train. For trains with no pulses, NaN is returned.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Train duration in seconds per train, indexed by train ID if labelled is True.

build_pulse_index ¤

build_pulse_index(
    pulse_dim="pulseId", include_extra_dims=True
)

Get a multi-level index for pulse-resolved data.

Parameters:

Name Type Description Default
pulse_dim {pulseId, pulseIndex, time}

Label for pulse dimension, pulse ID by default.

'pulseId'
include_extra_dims bool

Whether to include any additional dimensions of this particular implementation beyond train ID and pulse dimension.

True

Returns:

Type Description
MultiIndex

Multi-level index covering train ID, pulse ID or pulse index and potentially any additonal extra index dimensions.

search_pulse_patterns ¤

search_pulse_patterns(labelled=True)

Search identical pulse patterns in this data.

Reads the bunch pattern table and gathers contiguous train regions of constant pulse pattern. It returns a list of train slices and corresponding pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
list of (slice, pandas.Series or ndarray) tuples

List of train regions identified by index slices with identical pulse IDs.

trains ¤

trains(labelled=True)

Iterate over pulse IDs by train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Yields:

Type Description
(int, Series or ndarray)

Train ID and pulse IDs.

machine_pulses ¤

machine_pulses(**kwargs) -> MachinePulses

Get MachinePulses component for the same data.

Any additional keyword arguments are passed to the MachinePulses initializer.

Returns:

Type Description
MachinePulses

(MachinePulses) Corresponding component using the same data as this component.

machine_repetition_rate cached ¤

machine_repetition_rate() -> float

Actual machine repetition rate.

is_sa1_interleaved_with_sa3 cached ¤

is_sa1_interleaved_with_sa3() -> Optional[bool]

Check whether SASE1 and SASE3 pulses are interleaved.

Due to their unique geometry, the pulses of the SASE1 and SASE3 beamlines can either occur after each other on the pulse train or be interleaved. Here, each beamline generally receives their first pulse directly after each other, with their relative pulse patterns following afterwards in a back-and-forth fashion.

This method returns True if and only if it can be safely determined the SA1 and SA3 pulses are intereavled, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether SA1 and SA3 are interleaved or None if the pulse patterns do not allow the determination.

extra.components.PumpProbePulses ¤

PumpProbePulses(
    data,
    source=None,
    instrument=None,
    *,
    bunch_table_position=None,
    bunch_table_offset=None,
    pulse_offset=None,
    extrapolate=True
)

Bases: XrayPulses, OpticalLaserPulses

An interface to combined FEL and PPL pulses.

This component offers support for arbitrary pulse relations between X-ray FEL and optical laser pulses (PPL) in pump-probe experiments. As the PPL pulse information in the bunch pattern table always starts at offset 0 for technical reasons irrespective of its actual temporal relation, it is corrected during initialization by exactly one of three methods:

1) Offset all PPL pulses to a fixed bunch table position. 2) Offset all PPL pulses relative to the first FEL pulse in units of the bunch pattern table. 3) Offset all PPL pulses relative to the first FEL pulse in units of FEL pulses.

In cases where there are no FEL pulses (for method 2) or too few (for method 3) to determine this offset, it may be extrapolated from a previous train if enabled. If extrapolation is disabled, an exception is raised.

Unlike XrayPulses and OpticalLaserPulses, this component adds additional levels to the pulse index indicated whether an FEL or PPL pulse is present in any particular position. It will only consider a pattern equal if it is equal for both FEL and PPL.

For experiments where all FEL and PPL laser pulses overlap, it is recommended to just use the XrayPulses component.

Parameters:

Name Type Description Default
data DataCollection

Data to access bunch pattern data from.

required
source str

Source name of a timeserver or pulse pattern decoder, only needed if the data includes more than one such device or none could not be detected automatically.

None
instrument src or tuple

Instrument to interpret FEL and PPL pulses of, only needed if the data includes sources from more than one instrument or it could not be detected automatically. May also be a tuple of (sase, ppl_seed) corresponding to arguments for XrayPulses and OpticalLaserPulses.

None
bunch_table_position int

Absolute bunch table position or pulse ID for the PPL pulse.

None
bunch_table_offset int

Offset to the first FEL pulse in bunch table positions or pulse IDs.

None
pulse_offset number

Offset to the first FEL pulse in units of the spacing between the first two FEL pulses, i.e. in units of FEL pulses.

None
extrapolate bool

Whether FEL pulse IDs may be extrapolated from past trains if missing, true by default. An exception is raised if disabled and the PPL anchoring method is missing the minimum number of required FEL pulses.

True

master_clock property ¤

master_clock: float

European XFEL timing system master clock in Hz.

bunch_clock_divider property ¤

bunch_clock_divider: int

Divider to generate repetition rate from master clock.

bunch_repetition_rate property ¤

bunch_repetition_rate: float

European XFEL fundamental bunch repetition rate in Hz.

Generated from the master clock using a divider of 288, resulting in 4.5 MHz.

source property ¤

source: SourceData

Source used for pulse information.

timeserver property ¤

timeserver: SourceData

Used timeserver source.

pulse_pattern_decoder property ¤

pulse_pattern_decoder: SourceData

Used PulsePatternDecoder source.

bunch_pattern_table property ¤

bunch_pattern_table: KeyData

Used bunch pattern table key.

ppl_seed property ¤

ppl_seed: Optional[PPL_BITS]

Used laser seed.

sase property ¤

sase: int

Used SASE beamline.

pulse_ids ¤

pulse_ids(labelled=True, copy=True)

Get pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
copy bool

Whether a copy is returned (default) or potentially a reference to an internal object. In the latter case, modifying the returned value will likely break other methods.

True

Returns:

Type Description
Series or ndarray

Pulse ID indexed by train ID and pulse index if labelled is True.

peek_pulse_ids ¤

peek_pulse_ids(labelled=True)

Get pulse IDs for the first train.

This method may be significantly faster than to pulse_ids() by only reading data for the very first train of data.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse ID in the first train of this data.

is_constant_pattern ¤

is_constant_pattern(*, include_empty_trains=False)

Whether pulse IDs are constant in this data.

Parameters:

Name Type Description Default
include_empty_trains bool

Whether trains without any pulses cause a pulse pattern to not be considered constant, False by default.

False

Returns:

Type Description
bool

Whether pulse IDs are identical in every train.

is_interleaved_with ¤

is_interleaved_with(other: PulsePattern) -> Optional[bool]

Check whether pulses are interleaved with other pattern.

This method returns True if and only if it can safely determine that the pulse pattern described by this component and the passed component are interleaved, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether pulses are interleaved or None if the pulse patterns do not allow the determination.

pulse_counts ¤

pulse_counts(labelled=True)

Get number of pulses per train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Number of pulses per train, indexed by train ID if labelled is True.

pulse_periods ¤

pulse_periods(
    labelled=True,
    single_pulse_value=None,
    no_pulse_value=None,
)

Get pulse periods per train.

The pulse period is expressed in units of the fundamental bunch repetition rate of 4.5 MHz. Its exact value can be accessed via PulsePattern.bunch_repetition_rate.

In each train, the smallest period between consecutive pulses is considered if the pulses do not have equal distances. For trains with a single pulse, the value can be specified or is filled by the largest value encountered across other trains with more pulses.

The resulting series is cast to integers unless it contains non-finite values as a result of fill values.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
single_pulse_value number

Fill value for trains with a single pulse. If omitted the largest period encountered in the data is used or an exception raised if there are no trains with more than one pulse.

None
no_pulse_value number

Fill value for trains without any pulse, 0 if omitted.

None

Returns:

Type Description
Series or ndarray

Pulse period per train train, indexed by train ID if labelled is True.

pulse_repetition_rates ¤

pulse_repetition_rates(labelled=True)

Get pulse repetition rate per train in Hz.

In each train, the highest repetition rate is used if the pulses do not have equal distances.

For trains with a single pulse, 0.0 is returned while trains without any pulse return NaN. If different fill values are desired, PulsePattern.bunch_repetition_rate can be divided manually by the result from PulsePattern.pulse_periods().

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse repetition rate per train, indexed by train ID if labelled is True.

train_durations ¤

train_durations(labelled=True)

Get durations of each train in seconds.

The duration is the time difference between the first and last pulse in each train. For trains with no pulses, NaN is returned.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Train duration in seconds per train, indexed by train ID if labelled is True.

build_pulse_index ¤

build_pulse_index(
    pulse_dim="pulseId", include_extra_dims=True
)

Get a multi-level index for pulse-resolved data.

Parameters:

Name Type Description Default
pulse_dim {pulseId, pulseIndex, time}

Label for pulse dimension, pulse ID by default.

'pulseId'
include_extra_dims bool

Whether to include any additional dimensions of this particular implementation beyond train ID and pulse dimension.

True

Returns:

Type Description
MultiIndex

Multi-level index covering train ID, pulse ID or pulse index and potentially any additonal extra index dimensions.

search_pulse_patterns ¤

search_pulse_patterns(labelled=True)

Search identical pulse patterns in this data.

Reads the bunch pattern table and gathers contiguous train regions of constant pulse pattern. It returns a list of train slices and corresponding pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
list of (slice, pandas.Series or ndarray) tuples

List of train regions identified by index slices with identical pulse IDs.

trains ¤

trains(labelled=True)

Iterate over pulse IDs by train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Yields:

Type Description
(int, Series or ndarray)

Train ID and pulse IDs.

machine_pulses ¤

machine_pulses(**kwargs) -> MachinePulses

Get MachinePulses component for the same data.

Any additional keyword arguments are passed to the MachinePulses initializer.

Returns:

Type Description
MachinePulses

(MachinePulses) Corresponding component using the same data as this component.

machine_repetition_rate cached ¤

machine_repetition_rate() -> float

Actual machine repetition rate.

is_sa1_interleaved_with_sa3 cached ¤

is_sa1_interleaved_with_sa3() -> Optional[bool]

Check whether SASE1 and SASE3 pulses are interleaved.

Due to their unique geometry, the pulses of the SASE1 and SASE3 beamlines can either occur after each other on the pulse train or be interleaved. Here, each beamline generally receives their first pulse directly after each other, with their relative pulse patterns following afterwards in a back-and-forth fashion.

This method returns True if and only if it can be safely determined the SA1 and SA3 pulses are intereavled, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether SA1 and SA3 are interleaved or None if the pulse patterns do not allow the determination.

pulse_mask ¤

pulse_mask(labelled=True, field=None)

Get boolean pulse mask.

The returned mask has the same shape as the full bunch pattern table but only contains boolean flags whether a given pulse was present in this pattern.

For instance, to see whether each FEL pulse has a corresponding pump laser pulse in a consistent pulse pattern:

ppl_on = ppp.select_trains(0).pulse_mask(field='ppl').squeeze()
fel_on = ppp.select_trains(0).pulse_mask(field='fel').squeeze()

fel_pulse_is_pumped = ppl_on[fel_on]

Parameters:

Name Type Description Default
labelled bool

Whether a labelled xarray DataArray (default) or unlabelled numpy array is returned.

True
field str

'fel'/'ppl' to mark only FEL or only pump laser pulses in the returned array. By default, pulses are True whether either an FEL pulse or a PPL pulse occured.

None

Returns:

Type Description
DataArray or ndarray

extra.components.MachinePulses ¤

MachinePulses(
    data,
    source=None,
    mask=_all_dumps,
    require_all_bits=False,
)

Bases: TimeserverPulses

An interface to machine pulses and other bunch pattern data.

The bunch pattern table contains much more information than just the pulses of each SASE beamline or the optical laser systems, in particular about the upstream electron systems.

This component is configurable to extract any information from the bunch pattern table beyond the X-ray or optical laser pulses. By default, it considers all generated electron bunches by combining the various electron dumps along the accelerator. Please consult the XFEL Timing System Specification for the various mask bits used.

Note that the full range of bunch pattern table information is only available when used with timeserver data. The pulse pattern decoder data only contains information about those pulses in the main dump and SASE dumps.

Parameters:

Name Type Description Default
data DataCollection

Data to access bunch pattern data from.

required
source str

Source name of a timeserver or pulse pattern decoder, only needed if the data includes more than one such device or none could not be detected automatically.

None
mask int

Custom mask into the bunch pattern table, by default all electron dumps are used. When initialized with ppdecoder data, only the main and SASE dumps are supported.

_all_dumps
require_all_bits bool

Whether to consider entries having any or all of the bits specified by mask, False by default. Only supported when initialized with timeserver data.

False

master_clock property ¤

master_clock: float

European XFEL timing system master clock in Hz.

bunch_clock_divider property ¤

bunch_clock_divider: int

Divider to generate repetition rate from master clock.

bunch_repetition_rate property ¤

bunch_repetition_rate: float

European XFEL fundamental bunch repetition rate in Hz.

Generated from the master clock using a divider of 288, resulting in 4.5 MHz.

source property ¤

source: SourceData

Source used for pulse information.

timeserver property ¤

timeserver: SourceData

Used timeserver source.

pulse_pattern_decoder property ¤

pulse_pattern_decoder: SourceData

Used PulsePatternDecoder source.

bunch_pattern_table property ¤

bunch_pattern_table: KeyData

Used bunch pattern table key.

pulse_ids ¤

pulse_ids(labelled=True, copy=True)

Get pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
copy bool

Whether a copy is returned (default) or potentially a reference to an internal object. In the latter case, modifying the returned value will likely break other methods.

True

Returns:

Type Description
Series or ndarray

Pulse ID indexed by train ID and pulse index if labelled is True.

peek_pulse_ids ¤

peek_pulse_ids(labelled=True)

Get pulse IDs for the first train.

This method may be significantly faster than to pulse_ids() by only reading data for the very first train of data.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse ID in the first train of this data.

pulse_mask ¤

pulse_mask(labelled=True)

Get boolean pulse mask.

The returned mask has the same shape as the full bunch pattern table but only contains boolean flags whether a given pulse was present in this pattern.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled xarray DataArray (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
DataArray or ndarray

is_constant_pattern ¤

is_constant_pattern(*, include_empty_trains=False)

Whether pulse IDs are constant in this data.

Parameters:

Name Type Description Default
include_empty_trains bool

Whether trains without any pulses cause a pulse pattern to not be considered constant, False by default.

False

Returns:

Type Description
bool

Whether pulse IDs are identical in every train.

is_interleaved_with ¤

is_interleaved_with(other: PulsePattern) -> Optional[bool]

Check whether pulses are interleaved with other pattern.

This method returns True if and only if it can safely determine that the pulse pattern described by this component and the passed component are interleaved, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether pulses are interleaved or None if the pulse patterns do not allow the determination.

pulse_counts ¤

pulse_counts(labelled=True)

Get number of pulses per train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Number of pulses per train, indexed by train ID if labelled is True.

pulse_periods ¤

pulse_periods(
    labelled=True,
    single_pulse_value=None,
    no_pulse_value=None,
)

Get pulse periods per train.

The pulse period is expressed in units of the fundamental bunch repetition rate of 4.5 MHz. Its exact value can be accessed via PulsePattern.bunch_repetition_rate.

In each train, the smallest period between consecutive pulses is considered if the pulses do not have equal distances. For trains with a single pulse, the value can be specified or is filled by the largest value encountered across other trains with more pulses.

The resulting series is cast to integers unless it contains non-finite values as a result of fill values.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
single_pulse_value number

Fill value for trains with a single pulse. If omitted the largest period encountered in the data is used or an exception raised if there are no trains with more than one pulse.

None
no_pulse_value number

Fill value for trains without any pulse, 0 if omitted.

None

Returns:

Type Description
Series or ndarray

Pulse period per train train, indexed by train ID if labelled is True.

pulse_repetition_rates ¤

pulse_repetition_rates(labelled=True)

Get pulse repetition rate per train in Hz.

In each train, the highest repetition rate is used if the pulses do not have equal distances.

For trains with a single pulse, 0.0 is returned while trains without any pulse return NaN. If different fill values are desired, PulsePattern.bunch_repetition_rate can be divided manually by the result from PulsePattern.pulse_periods().

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse repetition rate per train, indexed by train ID if labelled is True.

train_durations ¤

train_durations(labelled=True)

Get durations of each train in seconds.

The duration is the time difference between the first and last pulse in each train. For trains with no pulses, NaN is returned.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Train duration in seconds per train, indexed by train ID if labelled is True.

build_pulse_index ¤

build_pulse_index(
    pulse_dim="pulseId", include_extra_dims=True
)

Get a multi-level index for pulse-resolved data.

Parameters:

Name Type Description Default
pulse_dim {pulseId, pulseIndex, time}

Label for pulse dimension, pulse ID by default.

'pulseId'
include_extra_dims bool

Whether to include any additional dimensions of this particular implementation beyond train ID and pulse dimension.

True

Returns:

Type Description
MultiIndex

Multi-level index covering train ID, pulse ID or pulse index and potentially any additonal extra index dimensions.

search_pulse_patterns ¤

search_pulse_patterns(labelled=True)

Search identical pulse patterns in this data.

Reads the bunch pattern table and gathers contiguous train regions of constant pulse pattern. It returns a list of train slices and corresponding pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
list of (slice, pandas.Series or ndarray) tuples

List of train regions identified by index slices with identical pulse IDs.

trains ¤

trains(labelled=True)

Iterate over pulse IDs by train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Yields:

Type Description
(int, Series or ndarray)

Train ID and pulse IDs.

machine_pulses ¤

machine_pulses(**kwargs) -> MachinePulses

Get MachinePulses component for the same data.

Any additional keyword arguments are passed to the MachinePulses initializer.

Returns:

Type Description
MachinePulses

(MachinePulses) Corresponding component using the same data as this component.

machine_repetition_rate cached ¤

machine_repetition_rate() -> float

Actual machine repetition rate.

is_sa1_interleaved_with_sa3 cached ¤

is_sa1_interleaved_with_sa3() -> Optional[bool]

Check whether SASE1 and SASE3 pulses are interleaved.

Due to their unique geometry, the pulses of the SASE1 and SASE3 beamlines can either occur after each other on the pulse train or be interleaved. Here, each beamline generally receives their first pulse directly after each other, with their relative pulse patterns following afterwards in a back-and-forth fashion.

This method returns True if and only if it can be safely determined the SA1 and SA3 pulses are intereavled, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether SA1 and SA3 are interleaved or None if the pulse patterns do not allow the determination.

extra.components.DldPulses ¤

DldPulses(
    detector,
    *,
    clock_ratio=None,
    first_pulse_id=None,
    negative_ppl_indices=False
)

Bases: PulsePattern

An interface to pulses from DLD reconstruction.

The facility-provided event reconstruction for delay line detectors records its own pulse pattern information as part of its output in the raw.triggers key. This class exposes the same pulse pattern interface based on this information, and is primarily meant to be used alongside such data. Note that it is influenced by parameters set at the time of reconstruction, and hence may (incorrectly!) differ from timeserver data.

For data processed before October 2022, this data may not contain flags for FEL/PPL pulses and may also be based on analog trigger signals. It is also lacking the true pulse IDs, which are in this case estimated by this component based on trigger positions.

Parameters:

Name Type Description Default
detector SourceData

Instrument source of reconstructed event data to retrieve trigger information from.

required
clock_ratio int

Ratio between bunch repetition rate and digitizer sampling rate, only used in case of missing pulse ID information in data and 196 by default (non-interleaved ADQ412-3G).

None
first_pulse_id int

Pulse ID for the first pulse, only used in case of missing pulse ID information in data and 0 by default.

None
negative_ppl_indices bool

Whether to enumerate PPL-only pulses with negative indices (while keeping non-negative indices for FEL-only or pumped pulses) or interleave all pulses with positive indices (default).

False

master_clock property ¤

master_clock: float

European XFEL timing system master clock in Hz.

bunch_clock_divider property ¤

bunch_clock_divider: int

Divider to generate repetition rate from master clock.

bunch_repetition_rate property ¤

bunch_repetition_rate: float

European XFEL fundamental bunch repetition rate in Hz.

Generated from the master clock using a divider of 288, resulting in 4.5 MHz.

source property ¤

source: SourceData

Source used for pulse information.

pulse_ids ¤

pulse_ids(labelled=True, copy=True)

Get pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
copy bool

Whether a copy is returned (default) or potentially a reference to an internal object. In the latter case, modifying the returned value will likely break other methods.

True

Returns:

Type Description
Series or ndarray

Pulse ID indexed by train ID and pulse index if labelled is True.

peek_pulse_ids ¤

peek_pulse_ids(labelled=True)

Get pulse IDs for the first train.

This method may be significantly faster than to pulse_ids() by only reading data for the very first train of data.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse ID in the first train of this data.

pulse_mask ¤

pulse_mask(labelled=True)

Get boolean pulse mask.

The returned mask has the same shape as the full bunch pattern table but only contains boolean flags whether a given pulse was present in this pattern.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled xarray DataArray (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
DataArray or ndarray

is_constant_pattern ¤

is_constant_pattern(*, include_empty_trains=False)

Whether pulse IDs are constant in this data.

Parameters:

Name Type Description Default
include_empty_trains bool

Whether trains without any pulses cause a pulse pattern to not be considered constant, False by default.

False

Returns:

Type Description
bool

Whether pulse IDs are identical in every train.

is_interleaved_with ¤

is_interleaved_with(other: PulsePattern) -> Optional[bool]

Check whether pulses are interleaved with other pattern.

This method returns True if and only if it can safely determine that the pulse pattern described by this component and the passed component are interleaved, and False if and only if it is clear they are not interleaved. In all other cases, the pulses may or may not be interleaved and None is returned.

Returns:

Type Description
Optional[bool]

(bool or None) Whether pulses are interleaved or None if the pulse patterns do not allow the determination.

pulse_counts ¤

pulse_counts(labelled=True)

Get number of pulses per train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Number of pulses per train, indexed by train ID if labelled is True.

pulse_periods ¤

pulse_periods(
    labelled=True,
    single_pulse_value=None,
    no_pulse_value=None,
)

Get pulse periods per train.

The pulse period is expressed in units of the fundamental bunch repetition rate of 4.5 MHz. Its exact value can be accessed via PulsePattern.bunch_repetition_rate.

In each train, the smallest period between consecutive pulses is considered if the pulses do not have equal distances. For trains with a single pulse, the value can be specified or is filled by the largest value encountered across other trains with more pulses.

The resulting series is cast to integers unless it contains non-finite values as a result of fill values.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True
single_pulse_value number

Fill value for trains with a single pulse. If omitted the largest period encountered in the data is used or an exception raised if there are no trains with more than one pulse.

None
no_pulse_value number

Fill value for trains without any pulse, 0 if omitted.

None

Returns:

Type Description
Series or ndarray

Pulse period per train train, indexed by train ID if labelled is True.

pulse_repetition_rates ¤

pulse_repetition_rates(labelled=True)

Get pulse repetition rate per train in Hz.

In each train, the highest repetition rate is used if the pulses do not have equal distances.

For trains with a single pulse, 0.0 is returned while trains without any pulse return NaN. If different fill values are desired, PulsePattern.bunch_repetition_rate can be divided manually by the result from PulsePattern.pulse_periods().

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Pulse repetition rate per train, indexed by train ID if labelled is True.

train_durations ¤

train_durations(labelled=True)

Get durations of each train in seconds.

The duration is the time difference between the first and last pulse in each train. For trains with no pulses, NaN is returned.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
Series or ndarray

Train duration in seconds per train, indexed by train ID if labelled is True.

build_pulse_index ¤

build_pulse_index(
    pulse_dim="pulseId", include_extra_dims=True
)

Get a multi-level index for pulse-resolved data.

Parameters:

Name Type Description Default
pulse_dim {pulseId, pulseIndex, time}

Label for pulse dimension, pulse ID by default.

'pulseId'
include_extra_dims bool

Whether to include any additional dimensions of this particular implementation beyond train ID and pulse dimension.

True

Returns:

Type Description
MultiIndex

Multi-level index covering train ID, pulse ID or pulse index and potentially any additonal extra index dimensions.

search_pulse_patterns ¤

search_pulse_patterns(labelled=True)

Search identical pulse patterns in this data.

Reads the bunch pattern table and gathers contiguous train regions of constant pulse pattern. It returns a list of train slices and corresponding pulse IDs.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Returns:

Type Description
list of (slice, pandas.Series or ndarray) tuples

List of train regions identified by index slices with identical pulse IDs.

trains ¤

trains(labelled=True)

Iterate over pulse IDs by train.

Parameters:

Name Type Description Default
labelled bool

Whether a labelled pandas Series (default) or unlabelled numpy array is returned.

True

Yields:

Type Description
(int, Series or ndarray)

Train ID and pulse IDs.

triggers ¤

triggers(labelled=True)

Get trigger information.

Returns:

Type Description
Series or ndarray

Trigger fields start, stop, offset