.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.weather.WindSpeed Class Reference

Public Member Functions

 __init__ (self, float value, Units unit)
 
 __str__ (self)
 
float value (self, Units unit)
 
str l10n (self, Units|None unit=None, babel.Locale|GeoLocation|None locale=None, str template="{value} {unit}", str num_pattern="#,##0")
 

Public Attributes

float si = convert_to_si(si_name=self.si_name, symbol=unit, value=value)
 

Static Public Attributes

str si_name = "Q182429"
 
 Units = typing.Literal["m/s", "km/h", "kn", "mph", "mi/h", "Bft"]
 
 units = list(typing.get_args(Units))
 

Detailed Description

Class for converting speed or velocity units and for string
representation of measured values.

.. hint::

   Working with unit ``Bft`` (:py:obj:`searx.wikidata_units.Beaufort`) will
   throw a :py:obj:`ValueError` for egative values or values greater 16 Bft
   (55.6 m/s)

Definition at line 333 of file weather.py.

Constructor & Destructor Documentation

◆ __init__()

searx.weather.WindSpeed.__init__ ( self,
float value,
Units unit )

Definition at line 351 of file weather.py.

351 def __init__(self, value: float, unit: Units):
352 if unit not in self.units:
353 raise ValueError(f"invalid unit: {unit}")
354 # pylint: disable=invalid-name
355 self.si: float = convert_to_si(si_name=self.si_name, symbol=unit, value=value)
356

References searx.weather.Pressure.units, searx.weather.Temperature.units, and units.

Member Function Documentation

◆ __str__()

searx.weather.WindSpeed.__str__ ( self)

Definition at line 357 of file weather.py.

357 def __str__(self):
358 return self.l10n()
359

References searx.weather.DateTime.l10n(), searx.weather.Pressure.l10n(), searx.weather.Temperature.l10n(), and l10n().

+ Here is the call graph for this function:

◆ l10n()

str searx.weather.WindSpeed.l10n ( self,
Units | None unit = None,
babel.Locale | GeoLocation | None locale = None,
str template = "{value} {unit}",
str num_pattern = "#,##0" )

Definition at line 363 of file weather.py.

369 ) -> str:
370 if isinstance(locale, GeoLocation):
371 locale = locale.locale()
372 elif locale is None:
373 locale = babel.Locale.parse(_get_sxng_locale_tag(), sep='-')
374
375 if unit is None: # unit by territory?
376 unit = "m/s"
377
378 val_str = babel.numbers.format_decimal(self.value(unit), locale=locale, format=num_pattern)
379 return template.format(value=val_str, unit=unit)
380
381

References searx.weather._get_sxng_locale_tag(), searx.preferences.BooleanSetting.value, searx.preferences.EnumStringSetting.value, searx.preferences.MapSetting.value, searx.preferences.MultipleChoiceSetting.value, searx.preferences.SearchLanguageSetting.value, searx.preferences.Setting.value, searx.weather.Pressure.value(), searx.weather.Temperature.value(), and value().

Referenced by searx.weather.Compass.__str__(), searx.weather.RelativeHumidity.__str__(), and __str__().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ value()

float searx.weather.WindSpeed.value ( self,
Units unit )

Definition at line 360 of file weather.py.

360 def value(self, unit: Units) -> float:
361 return convert_from_si(si_name=self.si_name, symbol=unit, value=self.si)
362

References searx.weather.Pressure.si, searx.weather.Temperature.si, si, searx.weather.Pressure.si_name, searx.weather.Temperature.si_name, and si_name.

Referenced by searx.weather.Compass.l10n(), searx.weather.RelativeHumidity.l10n(), and l10n().

+ Here is the caller graph for this function:

Member Data Documentation

◆ si

float searx.weather.WindSpeed.si = convert_to_si(si_name=self.si_name, symbol=unit, value=value)

Definition at line 355 of file weather.py.

Referenced by value().

◆ si_name

str searx.weather.WindSpeed.si_name = "Q182429"
static

Definition at line 344 of file weather.py.

Referenced by value().

◆ Units

searx.weather.WindSpeed.Units = typing.Literal["m/s", "km/h", "kn", "mph", "mi/h", "Bft"]
static

Definition at line 346 of file weather.py.

◆ units

searx.weather.WindSpeed.units = list(typing.get_args(Units))
static

Definition at line 349 of file weather.py.

Referenced by __init__().


The documentation for this class was generated from the following file: