Source code for pycif.utils.classes.chemistries
from types import MethodType
from ...utils.check.errclass import PluginError
from .baseclass import Plugin
[docs]
class Chemistry(Plugin):
"""Plugin type for atmospheric chemistry schemes.
Provides the interface to read or programmatically create a chemical
scheme used by a transport model. It includes information on species
that are transported, emitted, and for which chemical reactions apply.
Concrete implementations live in ``pycif/plugins/chemistries/``.
"""
[docs]
@classmethod
def register_plugin(cls, name, version, module, subtype="", **kwargs):
"""Register a module for a plugin and version with possibly options
Args:
name (str): name of the plugin
version (str): version of the plugin
module (types.ModuleType): module defining the interface
between pyCIF and the plugin
plugin_type (str): type of plugin
**kwargs (dictionary): default options for module
"""
super(Chemistry, cls).register_plugin(
name, version, module, plugin_type="chemistry", subtype=subtype
)
[docs]
def read_chemicalscheme(self, *args, **kwargs):
"""Read a chemical scheme from an existing file
Args:
self (Chemistry): plugin defining the chemistry. Should include
dirscheme grid to be able to read the chemistry from files
Return:
Characteristics of the chemical scheme
"""
raise PluginError("The function read_scheme was not defined")
[docs]
def create_chemicalscheme(self, *args, **kwargs):
"""Creates a chemical scheme if needed
Args:
chemistry (dictionary): dictionary defining the chelical scheme
"""
raise PluginError("The function create_chemicalscheme was not defined")
[docs]
def initiate_template(self):
"""Initialise the Chemistry plugin template.
Loads the registered chemistry module and attaches
``read_chemicalscheme`` and ``create_chemicalscheme`` as bound methods
on this instance.
"""
super(Chemistry, self).initiate_template(
plg_type="chemistry",
default_functions={
"read_chemicalscheme": True, "create_chemicalscheme": True}
)