Returns a dict containing wind info
        
        :param unit: the unit of measure for the wind values. May be:
            '*meters_sec*' (default) or '*miles_hour*'
        :type unit: str
        :returns: a dict containing wind info
194803
def get_wind(self, unit='meters_sec'):
        
        if unit == 'meters_sec':
            return self._wind
        elif unit == 'miles_hour':
            wind_dict = {k: self._wind[k] for k in self._wind if self._wind[k] is not None}
            return temputils.metric_wind_dict_to_imperial(wind_dict)
        else:
            raise ValueError("Invalid value for target wind conversion unit")
391618
def get(self):
        

        with self.lock:
            self.tick()

            data = dict(
                kind="meter",
                count=self.count,
                mean=self.count / (time.time() - self.started_on),
                one=self.m1.rate,
                five=self.m5.rate,
                fifteen=self.m15.rate,
                day=self.day.rate)

        return data
966679
def units(self) -> typing.Iterator['BaseUnit']:
        
        for group in self.groups:
            for unit in group.units:

                yield unit
972089
def items(cls):
        
        return [
            cls.TEMPERATURE,
            cls.PRESSURE,
            cls.HUMIDITY,
            cls.WIND_SPEED,
            cls.WIND_DIRECTION,
            cls.CLOUDS
        ]
25202
def get_info(self):
        
        return {
            self.get_plugin_name() : {
                "version" : self.get_version(),
                "params" : {
                    "icmp_check_interval" : self.conf['icmp_check_interval'],
                },
                "stats" : self.get_stats()
            }
        }
988791
def to_dict(self):
        
        return {'station_id': self.station_id,
                'timestamp': self.timestamp,
                'aggregated_on': self.aggregated_on,
                'temp': self.temp,
                'humidity': self.humidity,
                'wind': self.wind,
                'pressure': self.pressure,
                'precipitation': self.precipitation}
1199768
def check_weather(self):
        '''
        
        '''
        if self.station_id is None:
            # Failed to get the nearest station ID when first launched, so
            # retry it.
            self.get_station_id()

        self.data['update_error'] = ''
        try:
            query_url = STATION_QUERY_URL % (self.api_key,
                                             'conditions',
                                             self.station_id)
            try:
                response = self.api_request(query_url)['current_observation']
                self.forecast_url = response.pop('ob_url', None)
            except KeyError:
                self.logger.error('No weather data found for %s', self.station_id)
                self.data['update_error'] = self.update_error
                return

            if self.forecast:
                query_url = STATION_QUERY_URL % (self.api_key,
                                                 'forecast',
                                                 self.station_id)
                try:
                    forecast = self.api_request(query_url)['forecast']
                    forecast = forecast['simpleforecast']['forecastday'][0]
                except (KeyError, IndexError, TypeError):
                    self.logger.error(
                        'No forecast data found for %s', self.station_id)
                    # This is a non-fatal error, so don't return but do set the
                    # error flag.
                    self.data['update_error'] = self.update_error

                unit = 'celsius' if self.units == 'metric' else 'fahrenheit'
                low_temp = forecast.get('low', {}).get(unit, '')
                high_temp = forecast.get('high', {}).get(unit, '')
            else:
                low_temp = high_temp = ''

            if self.units == 'metric':
                temp_unit = 'c'
                speed_unit = 'kph'
                distance_unit = 'km'
                pressure_unit = 'mb'
            else:
                temp_unit = 'f'
                speed_unit = 'mph'
                distance_unit = 'mi'
                pressure_unit = 'in'

            def _find(key, data=None, default=''):
                if data is None:
                    data = response
                return str(data.get(key, default))

            try:
                observation_epoch = _find('observation_epoch') or _find('local_epoch')
                observation_time = datetime.fromtimestamp(int(observation_epoch))
            except (TypeError, ValueError):
                log.debug(
                    'Observation time \'%s\' is not a UNIX timestamp',
                    observation_epoch
                )
                observation_time = datetime.fromtimestamp(0)

            self.data['city'] = _find('city', response['observation_location'])
            self.data['condition'] = _find('weather')
            self.data['observation_time'] = observation_time
            self.data['current_temp'] = _find('temp_' + temp_unit).split('.')[0]
            self.data['low_temp'] = low_temp
            self.data['high_temp'] = high_temp
            self.data['temp_unit'] = '°' + temp_unit.upper()
            self.data['feelslike'] = _find('feelslike_' + temp_unit)
            self.data['dewpoint'] = _find('dewpoint_' + temp_unit)
            self.data['wind_speed'] = _find('wind_' + speed_unit)
            self.data['wind_unit'] = speed_unit
            self.data['wind_direction'] = _find('wind_dir')
            self.data['wind_gust'] = _find('wind_gust_' + speed_unit)
            self.data['pressure'] = _find('pressure_' + pressure_unit)
            self.data['pressure_unit'] = pressure_unit
            self.data['pressure_trend'] = _find('pressure_trend')
            self.data['visibility'] = _find('visibility_' + distance_unit)
            self.data['visibility_unit'] = distance_unit
            self.data['humidity'] = _find('relative_humidity').rstrip('%')
            self.data['uv_index'] = _find('UV')
        except Exception:
            # Don't let an uncaught exception kill the update thread
            self.logger.error(
                'Uncaught error occurred while checking weather. '
                'Exception follows:', exc_info=True
            )
            self.data['update_error'] = self.update_error
207754
def unit(self, value):
        

        if isinstance(value, TimeUnit):
            self._unit = value
        else:
            self._unit = TimeUnit(value)
25099
def unit(self, parameter):
        ""
        parameter = self._get_parameter_name(parameter).lower()
        return self._parameters[parameter]['Unit']
777749
def metar(wxdata: MetarData, units: Units) -> MetarTrans:
    
    translations = shared(wxdata, units)
    translations['wind'] = wind(wxdata.wind_direction, wxdata.wind_speed,
                                wxdata.wind_gust, wxdata.wind_variable_direction,
                                units.wind_speed)
    translations['temperature'] = temperature(wxdata.temperature, units.temperature)
    translations['dewpoint'] = temperature(wxdata.dewpoint, units.temperature)
    translations['remarks'] = remarks.translate(wxdata.remarks)  # type: ignore
    return MetarTrans(**translations)
1197172
def _normalize_unit(cls, unit):
        
        if unit in cls.UNITS_IN_SECONDS:
            return unit
        return cls.UNIT_ALIASES_REVERSE.get(unit, None)
475836
def unit_value(self, value):
        

        if isinstance(value, TimeUnit):
            self._unit = value
        else:
            self._unit = TimeUnit(value)
1060795
def get_miles(self):
    '''  '''
    if self._obs_value in self.MISSING:
      return 'MISSING'
    if self._obs_units == self.METERSPERSECOND:
      return round(2.23694 * self._obs_value, 4)
86760
def dimensions_unit(self, dimensions_unit):
        
        allowed_values = ["inch", "cm", "foot", "meter"]  # noqa: E501
        if dimensions_unit is not None and dimensions_unit not in allowed_values:
            raise ValueError(
                "Invalid value for `dimensions_unit` ({0}), must be one of {1}"  # noqa: E501
                .format(dimensions_unit, allowed_values)
            )

        self._dimensions_unit = dimensions_unit
457964
def units(self) -> typing.Iterator['BaseUnit']:
        
        for unit_index in self._section_group['units']:
            if unit_index not in self.__units.keys():
                _category = self.units_class_enum[self.group_category]  # type: ignore
                self.__units[unit_index] = _category(self.d, self.l10n, self.coa_color,
                                                     self.country_index,
                                                     self.group_category,
                                                     self.group_index, unit_index)
            yield self.__units[unit_index]
1268562
async def wind_type_classe(self):
        """"""

        data = await self.retrieve(url=API_WIND_TYPE)

        self.wind_type = dict()

        for _type in data['data']:
            self.wind_type[int(_type['classWindSpeed'])] = _type['descClassWindSpeedDailyPT']

        return self.wind_type
306288
def get_weather_forecast(self, place, unit=None):
        
        unit = unit if unit else self.unit
        response = self.get_weather_in(place, items=['item.forecast'], unit=unit)
        return response