libcrystfel  0.10.1
Macros | Typedefs | Enumerations | Functions
stream.h File Reference


#define STREAM_GEOM_START_MARKER   "----- Begin geometry file -----"
#define STREAM_GEOM_END_MARKER   "----- End geometry file -----"
#define STREAM_CELL_START_MARKER   "----- Begin unit cell -----"
#define STREAM_CELL_END_MARKER   "----- End unit cell -----"
#define STREAM_CHUNK_START_MARKER   "----- Begin chunk -----"
#define STREAM_CHUNK_END_MARKER   "----- End chunk -----"
#define STREAM_PEAK_LIST_START_MARKER   "Peaks from peak search"
#define STREAM_PEAK_LIST_END_MARKER   "End of peak list"
#define STREAM_CRYSTAL_START_MARKER   "--- Begin crystal"
#define STREAM_CRYSTAL_END_MARKER   "--- End crystal"
#define STREAM_REFLECTION_START_MARKER   "Reflections measured after indexing"
#define STREAM_REFLECTION_END_MARKER   "End of reflections"


typedef struct _stream Stream
typedef struct _streamindex StreamIndex


enum  StreamFlags {


Streamstream_open_for_read (const char *filename)
Streamstream_open_for_write (const char *filename, const DataTemplate *dtempl)
Streamstream_open_fd_for_write (int fd, const DataTemplate *dtempl)
void stream_close (Stream *st)
void stream_write_geometry_file (Stream *st, const char *geom_filename)
void stream_write_target_cell (Stream *st, UnitCell *cell)
void stream_write_commandline_args (Stream *st, int argc, char *argv[])
void stream_write_indexing_methods (Stream *st, const char *indm_str)
int stream_has_old_indexers (Stream *st)
char * stream_audit_info (Stream *st)
char * stream_geometry_file (Stream *st)
int stream_get_fd (Stream *st)
int stream_rewind (Stream *st)
StreamIndex * stream_make_index (const char *filename)
int stream_select_chunk (Stream *st, StreamIndex *index, const char *filename, const char *ev)
void stream_index_free (StreamIndex *index)
struct imagestream_read_chunk (Stream *st, StreamFlags srf)
int stream_write_chunk (Stream *st, const struct image *image, StreamFlags srf)

Detailed Description

Stream functions (for indexing results)

Typedef Documentation

◆ Stream

typedef struct _stream Stream

An opaque structure representing a stream being read or written

Enumeration Type Documentation

◆ StreamFlags

A bitfield of things that can be read from or written to a stream. Use this together with stream_{read,write}_chunk to read/write the stream faster if you don't need all the information.

General information about crystals (including unit cell parameters) is always read and written.


Read the integrated reflections


Read the peak search results


Reconstruct the detgeom structure, and create (blank) data/mask arrays. (NB this is (currently) a slow operation)

Function Documentation

◆ stream_close()

void stream_close ( Stream st)
stA Stream

Closes the stream

◆ stream_open_fd_for_write()

Stream* stream_open_fd_for_write ( int  fd,
const DataTemplate dtempl 
fdFile descriptor (e.g. from open()) to use for stream data.

Creates a new Stream from fd, so that stream data can be written to fd using stream_write_chunk.

In contrast to stream_open_for_write, this function does not write any of the usual headers. This function is mostly for use when multiple substreams need to be multiplexed into a single master stream. The master would be opened using stream_open_for_write, and the substreams using this function.

A Stream, or NULL on failure.

◆ stream_open_for_write()

Stream* stream_open_for_write ( const char *  filename,
const DataTemplate dtempl 
filenameFilename of new stream
dtemplA DataTemplate

Creates a new stream with name filename. If filename already exists, it will be overwritten.

Audit information (e.g. CrystFEL version number) will be written.

A Stream, or NULL on failure.

◆ stream_read_chunk()

struct image* stream_read_chunk ( Stream st,
StreamFlags  srf 

Read the next chunk from a stream and return an image structure

◆ stream_rewind()

int stream_rewind ( Stream st)
stA Stream

Attempts to set the file pointer for st to the start of the stream, so that later calls to stream_read_chunk will repeat the sequence of chunks from the start.

Programs must not assume that this operation always succeeds!

Non-zero if the stream could not be rewound.

◆ stream_write_chunk()

int stream_write_chunk ( Stream st,
const struct image i,
StreamFlags  srf 
stA Stream
iAn image structure
srfA StreamFlags enum saying what to write

Writes a new chunk to st.

non-zero on error.

◆ stream_write_commandline_args()

void stream_write_commandline_args ( Stream st,
int  argc,
char *  argv[] 
stA Stream
argcnumber of arguments
argvcommand-line arguments

Writes the command line to st. argc and argv should be exactly as were given to main(). This should usually be called immediately after stream_open_for_write.

◆ stream_write_geometry_file()

void stream_write_geometry_file ( Stream st,
const char *  geom_filename 
stA Stream
geom_filenamegeomtry file name

Writes the content of the geometry file to st. This should usually be called immediately after write_command.