|
2 | 2 |
|
3 | 3 | from deepsensor.plot import extent_str_to_tuple |
4 | 4 |
|
5 | | -from get_station_data import ghcnd |
6 | 5 | import urllib.request |
7 | 6 | import multiprocessing |
8 | 7 | from functools import partial |
@@ -31,6 +30,11 @@ def get_ghcnd_station_data( |
31 | 30 | into a pandas DataFrame. |
32 | 31 | Source: https://www.ncei.noaa.gov/products/land-based-station/global-historical-climatology-network-daily |
33 | 32 |
|
| 33 | + .. note:: |
| 34 | + Requires the `scotthosking/get-station-data` repository to be installed |
| 35 | + manually in your Python environment with: |
| 36 | + `pip install git+https://github.com/scott-hosking/get-station-data.git` |
| 37 | +
|
34 | 38 | .. note:: |
35 | 39 | Example key variable IDs: |
36 | 40 | - ``"TAVG"``: Average temperature (degrees Celsius) |
@@ -78,6 +82,12 @@ def get_ghcnd_station_data( |
78 | 82 | Station data with indexes ``time``, ``lat``, ``lon``, ``station`` and columns |
79 | 83 | ``var1``, ``var2``, etc. |
80 | 84 | """ |
| 85 | + try: |
| 86 | + from get_station_data import ghcnd |
| 87 | + except ImportError: |
| 88 | + raise ImportError( |
| 89 | + "Must manually pip-install get-station-data with: `pip install git+https://github.com/scott-hosking/get-station-data.git`" |
| 90 | + ) |
81 | 91 | if not cache: |
82 | 92 | cache_dir = None |
83 | 93 | memory = Memory(cache_dir, verbose=0) |
@@ -301,7 +311,7 @@ def _get_era5_reanalysis_data_parallel( |
301 | 311 | extent="global", |
302 | 312 | cache=False, |
303 | 313 | cache_dir=".datacache", |
304 | | -): |
| 314 | +): # pragma: no cover |
305 | 315 | """ |
306 | 316 | Helper function for downloading ERA5 data in parallel with caching. |
307 | 317 |
|
@@ -359,7 +369,7 @@ def get_gldas_land_mask( |
359 | 369 | verbose: bool = False, |
360 | 370 | cache: bool = False, |
361 | 371 | cache_dir: str = ".datacache", |
362 | | -) -> xr.DataArray: |
| 372 | +) -> xr.DataArray: # pragma: no cover |
363 | 373 | """ |
364 | 374 | Get GLDAS land mask at 0.25 degree resolution. |
365 | 375 | Source: https://ldas.gsfc.nasa.gov/gldas/vegetation-class-mask |
@@ -439,7 +449,7 @@ def get_earthenv_auxiliary_data( |
439 | 449 | verbose: bool = False, |
440 | 450 | cache: bool = False, |
441 | 451 | cache_dir: str = ".datacache", |
442 | | -) -> xr.Dataset: |
| 452 | +) -> xr.Dataset: # pragma: no cover |
443 | 453 | """ |
444 | 454 | Download global static auxiliary data from EarthEnv into an xarray DataArray. |
445 | 455 | See: https://www.earthenv.org/topography |
@@ -558,7 +568,7 @@ def _get_auxiliary_data_cached( |
558 | 568 | return _get_auxiliary_data_cached(var_IDs, extent, resolution, verbose) |
559 | 569 |
|
560 | 570 |
|
561 | | -if __name__ == "__main__": |
| 571 | +if __name__ == "__main__": # pragma: no cover |
562 | 572 | # Using the same settings allows use to use pre-downloaded cached data |
563 | 573 | data_range = ("2015-06-25", "2015-06-30") |
564 | 574 | extent = "europe" |
|
0 commit comments