How to use the metar.Datatypes.direction.compass_dirs.items function in metar

To help you get started, we’ve selected a few metar 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 python-metar / python-metar / metar / Datatypes.py View on Github external
def compass(self):
        """Return the compass direction, e.g., "N", "ESE", etc.)."""
        if not self._compass:
            degrees = 22.5 * round(self._degrees / 22.5)
            if degrees == 360.0:
                self._compass = "N"
            else:
                for name, d in direction.compass_dirs.items():
                    if d == degrees:
                        self._compass = name
                        break
        return self._compass