backend

Implements all the reading and translation of facility specific data streams into a unified format that can be used by the analysis package.

class hummingbird.backend.Worker(config_file, port)[source]

Bases: object

Coordinates data reading, translation and analysis.

This is the main class of the backend of Hummingbird. It uses a light source dependent translator to read and translate the data into a common format. It then runs whatever analysis algorithms are specified in the user provided configuration file.

Args:

config_file (str): The configuration file to load.

conf = None
ctrlcevent(whatSignal, stack)[source]
event_loop()[source]

The event loop.

While state['running'] is True, it will get events from the translator and process them as fast as possible.

load_conf()[source]

Load or reload the configuration file.

raise_interruption(signum, stack)[source]
start()[source]

Start the event loop.

state = None
class hummingbird.backend.EventTranslator(event, source_translator)[source]

Bases: object

Provides the interface between the analysis code and the various translators.

The evt argument of onEvent(), which must be defined in every configuration file is actually an EventTranslator.

event_id()[source]

Returns an id which should be unique for each shot and increase monotonically

event_id2()[source]

Returns an alternative id

keys()[source]

Returns the translated keys available

native_keys()[source]

Returns the keys, with facility specific names, available

class hummingbird.backend.Record(name, data, unit=None, group=None)[source]

Bases: object

Generic storage class for a name/data pair extracted from an event

Accept both values and functions for data. In the latter case the first time data is accessed evaluate the function and return its result.

property data
hummingbird.backend.add_record(values, group, name, data, unit=None)[source]

Convenience function to add a new Record to an existing Records dictionary.

hummingbird.backend.lcls

Translates between LCLS events and Hummingbird ones

class hummingbird.backend.lcls.EPICSdict(epics)[source]

Bases: object

Provides a dict-like interface to EPICS parameters.

Translated all the parameters is too slow too slow. Instead parameters are only translated as they are needed, when they are accessed, using this class.

keys()[source]

Returns available EPICS names

len()[source]

Returns the length of the dictionary

class hummingbird.backend.lcls.LCLSTranslator(state)[source]

Bases: object

Translate between LCLS events and Hummingbird ones

event_id(evt)[source]

Returns an id which should be unique for each shot and increase monotonically

event_id2(evt)[source]

Returns the LCLS time, a 64-bit integer as an alterative ID

event_keys(evt)[source]

Returns the translated keys available

event_native_keys(evt)[source]

Returns the native keys available

init_detectors(state)[source]
next_event()[source]

Grabs the next event and returns the translated version

translate(evt, key)[source]

Returns a dict of Records that match a given humminbird key

translate_core(evt, key)[source]

Returns a dict of Records that matchs a core Hummingbird key.

Core keys include all except: parameters, any psana create key, any native key.

translate_object(evt, key)[source]
hummingbird.backend.lcls.add_cmdline_args()[source]

hummingbird.backend.euxfel

Online backend for reading EuXFEL events via the Karabo-bridge.

class hummingbird.backend.euxfel.EUxfelTrainTranslator(state)[source]

Bases: EUxfelTranslator

Translate between EUxfel train events and Hummingbird ones

event_id(evt)[source]

Returns the first id of a train.

next_event()[source]

Grabs the next train event returns the translated version.

train_id(evt)[source]

Returns the full stack of all event ids within a train.

class hummingbird.backend.euxfel.EUxfelTranslator(state)[source]

Bases: object

Translate between EUxfel events and Hummingbird ones

append_slow_data(buf, meta)[source]

Append slow data to train buffer

event_keys(evt)[source]

Returns the translated keys available

event_native_keys(evt)[source]

Returns the native keys available

next_train()[source]

Asks for next train until its age is within a given time window.

translate(evt, key)[source]

Returns a dict of Records that match a given hummingbird key

translate_core(evt, key)[source]

Returns a dict of Records that matchs a core Hummingbird key.

hummingbird.backend.euxfel.add_cmdline_args()[source]

hummingbird.backend.flash

Creates Hummingbird events for testing purposes

class hummingbird.backend.flash.FLASHTranslator(state)[source]

Bases: object

Creates Hummingbird events for testing purposes

event_id(evt)[source]

Returns an id which should be unique for each shot and increase monotonically

event_id2(_)[source]

Returns an alternative id, which is jsut a copy of the usual id here

event_keys(_)[source]

Returns the translated keys available

event_native_keys(evt)[source]

Returns the native keys available

file_filter(filename, runnr)[source]
get_bunch_time()[source]
get_dark()[source]
get_gmd(daq_index)[source]
get_wavelength(daq_index)[source]
new_file_check(force=False)[source]
next_event()[source]

Generates and returns the next event

translate(evt, key)[source]

Returns a dict of Records that match a given Humminbird key

hummingbird.backend.swissfel

class hummingbird.backend.swissfel.SwissFELTranslator(state)[source]

Bases: object

Translate between SwissFEL h5 files and Hummingbird events

event_id(evt)[source]

Returns an id which should be unique for each shot and increase monotonically

event_id2(_)[source]

Returns an alternative id, which is jsut a copy of the usual id here

event_keys(_)[source]

Returns the translated keys available

event_native_keys(evt)[source]

Returns the native keys available

new_file_check(force=False)[source]
next_event()[source]

Generates and returns the next event

translate(evt, key)[source]

Returns a dict of Records that match a given Humminbird key