.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.wikidata_units.Beaufort Class Reference

Public Member Functions

float from_si (cls, value)
float to_si (cls, value)

Static Public Attributes

list scale

Detailed Description

The mapping of the Beaufort_ contains values from 0 to 16 (55.6 m/s),
wind speeds greater than 200km/h (55.6 m/s) are given as 17 Bft. Thats why
a value of 17 Bft cannot be converted to SI.

.. hint::

   Negative values or values greater 16 Bft (55.6 m/s) will throw a
   :py:obj:`ValueError`.

_Beaufort: https://en.wikipedia.org/wiki/Beaufort_scale

Definition at line 17 of file wikidata_units.py.

Member Function Documentation

◆ from_si()

float searx.wikidata_units.Beaufort.from_si ( cls,
value )

Definition at line 40 of file wikidata_units.py.

40 def from_si(cls, value) -> float:
41 if value < 0 or value > 55.6:
42 raise ValueError(f"invalid value {value} / the Beaufort scales from 0 to 16 (55.6 m/s)")
43 bft = 0
44 for bft, mps in enumerate(cls.scale):
45 if mps >= value:
46 break
47 return bft
48

References scale.

◆ to_si()

float searx.wikidata_units.Beaufort.to_si ( cls,
value )

Definition at line 50 of file wikidata_units.py.

50 def to_si(cls, value) -> float:
51 idx = round(value)
52 if idx < 0 or idx > 16:
53 raise ValueError(f"invalid value {value} / the Beaufort scales from 0 to 16 (55.6 m/s)")
54 return cls.scale[idx]
55
56

References scale.

Member Data Documentation

◆ scale

searx.wikidata_units.Beaufort.scale
static
Initial value:
= [
0.2, 1.5, 3.3, 5.4, 7.9,
10.7, 13.8, 17.1, 20.7, 24.4,
28.4, 32.6, 32.7, 41.1, 45.8,
50.8, 55.6
]

Definition at line 31 of file wikidata_units.py.

Referenced by from_si(), and to_si().


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