Weather
Weather
UNIT_GROUP: Final[str] = 'metric'
module-attribute
Defines unit system data is converted to. "metric" or "us". Defaults to "metric"
_append_api_params(url, include=None, elements=None)
Appends API params to URL
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL to append the params to. |
required |
include |
list[IncludeEnum] | None, optional
|
The list of IncludeEnum values to append to the URL. By default |
None
|
elements |
list[ElementsEnum] | None, optional
|
The list of ElementsEnum values to append to the URL. By default |
None
|
Returns:
Type | Description |
---|---|
str
|
The URL with the appended params. |
dynamic_range(location, dynamic_period, include=None, elements=None)
Retrieves dynamic data relative to current date
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
Location format: "city, country" Country needs to be in Alpha-2 Code. |
required |
dynamic_period |
DynamicPeriodEnum
|
Dynamic Period. Refer to |
required |
elements |
list[ElementsEnum] | None, optional
|
List of possible properties in a day or hourly data object that should be retrieved from the API.
Refer to |
None
|
include |
list[IncludeEnum] | None, optional
|
List of possible information that should be retrieved from the API. Refer to |
None
|
forecast(location, start_date=None, end_date=None, include=None, elements=None)
Retrieves weather forecast of given location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
Location format: "city, country" Country needs to be in Alpha-2 Code. |
required |
start_date |
str | None, optional
|
Date format: |
None
|
end_date |
str | None, optional
|
Date format: |
None
|
include |
list[IncludeEnum] | None, optional
|
List of possible information that should be retrieved from the API. Refer to |
None
|
elements |
list[ElementsEnum] | None, optional
|
List of possible properties in a day or hourly data object that should be retrieved from the API.
Refer to |
None
|
historic_day(location, date, include=None, elements=None)
Retrieves historic data from a specific day.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
Location format: "city, country" Country needs to be in Alpha-2 Code. |
required |
date |
str
|
Date format: |
required |
elements |
list[ElementsEnum] | None, optional
|
List of possible properties in a day or hourly data object that should be retrieved from the API.
Refer to |
None
|
include |
list[IncludeEnum] | None, optional
|
List of possible information that should be retrieved from the API. Refer to |
None
|
historic_range(location, start_date, end_date, include=None, elements=None)
Retrieves historic data between two given dates.
- TODO: Check if format is correct (
YYYY-MM-DDThh:mm:ss
orYYYY-MM-DDThh:mm:ssZ
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
str
|
Location format: "city, country" Country needs to be in Alpha-2 Code. |
required |
start_date |
str
|
Date format: |
required |
end_date |
str
|
Date format: |
required |
elements |
list[ElementsEnum] | None, optional
|
List of possible properties in a day or hourly data object that should be retrieved from the API.
Refer to |
None
|
include |
list[IncludeEnum] | None, optional
|
List of possible information that should be retrieved from the API. Refer to |
None
|
Enums & Dataclasses
DynamicPeriodEnum
Enum of possible dynamic periods for weather API
LAST_24_HOURS = 'last24hours'
class-attribute
the 24 hour period ending at the current time (rounded to the currenthour).
LAST_WEEKEND = 'lastweekend'
class-attribute
the last occurrence of the weekend before today's day. Weekend is defined as Saturday and Sunday. Please let us know if you would like additional weekend definitions added.
LAST_YEAR = 'lastyear'
class-attribute
the one year period ending on yesterday's date.
MONTH_TO_DATE = 'monthtodate'
class-attribute
from midnight on the 1st of the current month until the current date time.
NEXT_WEEKEND = 'nextweekend'
class-attribute
the next occurrence of the weekend after today's day. Weekend is defined as Saturday and Sunday. Please let us know if you would like additional weekend definitions added.
TODAY = 'today'
class-attribute
from midnight to the current time at the requested location.
YEART_TO_DATE = 'yeartodate'
class-attribute
from midnight of January 1st of the current year until the current date time.
YESTERDAY = 'yesterday'
class-attribute
from midnight to midnight on yesterday's date.
last_weekday(weekday)
classmethod
the last occurrence of the named day of week before today’s day. For example lastsaturday
last_x_days(days_count)
classmethod
the period before today's date with a length on the number of days specified. For example last7days or last21days.
next_weekday(weekday)
classmethod
the next occurrence of the named day of week after today's day. For example nextsaturday
next_x_days(days_count)
classmethod
the period including and after today's date with a length on the number of days specified. For example next7days or next21days.
ElementsEnum
Enum of possible element parameters for weather API
CAPE = 'cape'
class-attribute
(forecast only) convective available potential energy. This is a numbering indicating amount of energy available to produce thunderstorms. A higher values indicates a more unstable atmosphere capable of creating stronger storms. Values lower than 1000 J/kg indicate generally low instability, between 1000-2500 J/kg medium instability and 2500-4000 J/kg high instability. Values greater than 4000 J/kg indicating an extremely unstable atmosphere.
CIN = 'cin'
class-attribute
(forecast only) convective inhibition. A number representing the level of atmospheric tendency to prevent instability and therefore prevent thunderstorms.
CLOUDCOVER = 'cloudcover'
class-attribute
how much of the sky is covered in cloud ranging from 0-100%
CONDITIONS = 'conditions'
class-attribute
textual representation of the weather conditions. See Weather Data Conditions.
DATETIME = 'datetime'
class-attribute
ISO formatted date, time or datetime value indicating the date and time of the weather data in the local time zone of the requested location
DATETIME_EPOCH = 'datetimeEpoch'
class-attribute
number of seconds since 1st January 1970 in UTC time
DEGREE_DAYS = 'degreedays'
class-attribute
(day only) optional elements indicating the number of degree days for this date. See the degree days API for more information on degree days. To turn degree days and degree day accumulation on, use the elements parameter. For example, elements=datetime,tempmax,tempmin,degreedays,accdegreedays.
DESCRIPTION = 'description'
class-attribute
longer text descriptions suitable for displaying in weather displays. The descriptions combine the main features of the weather for the day such as precipitation or amount of cloud cover. Daily descriptions are provided for historical and forecast days. When the timeline request includes the model forecast period, a seven day outlook description is provided at the root response level.
DEW = 'dew'
class-attribute
dew point temperature
FEELSLIKE = 'feelslike'
class-attribute
what the temperature feels like accounting for heat index or wind chill. Daily values are average values (mean) for the day.
FEELSLIKE_MAX = 'feelslikemax'
class-attribute
(day only) maximum feels like temperature at the location.
FEELSLIKE_MIN = 'feelslikemin'
class-attribute
(day only) minimum feels like temperature at the location.
HOURS = 'hours'
class-attribute
array of hourly weather data objects. This is a child of each of the daily weather object when hours are selected.
HUMIDITY = 'humidity'
class-attribute
relative humidity in %
ICON = 'icon'
class-attribute
a fixed, machine readable summary that can be used to display an icon
MOONRISE = 'moonrise'
class-attribute
(day only, optional) The formatted time of the moonrise (For example “2022-05-23T02:38:10”)
MOONSET = 'moonset'
class-attribute
(day only, optional) The formatted time of the moonset (For example “2022-05-23T13:40:07”)
MOONSET_EPOCH = 'moonsetEpoch'
class-attribute
(day only, optional) moonset time specified as number of seconds since 1st January 1970 in UTC time
MOON_PHASE = 'moonphase'
class-attribute
represents the fractional portion through the current moon lunation cycle ranging from 0 (the new moon) to 0.5 (the full moon) and back to 1 (the next new moon)
MOORISE_EPOCH = 'moonriseEpoch'
class-attribute
(day only, optional) moonrise time specified as number of seconds since 1st January 1970 in UTC time
NORMAL = 'normal'
class-attribute
array of normal weather data values - Each weather data normal is an array of three values representing, in order, the minimum value over the statistical period, the mean value, and the maximum value over the statistical period.
OFFSET_SECONDS = 'offsetseconds'
class-attribute
(hourly only) time zone offset for this weather data object in seconds - This value may change for a location based on daylight saving time observation.
PRECIP = 'precip'
class-attribute
the amount of liquid precipitation that fell or is predicted to fall in the period. This includes the liquid-equivalent amount of any frozen precipitation such as a snow or ice.
PRECIP_COVER = 'precipcover'
class-attribute
(days only) the proportion of hours where there was non-zero precipitation
PRECIP_PROB = 'precipprob'
class-attribute
(forecast only) the likelihood of measurable precipitation ranging from 0% to 100%
PRECIP_TYPE = 'preciptype'
class-attribute
an array indicating the type(s) of precipitation expected or that occurred. Possible values include rain, snow, freezingrain and ice.
PRESSURE = 'pressure'
class-attribute
the sea level atmospheric or barometric pressure in millibars (or hectopascals)
SEVERE_RISK = 'severerisk'
class-attribute
(forecast only) a value between 0 and 100 representing the risk of convective storms (eg thunderstorms, hail and tornadoes). It is a scaled measure that combines a variety of other fields such as the convective available potential energy (CAPE) and convective inhibition (CIN), predicted rain and wind. Typically a value less than 30 indicates a low risk, between 30 and 70 a moderate risk and above 70 a high risk.
SNOW = 'snow'
class-attribute
the amount of snow that fell or is predicted to fall
SNOW_DEPTH = 'snowdepth'
class-attribute
the depth of snow on the ground
SOLAR_ENERGY = 'solarenergy'
class-attribute
(MJ /m2 ) indicates the total energy from the sun that builds up over an hour or day. See the full solar radiation data documentation and Wind and Solar Energy pages .
SOLAR_RADIATION = 'solarradiation'
class-attribute
(W/m2) the solar radiation power at the instantaneous moment of the observation (or forecast prediction). See the full solar radiation data documentation and Wind and Solar Energy pages .
SOURCE = 'source'
class-attribute
the type of weather data used for this weather object. - Values include historical observation (“obs”), forecast (“fcst”), historical forecast (“histfcst”) or statistical forecast (“stats”). If multiple types are used in the same day, “comb” is used. Today a combination of historical observations and forecast data.
STATIONS = 'stations'
class-attribute
(historical only) the weather stations used when collecting an historical observation record
SUNRISE = 'sunrise'
class-attribute
(day only) The formatted time of the sunrise (For example “2022-05-23T05:50:40”)
SUNRISE_EPOCH = 'sunriseEpoch'
class-attribute
sunrise time specified as number of seconds since 1st January 1970 in UTC time
SUNSET = 'sunset'
class-attribute
The formatted time of the sunset (For example “2022-05-23T20:22:29”)
SUNSET_EPOCH = 'sunsetEpoch'
class-attribute
sunset time specified as number of seconds since 1st January 1970 in UTC time
TEMP = 'temp'
class-attribute
temperature at the location. Daily values are average values (mean) for the day.
TEMP_MAX = 'tempmax'
class-attribute
(day only) maximum temperature at the location.
TEMP_MIN = 'tempmin'
class-attribute
(day only) minimum temperature at the location.
TZOFFSET = 'tzoffset'
class-attribute
the time zone offset in hours. This will only occur in the data object if it is different from the global time zone offset.
UV_INDEX = 'uvindex'
class-attribute
a value between 0 and 10 indicating the level of ultra violet (UV) exposure for that hour or day. 10 represents high level of exposure, and 0 represents no exposure. The UV index is calculated based on amount of short wave solar radiation which in turn is a level the cloudiness, type of cloud, time of day, time of year and location altitude. Daily values represent the maximum value of the hourly values.
VISIBILITY = 'visibility'
class-attribute
distance at which distant objects are visible
WIND_DIR = 'winddir'
class-attribute
direction from which the wind is blowing
WIND_GUST = 'windgust'
class-attribute
instantaneous wind speed at a location - May be empty if it is not significantly higher than the wind speed. Daily values are the maximum hourly value for the day.
WIND_SPEED = 'windspeed'
class-attribute
the sustained wind speed measured as the average windspeed that occurs during the preceding one to two minutes. Daily values are the maximum hourly value for the day.
WIND_SPEED_MAX = 'windspeedmax'
class-attribute
(day only, optional) maximum wind speed over the day.
WIND_SPEED_MEAN = 'windspeedmean'
class-attribute
(day only , optional ) average (mean) wind speed over the day.
WIND_SPEED_MIN = 'windspeedmin'
class-attribute
(day only , optional ) minimum wind speed over the day.
IncludeEnum
Enum of possible include parameters for weather API
ALERTS = 'alerts'
class-attribute
weather alerts
CURRENT = 'current'
class-attribute
current conditions or conditions at requested time.
DAYS = 'days'
class-attribute
daily data
EVENTS = 'events'
class-attribute
historical events such as a hail, tornadoes, wind damage and earthquakes (not enabled by default)
FORECAST = 'fcst'
class-attribute
forecast based on 16 day models.
HOURS = 'hours'
class-attribute
hourly data
OBS = 'obs'
class-attribute
historical observations from weather stations
REMOTE = 'remote'
class-attribute
historical observations from remote source such as satellite or radar
STATS = 'stats'
class-attribute
historical statistical normals and daily statistical forecast
STATS_FORECAST = 'statsfcst'
class-attribute
use the full statistical forecast information for dates in the future beyond the current model forecast. Permits hourly statistical forecast.