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[source]

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'], si_name: ClassVar[str] = 'Q11579', UNITS: ClassVar[tuple[Literal['°C', '°F', 'K']]] = ('°C', '°F', 'K'))[source]

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[source]

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:

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'], si_name: ClassVar[str] = 'Q44395', UNITS: ClassVar[tuple[Literal['Pa', 'hPa', 'cm Hg', 'bar']]] = ('Pa', 'hPa', 'cm Hg', 'bar'))[source]

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'], si_name: ClassVar[str] = 'Q182429', UNITS: ClassVar[tuple[Literal['m/s', 'km/h', 'kn', 'mph', 'mi/h', 'Bft']]] = ('m/s', 'km/h', 'kn', 'mph', 'mi/h', 'Bft'))[source]

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, unit: ClassVar[Literal['%']] = '%', UNITS: ClassVar[tuple[Literal['%']]] = ('%',))[source]

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'] = '°', UNITS: ClassVar[tuple[Literal['°', 'Point']]] = ('°', 'Point'), TURN: ClassVar[float] = 360.0, 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'), RANGE: ClassVar[float] = 22.5)[source]

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

TURN: ClassVar[float]

Full turn (360°)

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

Compass points.

RANGE: ClassVar[float]

Angle sector of a compass point

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

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(datetime: datetime)[source]

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[source]

Localized representation of date & time.

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

Localized representation of date.

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

Minimal implementation of Geocoding.

classmethod by_query(search_term: str) GeoLocation[source]

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.