Skip to main content

meteostat.config

Configure the behavior of the Meteostat Python library.

  • Type: Singleton
  • Source Code: GitHub

The meteostat.config module allows you to customize how the Meteostat library retrieves, caches, and processes weather data. Configuration options can be modified at runtime and also set via environment variables.

Properties

For default values, please refer to the source code.

PropertyDescriptionType
cache_enableEnable or disable caching of data. If True, caching is enabled (default).bool
cache_directoryDirectory path for cached data.str
cache_ttlMaximum time-to-live for cached data (seconds). After this period, cached data is considered expired. Most cached data defines its own TTL, which is usually shorter.int
cache_autocleanAutomatically clean up expired cache files upon interaction with the cache (default True).bool
block_large_requestsWhether to block large requests to prevent excessive data usage (default True). Requests are considered large based on the number of weather stations and period of time requested.bool
network_proxiesDictionary of proxy servers for requests. Please refer to the Requests documentation for more information.Dict[str, str] or None
stations_db_ttlTime-to-live for stations database (seconds). Since the database file is relatively large (more than 20 MB), the TTL should be set to a longer duration to reduce frequent downloads.int
stations_db_urlsURLs to download stations database. URLs are tried in order until a successful download occurs.List[str]
stations_db_filePath to local SQLite stations database.str
hourly_endpointEndpoint URL for hourly data.str
daily_endpointEndpoint URL for daily data.str
monthly_endpointEndpoint URL for monthly data.str
include_model_dataWhether to include model data (e.g. archived weather forecasts or analysis) when retrieving data from default providers (default True).bool
lapse_rate_parametersParameters for lapse rate adjustment. These parameters are adjusted based on altitude differences to improve temperature estimates during interpolation.List[Parameter]
dwd_ftp_hostFTP host for DWD data downloads.str
dwd_hourly_modesDWD hourly data modes (recent/historical) to consider when retrieving data. If None, applicable modes are used automatically.List[str] or None
dwd_daily_modesDWD daily data modes (recent/historical) to consider when retrieving data. If None, applicable modes are used automatically.List[str] or None
dwd_monthly_modesDWD monthly data modes (recent/historical) to consider when retrieving data. If None, applicable modes are used automatically.List[str] or None
aviationweather_endpointNOAA Aviation Weather Center API endpoint.str
aviationweather_user_agentUser agent for Aviation Weather API.str or None
metno_forecast_endpointMet.no forecast API endpoint.str
metno_user_agentUser agent for Met.no APIs. Please refer to the Met.no API documentation for more information.str or None

Methods

  • load_env - Parse environment variables and update the configuration
  • get_env_name - Get the full environment variable name for a configuration option

Examples

import meteostat as ms

# Set the cache directory
ms.config.cache_directory = '/path/to/cache'

# Now all data will be cached in the specified directory
# Your code here