API reference¶
Data Broker¶
Quick Reference¶
| Header(name, *args, **kwargs) | A dictionary-like object summarizing metadata for a run. |
| get_events(headers[, fields, fill]) | Get Events from given run(s). |
| get_table(headers[, fields, fill, convert_times]) | Make a table (pandas.DataFrame) from given run(s). |
| get_images(headers, name) | Load images from a detector for given Header(s). |
| DataBroker.__call__(**kwargs) | Given search criteria, find Headers describing runs. |
| DataBroker.__getitem__(key) | DWIM slicing |
Searching by ID or Recency¶
Here is a summary of the “Do What I Mean” slicing supported by DataBroker.
| syntax | meaning |
|---|---|
| DataBroker[-1] | most recent header |
| DataBroker[-5] | fifth most recent header |
| DataBroker[-5:] | all of the last five headers |
| DataBroker[108] | header with scan ID 108 (if ambiguous, most recent is found) |
| DataBroker[[108, 109, 110]] | headers with scan IDs 108, 109, 110 |
| DataBroker['acsf3rf'] | header with unique ID (uid) beginning with acsf3rf |
Time-based Queries¶
Runs that took place sometime in a given time interval are also supported.
| syntax | meaning |
|---|---|
| DataBroker(start_time='2015-01') | all headers from January 2015 or later |
| DataBroker(start_time='2015-01-05', end_time='2015-01-010') | between January 5 and 10 |
Complex Queries¶
Finally, for advanced queries, the full MongoDB query language is supported. Here are just a few examples:
| syntax | meaning |
|---|---|
| DataBroker(sample={'$exists': True}) | headers that include a custom metadata field labeled ‘color’ |
| DataBroker(scan_type={'$ne': 'DeltaScan'}) | headers where the type of scan was not a DeltaScan |
See the MongoDB query documentation for more.
Data Muxer¶
| DataMuxer() | This class provides a wrapper layer of signals and slots around a pandas DataFrame to make plugging stuff in for live view easier. |
| ColSpec | Named-tuple sub-class to validate the column specifications for the |
| dataframe_to_dict(df) | Turn a DataFrame into a dict of lists. |
| BinningError | An exception to raise if there are insufficient sampling rules to upsampling or downsample a data column into specified bins. |
| BadDownsamplerError | An exception to raise if a downsampler produces unexpected output. |