- classmethod Dict.to_dict(network=None, phases=, element=['pore', 'throat'], interleave=True, flatten=True, categorize_by=)¶
Returns a single dictionary object containing data from the given OpenPNM objects, with the keys organized differently depending on optional arguments.
network (GenericNetwork (optional)) – The network containing the desired data
phases (list[GenericPhase]s (optional, default is none)) – A list of phase objects whose data are to be included
element (str or list[str]) – An indication of whether ‘pore’ and/or ‘throat’ data are desired. The default is both.
interleave (bool (default is
True)) – When
True(default) the data from all Geometry objects (and Physics objects if
phasesare given) is interleaved into a single array and stored as a network property (or Phase property for Physics data). When
False, the data for each object are stored under their own dictionary key, the structuring of which depends on the value of the
flatten (bool (default is
True)) – When
True, all objects are accessible from the top level of the dictionary. When
Falseobjects are nested under their parent object. If
Truethis argument is ignored.
categorize_by (str or list[str]) –
Indicates how the dictionaries should be organized. The list can contain any, all or none of the following strings:
’object’ : If specified the dictionary keys will be stored under a general level corresponding to their type (e.g. ‘network/net_01/pore.all’). If
Truethen only the only categories are network and phase, since geometry and physics data get stored under their respective network and phase.
’data’ : If specified the data arrays are additionally categorized by
propertyto separate boolean from numeric data.
’element’ : If specified the data arrays are additionally categorized by
throat, meaning that the propnames are no longer prepended by a ‘pore.’ or ‘throat.’
A dictionary with the data stored in a hierarchical data structure, the
actual format of which depends on the arguments to the function.
There is a handy package called flatdict that can be used to access this dictionary using a single key such that:
d[level_1][level_2] == d[level_1/level_2]
Importantly, converting to a flatdict allows it be converted to an HDF5 file directly, since the hierarchy is dictated by the placement of ‘/’ characters.