4.5.4 pde.storage.modelrunner module

Defines a class storing data using modelrunner.

class ModelrunnerStorage(storage, *, loc='trajectory', info=None, write_mode='truncate_once')[source]

Bases: StorageBase

store discretized fields in a modelrunner storage

This storage class acts as a wrapper for the trajectory module, which allows handling time-dependent data in modelrunner storages. In principle, all backends are supported, but it is advisable to use binary formats like HDFStorage or ZarrStorage to write large amounts of data.

from modelrunner import Result
r = Result.from_file("data.hdf5")
r.result.plot()  # plots the final state
r.storage["trajectory"]  # allows accessing the stored trajectory
Parameters:
  • storage (StorageGroup) – Modelrunner storage used for storing the trajectory

  • loc (str or list of str) – The location in the storage where the trajectory data is written.

  • 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.

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.

close()[source]

close the currently opened trajectory writer

Return type:

None

property data

The actual data for all time

Type:

ndarray

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

start_writing(field, info=None)[source]

initialize the storage for writing data

Parameters:
  • 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

Return type:

None

property times

The times at which data is available

Type:

ndarray