diffractem.stream_parser module¶
- class diffractem.stream_parser.StreamParser(filename, parse_now=True, serial_offset=-1, new_folder=None)[source]¶
Bases:
object- property cell¶
cell section as dictionary
- Type:
return
- property files¶
- property geometry¶
geometry section as dictionary
- Type:
return
- property indexed¶
- property input_file¶
- property num_crystals¶
- property num_shots¶
- property options¶
crystfel call options (ONLY – ones) as dict
- Type:
return
- property peaks¶
- property shots¶
- diffractem.stream_parser.augment_stream(streamname, outfile, new_fields, where='chunk')[source]¶
Add new fields to chunk headers in the stream file, which can then be used for chopping or filtering. Somewhat similar to indexamajig’s “include-hdf5-field” option, just after the fact.
- Parameters:
streamname (str) – Name of stream file
new_fields (pd.DataFrame) – pandas DataFrame with index matching the file and Event of the stream file and columns matching the additional fields to be added
- diffractem.stream_parser.chop_stream(streamname, id_list, id_field='hdf5/%/shots/frame', id_suffix='frame', fn_contains=None)[source]¶
Chops a stream file into sub-streams containing only shots with a specific value of a defined field, which must be in the chunk header. Useful e.g. for chopping into aggregation frames, different sample grids, runs with different rotation angles etc.
If you just want to select a sub-set of a stream file instead of chopping it up into many parts, consider using the stream_grep script included with CrystFEL, which is way faster and more flexible.
- Parameters:
streamname (str) – Stream file name
id_list (str) – List of values of the ID variable which you want to have in the final files.
id_field (str) – Field in chunk data to select by. Defaults to ‘hdf5/%/shots/frame’.
id_appendix (str) – Appendix to be applied to the output stream file names. Defaults to ‘frame’.
- diffractem.stream_parser.make_substream(stream, Ncryst, seed=None, filename=None, query=None)[source]¶
Write a stream file containing a sub-set of events to a new stream file.
- Parameters:
stream (StreamParser) – StreamParser object holding the original stream
Ncryst (int) – Number of events to sample
seed (Optional[int], optional) – Seed of the random generator. Defaults to None.
filename (Optional[str], optional) – Output stream filename. Defaults to filename of original stream, with ‘-N_{Ncryst}’ appended, where {Ncryst} is the number of sampled crystals.
query (str, optional) – query to pre-select events. A sensible choice might be to only pick indexed events by setting query=’indexed_by != “none”’. Defaults to None.
- Returns:
[description]
- Return type:
[type]