Python library for parsing and generating NMEA 0183 protocol messages used in GPS and marine navigation systems
77
Wind and weather sentences provide meteorological data including wind speed, direction, temperature, pressure, and humidity measurements.
class MWV(TalkerSentence, ValidStatusFix):
"""Wind Speed and Angle."""
wind_angle: str # Wind angle in degrees
reference: str # Reference ('R' = relative, 'T' = true)
wind_speed: str # Wind speed
wind_speed_units: str # Speed units ('N' = knots, 'M' = m/s, 'K' = km/h)
status: str # 'A' = valid, 'V' = invalid
@property
def is_valid(self) -> bool:
"""True if status is 'A'."""class VWR(TalkerSentence):
"""Relative Wind Speed and Angle."""
deg_r: str # Wind direction relative to vessel
l_r: str # 'L' = left, 'R' = right
wind_speed_kn: str # Wind speed in knots
unit_knots: str # 'N' for knots
wind_speed_ms: str # Wind speed in m/s
unit_ms: str # 'M' for m/s
wind_speed_km: str # Wind speed in km/h
unit_km: str # 'K' for km/hclass MWD(TalkerSentence):
"""Wind Direction."""
direction_true: str # True wind direction in degrees
true: str # 'T' for true
direction_magnetic: str # Magnetic wind direction in degrees
magnetic: str # 'M' for magnetic
wind_speed_knots: str # Wind speed in knots
knots: str # 'N' for knots
wind_speed_meters: str # Wind speed in m/s
meters: str # 'M' for m/sclass MTA(TalkerSentence):
"""Air Temperature."""
temperature: str # Temperature value
units: str # 'C' for Celsiusclass MTW(TalkerSentence):
"""Water Temperature."""
temperature: str # Water temperature value
units: str # 'C' for Celsiusclass MDA(TalkerSentence):
"""Meteorological Composite."""
b_pressure_inch: str # Barometric pressure in inches of mercury
inches: str # 'I' for inches
b_pressure_bar: str # Barometric pressure in bars
bars: str # 'B' for bars
air_temp: str # Air temperature
a_celsius: str # 'C' for Celsius
water_temp: str # Water temperature
w_celsius: str # 'C' for Celsius
rel_humidity: str # Relative humidity percentage
abs_humidity: str # Absolute humidity
dew_point: str # Dew point temperature
d_celsius: str # 'C' for Celsius
direction_true: str # True wind direction
true: str # 'T' for true
direction_magnetic: str # Magnetic wind direction
magnetic: str # 'M' for magnetic
wind_speed_knots: str # Wind speed in knots
knots: str # 'N' for knots
wind_speed_meters: str # Wind speed in m/s
meters: str # 'M' for m/simport pynmea2
# Parse wind speed and angle
msg = pynmea2.parse("$WIMWV,214,R,8.5,N,A*23")
print(f"Wind: {msg.wind_angle}° relative, {msg.wind_speed} {msg.wind_speed_units}") # 214° relative, 8.5 N
print(f"Valid: {msg.is_valid}") # True
# Parse relative wind
msg = pynmea2.parse("$WIMVR,045,R,8.5,N,4.4,M,15.8,K*59")
print(f"Relative wind: {msg.deg_r}° to {msg.l_r}") # 045° to R (right)
print(f"Speed: {msg.wind_speed_kn} knots, {msg.wind_speed_ms} m/s") # 8.5 knots, 4.4 m/s
# Parse comprehensive weather data
msg = pynmea2.parse("$WIMDA,30.15,I,1.02,B,23.5,C,18.2,C,65.5,,12.8,C,195,T,200,M,8.5,N,4.4,M*3D")
print(f"Pressure: {msg.b_pressure_inch} inches, {msg.b_pressure_bar} bars")
print(f"Air temp: {msg.air_temp}°C, Water temp: {msg.water_temp}°C")
print(f"Humidity: {msg.rel_humidity}%, Dew point: {msg.dew_point}°C")
print(f"Wind: {msg.direction_true}°T at {msg.wind_speed_knots} knots")
# Parse air temperature
msg = pynmea2.parse("$WIMTA,23.5,C*1F")
print(f"Air temperature: {msg.temperature}°{msg.units}") # 23.5°CInstall with Tessl CLI
npx tessl i tessl/pypi-pynmea2docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10