radarx.io.aws_data.download_file#

radarx.io.aws_data.download_file(bucket, file_key, save_dir, anonymous=True)[source]#

Download a file from S3.

Parameters:
  • bucket (str) – Name of the AWS S3 bucket.

  • file_key (str) – Key of the file to download.

  • save_dir (str) – Directory to save the downloaded file.

  • anonymous (bool, optional) – If True, uses anonymous access. Default is True.

Returns:

str – Path to the downloaded file.

Notes

When the environment variable RADARX_DOWNLOAD_CACHE names a directory, every downloaded file is also stored there (as <bucket>/<key>) and later calls for the same key copy it instead of downloading it again. The test suite and the notebooks use this in CI, where many of them fetch the same volumes.

Examples

Download a NEXRAD Level II file:

>>> file_path = download_file(
...     "unidata-nexrad-level2",
...     "2016/10/06/KAMX/KAMX20161006_170414_V06",
...     "./downloads"
... )
>>> print(f"File downloaded to: {file_path}")

Download an MRMS file:

>>> file_path = download_file(
...     "noaa-mrms-pds",
...     "CONUS/ReflectivityAtLowestAltitude_00.50/2016/10/06/" +
        "ReflectivityAtLowestAltitude_00.50_20161006-1700.grib2.gz",
...     "./downloads"
... )
>>> print(f"File downloaded to: {file_path}")