Skip to content
Back to top
View this page
Edit this page

# Weather

Implementations used for weather conditions and forecast.

searx.weather.symbol_url(condition: Literal['clear sky', 'partly cloudy', 'cloudy', 'fair', 'fog', 'light rain and thunder', 'light rain showers and thunder', 'light rain showers', 'light rain', 'rain and thunder', 'rain showers and thunder', 'rain showers', 'rain', 'heavy rain and thunder', 'heavy rain showers and thunder', 'heavy rain showers', 'heavy rain', 'light sleet and thunder', 'light sleet showers and thunder', 'light sleet showers', 'light sleet', 'sleet and thunder', 'sleet showers and thunder', 'sleet showers', 'sleet', 'heavy sleet and thunder', 'heavy sleet showers and thunder', 'heavy sleet showers', 'heavy sleet', 'light snow and thunder', 'light snow showers and thunder', 'light snow showers', 'light snow', 'snow and thunder', 'snow showers and thunder', 'snow showers', 'snow', 'heavy snow and thunder', 'heavy snow showers and thunder', 'heavy snow showers', 'heavy snow']) → str | None

  Returns `data:` URL for the weather condition symbol or `None` if the condition is not of type `WeatherConditionType`.

  If symbol (SVG) is not already in the `WEATHER_DATA_CACHE` its fetched from https://github.com/nrkno/yr-weather-symbols

class searx.weather.Temperature(*, val: float, unit: Literal['°C', '°F', 'K'])

  Class for converting temperature units and for string representation of measured values.

  l10n(unit: Literal['°C', '°F', 'K'] | None = None, locale: Locale | GeoLocation | None = None, template: str = '{value} {unit}', num_pattern: str = '#,##0') → str

    Localized representation of a measured value.

    If the `unit` is not set, an attempt is made to determine a `unit` matching the territory of the `locale`. If the locale is not set, an attempt is made to determine it from the HTTP request.

    The value is converted into the respective unit before formatting.

    The argument `num_pattern` is used to determine the string formatting of the numerical value:

    - https://babel.pocoo.org/en/latest/numbers.html#pattern-syntax

    - https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns

    The argument `template` specifies how the string formatted value and unit are to be arranged.

    - Format Specification Mini-Language <https://docs.python.org/3/library/string.html#format-specification-mini-language>.

class searx.weather.Pressure(*, val: float, unit: Literal['Pa', 'hPa', 'cm Hg', 'bar'])

  Class for converting pressure units and for string representation of measured values.

class searx.weather.WindSpeed(*, val: float, unit: Literal['m/s', 'km/h', 'kn', 'mph', 'mi/h', 'Bft'])

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

  Hint

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

class searx.weather.RelativeHumidity(val: float)

  Amount of relative humidity in the air. The unit is `%`

class searx.weather.Compass(val: float | int | Literal['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'], unit: Literal['°', 'Point'] = '°')

  Class for converting compass points and azimuth values (360°)

  TURN: ClassVar[float] = 360.0

    Full turn (360°)

  POINTS: ClassVar[tuple[Literal['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']]] = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW')

    Compass points.

  RANGE: ClassVar[float] = 22.5

    Angle sector of a compass point

  classmethod point(azimuth: float | int) → Literal['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']

    Returns the compass point to an azimuth value.

searx.weather.WeatherConditionType

  Standardized designations for weather conditions. The designators were taken from a collaboration between NRK and Norwegian Meteorological Institute (yr.no). Weather symbols can be assigned to the identifiers (weathericons) and they are included in the translation (i18n/l10n git://searx/searxng.msg).

  alias of `Literal`[‘clear sky’, ‘partly cloudy’, ‘cloudy’, ‘fair’, ‘fog’, ‘light rain and thunder’, ‘light rain showers and thunder’, ‘light rain showers’, ‘light rain’, ‘rain and thunder’, ‘rain showers and thunder’, ‘rain showers’, ‘rain’, ‘heavy rain and thunder’, ‘heavy rain showers and thunder’, ‘heavy rain showers’, ‘heavy rain’, ‘light sleet and thunder’, ‘light sleet showers and thunder’, ‘light sleet showers’, ‘light sleet’, ‘sleet and thunder’, ‘sleet showers and thunder’, ‘sleet showers’, ‘sleet’, ‘heavy sleet and thunder’, ‘heavy sleet showers and thunder’, ‘heavy sleet showers’, ‘heavy sleet’, ‘light snow and thunder’, ‘light snow showers and thunder’, ‘light snow showers’, ‘light snow’, ‘snow and thunder’, ‘snow showers and thunder’, ‘snow showers’, ‘snow’, ‘heavy snow and thunder’, ‘heavy snow showers and thunder’, ‘heavy snow showers’, ‘heavy snow’]

class searx.weather.DateTime

  Class to represent date & time. Essentially, it is a wrapper that conveniently combines `datetime.datetime` and `babel.dates.format_datetime`. A conversion of time zones is not provided (in the current version).

  The localized string representation can be obtained via the `DateTime.l10n` and `DateTime.l10n_date` methods, where the `locale` parameter defaults to the search language. Alternatively, a `GeoLocation` or a `babel.Locale` instance can be passed directly. If the UI language is to be used, the string `UI` can be passed as the value for the `locale`.

  l10n(fmt: Literal['full', 'long', 'medium', 'short'] | str = 'medium', locale: Literal['UI'] | Locale | GeoLocation | None = None) → str

    Localized representation of date & time.

  l10n_date(fmt: Literal['full', 'long', 'medium', 'short'] | str = 'medium', locale: Literal['UI'] | Locale | GeoLocation | None = None) → str

    Localized representation of date.

class searx.weather.GeoLocation(*, name: str, latitude: float, longitude: float, elevation: float, country_code: str, timezone: str)

  Minimal implementation of Geocoding.

  classmethod by_query(search_term: str) → GeoLocation

    Factory method to get a GeoLocation object by a search term. If no location can be determined for the search term, a `ValueError` is thrown.