Source code for neclib.devices.weather_station.vantagepro2

__all__ = ["VantagePro2"]

import astropy.units as u

from .weather_station_base import WeatherStation


[docs] class VantagePro2(WeatherStation): Manufacturer = "Davis" Model = "VantagePro2" Identifier = "port" def __init__(self) -> None: import weather.stations.davis as weatherlink from weather import units self._units = units self.vantage = weatherlink.VantagePro(self.Config.port) def _get_data(self) -> dict: self.vantage._cmd("CLRLOG") ret = self.vantage.parse() if ret["EOL"] == b"\n\r": return ret else: print("Can not access weather station")
[docs] def get_temperature(self) -> u.Quantity: data = self._get_data() data_K = self._units.fahrenheit_to_kelvin(data["TempOut"]) * u.K return data_K
[docs] def get_in_temperature(self) -> u.Quantity: data = self._get_data() data_K = self._units.fahrenheit_to_kelvin(data["TempIn"]) * u.K return data_K
[docs] def get_humidity(self) -> float: data = self._get_data() return data["HumOut"] * 0.01
[docs] def get_in_humidity(self) -> float: data = self._get_data() return data["HumIn"] * 0.01
[docs] def get_pressure(self) -> u.Quantity: data = self._get_data() data_press = self._units.incConv_to_Pa(data["Pressure"]) * 10 * u.hPa return data_press
[docs] def get_wind_speed(self) -> float: data = self._get_data() data_WindSpeed = self._units.mph_to_m_sec(data["WindSpeed"]) * u.m / u.second return data_WindSpeed
[docs] def get_wind_direction(self) -> u.Quantity: data = self._get_data() return data["WindDir"] * u.deg
[docs] def get_rain_rate(self) -> float: data = self._get_data() return data["RainRate"]
[docs] def finalize(self) -> None: self.vantage.__del__()