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, *, info=None, write_mode='truncate_once', max_length=None, compression=True, keep_opened=True, check_mpi=True)[source]
Bases:
StorageBase
Store discretized fields in a hdf5 file.
- Parameters:
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.
check_mpi (bool) – If True, files will only be opened in the main node for an parallel simulation using MPI. This flag has no effect in serial code.
- clear(clear_data_shape=False)[source]
Truncate the storage by removing all stored data.
- Parameters:
clear_data_shape (bool) – Flag determining whether the data shape is also deleted.
- end_writing()[source]
Finalize the storage after writing.
This makes sure the data is actually written to a file when self.keep_opened == False
- Return type:
None