How to use the metview.Fieldset function in metview

To help you get started, we’ve selected a few metview examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esowc / ecPoint-Calibrate / core / loaders / fieldset.py View on Github external
import logging
import os
from functools import reduce
from pathlib import Path
from typing import Union

import metview
import numpy as np

logger = logging.getLogger(__name__)


class Fieldset(metview.Fieldset):
    def __init__(self, path):
        raise PermissionError("Initilizing this class directly is not allowed.")

    @property
    def units(self):
        return metview.grib_get_string(self, "units")

    @classmethod
    def from_path(cls, path: Union[Path, str]):
        if isinstance(path, Path):
            path = str(path)

        if not os.path.exists(path):
            raise IOError(f"File does not exist: {path}")

        obj = metview.read(path)