Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue with VBR wind direction and wind_dir.compass #163

@taftr1

Description

@taftr1

I am working on a Program to display the Current weather on a Raspberry Pi. I'd like to display the wind direction and the closest I found is the variable wind_dir.compass. However when the wind direction is listed as VBR. I get the following error:

AttributeError: 'NoneType' object has no attribute 'compass'

Here is a Sample script I use to reproduce this error. If you change the input code between the 2 listed in the script you can make the error happen or not.

from __future__ import print_function

from metar import Metar

# A sample METAR report
code = (
#    "K12N 121754Z AUTO 36007G16KT 330V040 M01/M04 A2931 RMK AO1 SLP934 P0001 60042 T10111044 10056 21017 56042"
    "K12N 082154Z AUTO VRB03KT 07/M09 A3013 RMK AO1 SLP208 T00721089"
)

print("-----------------------------------------------------------------------")
print("METAR: ", code)
print("-----------------------------------------------------------------------")

# Initialize a Metar object with the coded report
obs = Metar.Metar(code)

# Print the individual data

# The 'station_id' attribute is a string.
print("station: %s" % obs.station_id)


print("Compass: " + obs.wind_dir.compass())

print("-----------------------------------------------------------------------\n")
'''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions