4.5.2. pde.storage.file module

Defines a class storing data on the file system using the hierarchical data format (hdf).

class FileStorage(filename: str, info: Optional[Dict[str, Any]] = None, write_mode: str = 'truncate_once', max_length: int = None, compression: bool = True, keep_opened: bool = True)[source]

Bases: StorageBase

store discretized fields in a hdf5 file

  • filename (str) – The path to the hdf5-file where the data is stored

  • info (dict) – Supplies extra information that is stored in the storage

  • write_mode (str) – Determines how new data is added to already existing data. Possible values are: ‘append’ (data is always appended), ‘truncate’ (data is cleared every time this storage is used for writing), or ‘truncate_once’ (data is cleared for the first writing, but appended subsequently). Alternatively, specifying ‘readonly’ will disable writing completely.

  • max_length (int, optional) – Maximal number of entries that will be stored in the file. This can be used to preallocate data, which can lead to smaller files, but is also less flexible. Giving max_length = None, allows for arbitrarily large data, which might lead to larger files.

  • compression (bool) – Whether to store the data in compressed form. Automatically enabled chunked storage.

  • keep_opened (bool) – Flag indicating whether the file should be kept opened after each writing. If False, the file will be closed after writing a dataset. This keeps the file in a consistent state, but also requires more work before data can be written.

clear(clear_data_shape: bool = False)[source]

truncate the storage by removing all stored data.


clear_data_shape (bool) – Flag determining whether the data shape is also deleted.

close() None[source]

close the currently opened file

property data

The actual data for all time



end_writing() None[source]

finalize the storage after writing.

This makes sure the data is actually written to a file when self.keep_opened == False

start_writing(field: FieldBase, info: Optional[Dict[str, Any]] = None) None[source]

initialize the storage for writing data

  • field (FieldBase) – An example of the data that will be written to extract the grid and the data_shape

  • info (dict) – Supplies extra information that is stored in the storage

property times

The times at which data is available



write_mode: str