The crystfel_stream Module#

Functions for getting data from CrystFEL stream output files.

parse_chunk(f, *, peak_tbl=True, refl_tbl=True)#

Parse one chunk (one image/event) from a file-like object to a dictionary

This reads from the current position to the ‘End chunk’ marker or the end of the file.

iter_chunks(stream_file)#

Yield chunks, each describing one image/event, as StringIO objects

The StringIO objects can be used with parse_chunk to extract information. The Begin chunk & End chunk marker lines are not included in the output.

parse_chunks(stream_file, *, peak_tbl=True, refl_tbl=True)#

Iterate over chunks in a stream file, yielding dicts of image info

If you don’t need the tables of peaks found or reflections, skipping these (peak_tbl=False, refl_tbl=False) may make reading much faster.

The values of typical “key = value” lines are left as strings in the dicts, so it’s up to the caller to convert fields it uses into numbers, e.g. int(d['num_peaks']). However, some lines which contain several numbers are parsed (Cell parameters, a/b/c star, 2D detector shift) into small NumPy arrays.