Source code for pycif.utils.classes.meteos

from types import MethodType

from .baseclass import Plugin, PluginError


[docs] class Meteo(Plugin): """Plugin type for meteorological data streams. A DataStream sub-type for reading and writing meteorological fields (wind, temperature, humidity, …) required by the transport model. Concrete implementations live in ``pycif/plugins/datastreams/meteos/``. """
[docs] def initiate_template(self): """Initialise the Meteo plugin template. Loads the registered meteo module and attaches ``write`` and ``read`` as bound methods, and ``fetch`` as a static function on this instance. """ super(Meteo, self).initiate_template( plg_type="meteo", default_functions={"write": True, "read": True, "fetch": False} )
[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(Meteo, cls).register_plugin( name, version, module, plugin_type="meteo", subtype=subtype )
[docs] def read(self, name, metdir, metfile, dates): """Read pre-computed meteorological fields into pyCIF variables. Must be overridden by each concrete meteo plugin. Args: name (str): Name of the meteo component. metdir (str): Directory where the meteo files are stored. metfile (str): File name pattern for the meteo files. dates (list[datetime]): List of dates to extract. Raises: PluginError: Always, in this default implementation. """ raise PluginError('The function read was not defined')