Skip to content

download_era5_uncertainty

ERA5 Uncertainty Download (CLIMATE-22 gap-fill)

Downloads whole-year ERA5 reanalysis and ensemble_spread 2m temperature files from the Copernicus CDS, matching the layout Katrin Burkart produced by hand in /ihme/erf/ERA5/katrin_download_20240208/ for 2022/2023:

era5_{product_type}_{variable}_{year}.nc   (one file per whole year)

This fills the 2024/2025 gap that GBD temperature PAF work depends on. It is a standalone gap-fill: the ensemble_spread product is not (yet) consumed by the rest of this repo's pipeline, which only uses reanalysis mean temperature.

Notes / gotchas baked in below: * The ensemble products only exist on reanalysis-era5-single-levels (0.25° HRES / ~0.5° EDA), never on reanalysis-era5-land. * Both products are pulled 3-hourly to match the canonical GBD download and Katrin's 2022/2023 files. ensemble_spread (the EDA) is only 3-hourly; reanalysis (HRES) is subsampled from hourly to the same 3-hourly axis. * Credentials come from the caller's ~/.cdsapirc (cdsapi.Client() with no args), so no dependency on the shared per-user copernicus.yaml keyring (which does not carry every user).

download_era5_uncertainty(era5_variable: str, output_dir: str, queue: str, dry_run: bool) -> None

Download 2024/2025 ERA5 reanalysis + ensemble_spread (CLIMATE-22 gap-fill).

Source code in src/climate_data/special/download_era5_uncertainty.py
@click.command()
@clio.with_era5_variable()
@clio.with_output_directory(DEFAULT_OUTPUT_DIR)
@clio.with_queue()
@clio.with_dry_run()
def download_era5_uncertainty(
    era5_variable: str,
    output_dir: str,
    queue: str,
    dry_run: bool,
) -> None:
    """Download 2024/2025 ERA5 reanalysis + ensemble_spread (CLIMATE-22 gap-fill)."""
    node_args = {
        "year": ERA5_UNCERTAINTY_YEARS,
        "product-type": ERA5_PRODUCT_TYPES,
    }

    run_parallel_maybe_dry_run(
        runner="cdtask special",
        task_name="download_era5_uncertainty",
        node_args=node_args,
        task_args={
            "era5-variable": era5_variable,
            "output-dir": output_dir,
        },
        task_resources={
            "queue": queue,
            "cores": 1,
            "memory": "20G",
            "runtime": "720m",
            "project": "proj_rapidresponse",
        },
        max_attempts=1,
        dry_run=dry_run,
    )

download_era5_uncertainty_task(year: str, product_type: str, era5_variable: str, output_dir: str) -> None

Download one whole-year ERA5 file (single year, single product type).

Source code in src/climate_data/special/download_era5_uncertainty.py
@click.command()
@clio.with_year(years=cdc.HISTORY_YEARS)
@click.option(
    "--product-type",
    required=True,
    type=click.Choice(ERA5_PRODUCT_TYPES),
    help="ERA5 product type to download.",
)
@clio.with_era5_variable()
@clio.with_output_directory(DEFAULT_OUTPUT_DIR)
def download_era5_uncertainty_task(
    year: str,
    product_type: str,
    era5_variable: str,
    output_dir: str,
) -> None:
    """Download one whole-year ERA5 file (single year, single product type)."""
    download_era5_uncertainty_main(year, product_type, era5_variable, output_dir)