write_file#

pypillometry.write_file(obj, fname, compress=True)[source]#

Store any Python object in a file using pickle (or HDF5).

By default, the file is compressed with zstd (about 13 times smaller for eyedata objects). read_file() detects the compression automatically.

If fname ends with .h5 or .hdf5, the object is stored in an HDF5 file instead (see pypillometry.hdf5); this works for eyedata and segmented objects only.

Parameters:
  • obj (object) – object to save

  • fname (str) – filename to save to

  • compress (bool) – if True (default), compress the file with zstd (HDF5: larger arrays with gzip); if False, write an uncompressed file

Raises:

TypeError – if fname is an HDF5 file and obj is not an eyedata or segmented object