aemetxfb package
Top-level exports from the package:
Main module for aemetxfb package.
- class aemetxfb.AEMetConfig(http_timeout=10.0, download_timeout=60.0, cache_enabled=False, cache_ttl=3600, cache_dir='.aemet_cache')[source]
Bases:
objectCentralized configuration for AEMet HTTP requests.
All timeout values are expressed in seconds. The defaults are chosen to be safe for the variety of endpoints the library calls:
http_timeout— small probe requests (finding the latest timestamp for radar images, checking HTTP status codes).download_timeout— larger payloads (CSV, tar.gz, images).
Caching parameters control the optional disk-based response cache (see
aemetxfb.cache). The cache is disabled by default so that existing code behaviour is unchanged.cache_enabled— whenTrue, decorated functions will read from / write to the SQLite cache store.cache_ttl— time-to-live in seconds for cached entries. Climate data that changes rarely can safely use large values (e.g. 86400 for one day).cache_dir— directory where the SQLite database file is stored.
The class is frozen so that a single shared instance can be safely imported by every module without risk of mutation.
Examples
>>> config = AEMetConfig() >>> config.http_timeout 10.0 >>> config.download_timeout 60.0 >>> config.cache_enabled False
- Parameters:
- aemetxfb.set_config(config)[source]
Replace the module-level CONFIG singleton with a new configuration.
Because
AEMetConfigis frozen (immutable), this function swaps the global reference so that all subsequent calls use the new timeouts. Modules that already importedCONFIGdirectly will still hold the old reference; the library’s own modules re-evaluateCONFIGat call time, so this works correctly for normal usage.- Parameters:
config (AEMetConfig) – The new configuration to use for all HTTP requests.
- Return type:
None
Examples
Replace the global CONFIG with custom timeouts:
>>> from aemetxfb.utils import CONFIG, AEMetConfig, set_config >>> original = CONFIG >>> set_config(AEMetConfig(http_timeout=5.0, download_timeout=30.0)) >>> from aemetxfb.utils import CONFIG as NEW_CONFIG >>> NEW_CONFIG.http_timeout 5.0 >>> set_config(original) # restore >>> from aemetxfb.utils import CONFIG as RESTORED >>> RESTORED.http_timeout 10.0
Subpackages
aemetxfb.clim — Climate data (normals, extremes, ephemerides, thresholds)
aemetxfb.obs — Observations (stations, radar, satellite, radiation, lightning, chemistry)
aemetxfb.pred — Predictions (hourly forecasts for ~8,000 municipalities)
aemetxfb.utils — Utilities and configuration
aemetxfb.cache — Optional disk cache