Core
Core
Settings
Settings for the wetterdienst package.
Settings
Bases: BaseSettings
Settings for the wetterdienst package.
Source code in wetterdienst/settings.py
__repr__()
__str__()
validate()
Validate the settings.
Source code in wetterdienst/settings.py
validate_ts_interpolation_station_distance(values)
classmethod
Validate the interpolation station distance settings.
Source code in wetterdienst/settings.py
validate_ts_unit_targets_after(values)
classmethod
Validate the unit targets.
Source code in wetterdienst/settings.py
validate_ts_unit_targets_before(values)
classmethod
Data models
Geo utilities for the wetterdienst package.
convert_dm_to_dd(dm)
Convert degree minutes (floats) to decimal degree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dm
|
Series
|
Series with degree minutes as float |
required |
Returns:
Type | Description |
---|---|
Series
|
Series with decimal degree |
Source code in wetterdienst/util/geo.py
convert_dms_string_to_dd(dms)
Convert degree minutes seconds (string) to decimal degree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dms
|
Series
|
Series with degree minutes seconds as string |
required |
Returns:
Type | Description |
---|---|
Series
|
Series with decimal degree |
Source code in wetterdienst/util/geo.py
derive_nearest_neighbours(latitudes, longitudes, q_lat, q_lon)
Obtain the nearest neighbours using a simple distance computation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
latitudes
|
Array
|
latitudes in degree |
required |
longitudes
|
Array
|
longitudes in degree |
required |
q_lat
|
float
|
latitude of the query point |
required |
q_lon
|
float
|
longitude of the query point |
required |
Returns:
Type | Description |
---|---|
list[float]
|
Tuple of distances and ranks of nearest to most distant station |
Source code in wetterdienst/util/geo.py
Download
Network utilities for the wetterdienst package.
FileDirCache
Bases: MutableMapping
File-based cache for FSSPEC.
Source code in wetterdienst/util/network.py
__contains__(item)
__delitem__(key)
__getitem__(item)
__init__(listings_expiry_time, *, use_listings_cache, listings_cache_location=None)
Initialize the FileDirCache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
listings_expiry_time
|
float
|
Time in seconds that a listing is considered valid. If None, |
required |
use_listings_cache
|
bool
|
If False, this cache never returns items, but always reports KeyError, |
required |
listings_cache_location
|
str | None
|
Directory path at which the listings cache file is stored. If None, |
None
|
Source code in wetterdienst/util/network.py
__iter__()
__len__()
__reduce__()
__setitem__(key, value)
HTTPFileSystem
Bases: HTTPFileSystem
HTTPFileSystem with cache support.
Source code in wetterdienst/util/network.py
__init__(use_listings_cache=None, listings_expiry_time=None, listings_cache_location=None, *args, **kwargs)
Initialize the HTTPFileSystem.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
use_listings_cache
|
bool | None
|
If False, this cache never returns items, but always reports KeyError, |
None
|
listings_expiry_time
|
float | None
|
Time in seconds that a listing is considered valid. If None, |
None
|
listings_cache_location
|
str | None
|
Directory path at which the listings cache file is stored. If None, |
None
|
*args
|
tuple
|
Additional arguments. |
()
|
**kwargs
|
dict
|
Additional keyword arguments. |
{}
|
Source code in wetterdienst/util/network.py
NetworkFilesystemManager
Manage multiple FSSPEC instances keyed by cache expiration time.
Source code in wetterdienst/util/network.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
get(cache_dir, ttl=CacheExpiry.NO_CACHE, client_kwargs=None, *, cache_disable=False)
classmethod
Get a filesystem instance for a given cache expiration time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir
|
Path
|
The cache directory to use for the filesystem. |
required |
ttl
|
CacheExpiry
|
The cache expiration time. |
NO_CACHE
|
client_kwargs
|
dict | None
|
Additional keyword arguments for the client. |
None
|
cache_disable
|
bool
|
If True, the cache is disabled |
False
|
Returns:
Type | Description |
---|---|
AbstractFileSystem
|
The filesystem instance. |
Source code in wetterdienst/util/network.py
register(cache_dir, ttl=CacheExpiry.NO_CACHE, client_kwargs=None, *, cache_disable=False)
classmethod
Register a new filesystem instance for a given cache expiration time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cache_dir
|
Path
|
The cache directory to use for the filesystem. |
required |
ttl
|
CacheExpiry
|
The cache expiration time. |
NO_CACHE
|
client_kwargs
|
dict | None
|
Additional keyword arguments for the client. |
None
|
cache_disable
|
bool
|
If True, the cache is disabled. |
False
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in wetterdienst/util/network.py
resolve_ttl(ttl)
staticmethod
Resolve the cache expiration time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ttl
|
int | CacheExpiry
|
The cache expiration time. |
required |
Returns:
Type | Description |
---|---|
tuple[str, int]
|
The cache expiration time as name and value. |
Source code in wetterdienst/util/network.py
download_file(url, cache_dir, ttl=CacheExpiry.NO_CACHE, client_kwargs=None, *, cache_disable=False)
Download a specified file from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL of the file to download. |
required |
cache_dir
|
Path
|
The cache directory to use for the filesystem. |
required |
ttl
|
CacheExpiry
|
The cache expiration time. |
NO_CACHE
|
client_kwargs
|
dict | None
|
Additional keyword arguments for the client. |
None
|
cache_disable
|
bool
|
If True, the cache is disabled. |
False
|
Returns:
Type | Description |
---|---|
BytesIO
|
A BytesIO object containing the downloaded file. |
Source code in wetterdienst/util/network.py
download_files(urls, cache_dir, ttl=CacheExpiry.NO_CACHE, client_kwargs=None, *, cache_disable=False)
Wrap download_file to download one or more files.
If multiple files are downloaded, it uses concurrent.futures to speed up the process.
Source code in wetterdienst/util/network.py
list_remote_files_fsspec(url, settings, ttl=CacheExpiry.FILEINDEX)
Create a listing of all files of a given path on the server.
The default ttl with CacheExpiry.FILEINDEX
is "5 minutes".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The URL to list files from. |
required |
settings
|
Settings
|
The settings to use for the listing. |
required |
ttl
|
CacheExpiry
|
The cache expiration time. |
FILEINDEX
|
Returns:
Type | Description |
---|---|
list[str]
|
A list of all files on the server |