opencr.data.native
OpenCR’s native, versioned file format for reaction networks.
A network is written as one JSON document::
{"format": "opencr-network", "version": 1, "name": ..., "assumptions": [...], "species": [...], "states": [...], "reactions": [...]}Each reaction lists its reactants and products by state name ("e" for the
electron), its kind, its rate model (opencr.core.rates.RateModel.to_dict;
a Function is written as its table) and its
provenance. Reading checks the format name and version, then builds and
checks the network. Files of a newer major version are refused.
Attributes
| Name | Description |
|---|---|
FORMAT_NAME | No description. |
FORMAT_VERSION | No description. |
Functions
| Name | Description |
|---|---|
load_network | Read a network written by save_network. |
network_from_dict | Return the network of network_to_dict's output, checked. |
network_to_dict | Return the network in the native format as plain data. |
rate_from_dict | Return the rate model of to_dict's output. |
save_network | Write the network to path as native JSON and return the path. |
FORMAT_NAMEattributemodule attribute#
FORMAT_NAME = 'opencr-network'FORMAT_VERSIONattributemodule attribute#
FORMAT_VERSION = 1load_networkfunction#
def load_network(path: str | Path) -> ReactionNetworkRead a network written by save_network.
network_from_dictfunction#
def network_from_dict(data: Mapping[str, Any]) -> ReactionNetworkReturn the network of network_to_dict’s output, checked.
network_to_dictfunction#
def network_to_dict(network: ReactionNetwork) -> dict[str, Any]Return the network in the native format as plain data.
rate_from_dictfunction#
def rate_from_dict(data: Mapping[str, Any]) -> RateModelReturn the rate model of to_dict’s output.
save_networkfunction#
def save_network(network: ReactionNetwork, path: str | Path) -> PathWrite the network to path as native JSON and return the path.