Source code for pycif.plugins.models.dummy.io.inputs.meteo

import pandas as pd


[docs] def make_meteo(self, datastore, ddi, ddf): """Load a meteorological field from the CIF datastore into the dummy model. Reads one meteorological parameter (e.g. ``'winddir'``, ``'windspeed'``) from the datastore and appends it as a column to ``self.meteo.data[ddi]``. Args: self: dummy model plugin instance with a ``meteo`` sub-plugin. datastore (dict): tracer-ID-keyed CIF data-store; only the first entry's ``'spec'`` array is used. ddi (datetime): period start date (key into ``self.meteo.data``). ddf (datetime): period end date (unused). """ param = list(datastore.keys())[0][1] ds = \ datastore[("meteo", param)]["data"][ddi]["spec"][:, 0, 0, 0] \ .to_dataframe() ds.columns = [param] if param in ["winddir", "windspeed"]: ds = ds.astype({param: "float"}) # Putting data in the meteo Plugin if not hasattr(self.meteo, "data"): self.meteo.data = {} if ddi not in self.meteo.data: self.meteo.data[ddi] = ds else: self.meteo.data[ddi] = pd.concat([self.meteo.data[ddi], ds], axis=1)