Source code for openghg.store._eulerian_model

from __future__ import annotations
import numpy as np
import logging
from typing import Any

from openghg.store import DataSchema
from openghg.store.base import BaseStore

logger = logging.getLogger("openghg.store")
logger.setLevel(logging.DEBUG)  # Have to set level for logger as well as handler

__all__ = ["EulerianModel"]


# TODO: Currently built around these keys but will probably need more unique distiguishers for different setups
# model name
# species
# date (start_date)
# ...
# setup (included as option for now)


[docs] class EulerianModel(BaseStore): """This class is used to process Eulerian model data""" _data_type = "eulerian_model" _root = "EulerianModel" _uuid = "63ff2365-3ba2-452a-a53d-110140805d06" _metakey = f"{_root}/uuid/{_uuid}/metastore"
[docs] def format_inputs(self, **kwargs: Any) -> dict: """ Apply appropriate formatting for expected inputs for EulerianModel. Expected inputs will typically be defined within the openghg.standardise.standardise_eulerian() function. Args: kwargs: Set of keyword arguments. Selected keywords will be appropriately formatted. Returns: dict: Formatted parameters for this data type. """ from openghg.util import clean_string, synonyms params = kwargs.copy() # Apply clean string formatting params["species"] = clean_string(params.get("species")) params["model"] = clean_string(params.get("model")) params["start_date"] = clean_string(params.get("start_date")) params["end_date"] = clean_string(params.get("end_date")) params["setup"] = clean_string(params.get("setup")) # Apply individual formatting as appropriate # - apply synonyms substitution for species species = params.get("species") if species is not None: params["species"] = synonyms(species) return params
[docs] @staticmethod def schema() -> DataSchema: # type:ignore[override] """ Define schema for Eulerian model Dataset. At present, this doesn't check the variables but does check that "lat", "lon", "time" are included as appropriate types. Returns: DataSchema : Contains dummy schema for EulerianModel. TODO: Decide on data_vars checks as we build up the use of this data_type """ data_vars: dict[str, tuple[str, ...]] = {} dtypes = {"lat": np.floating, "lon": np.floating, "time": np.datetime64} data_format = DataSchema(data_vars=data_vars, dtypes=dtypes) return data_format