Skip to content

module TopoPyScale.fetch_era5

Retrieve ecmwf data with cdsapi.

  • J. Fiddes, Origin implementation
  • S. Filhol adapted in 2021

Global Variables

  • var_surf_name_google
  • var_plev_name_google

function fetch_era5_google_from_zarr

fetch_era5_google_from_zarr(
    eraDir,
    startDate,
    endDate,
    lonW,
    latS,
    lonE,
    latN,
    plevels,
    bucket='gs://gcp-public-data-arco-era5/ar/full_37-1h-0p25deg-chunk-1.zarr-v3'
)

Function to download data from Zarr repository on Google Cloud Storage (https://github.com/google-research/arco-era5/tree/main)


function fetch_era5_google

fetch_era5_google(
    eraDir,
    startDate,
    endDate,
    lonW,
    latS,
    lonE,
    latN,
    plevels,
    step='3H',
    num_threads=1
)

function retrieve_era5

retrieve_era5(
    product,
    startDate,
    endDate,
    eraDir,
    latN,
    latS,
    lonE,
    lonW,
    step,
    num_threads=10,
    surf_plev='surf',
    plevels=None,
    realtime=False,
    output_format='netcdf',
    download_format='unarchived',
    new_CDS_API=True
)

Sets up era5 surface retrieval. * Creates list of year/month pairs to iterate through. * MARS retrievals are most efficient when subset by time. * Identifies preexisting downloads if restarted. * Calls api using parallel function.

Args:

  • product: "reanalysis" (HRES) or "ensemble_members" (EDA) startDate: endDate:
  • eraDir: directory to write output
  • latN: north latitude of bbox
  • latS: south latitude of bbox
  • lonE: easterly lon of bbox
  • lonW: westerly lon of bbox
  • step: timestep to use: 1, 3, 6
  • num_threads: number of threads to use for downloading data
  • surf_plev: download surface single level or pressure level product: 'surf' or 'plev'
  • output_format (str): default is "netcdf", can be "grib".
  • download_format (str): default "unarchived". Can be "zip"
  • new_CDS_API: flag to handle new formating of SURF files with the new CDS API (2024).

Returns: Monthly era surface files stored in disk.


function era5_request_surf

era5_request_surf(
    dataset,
    year,
    month,
    day,
    bbox,
    target,
    product,
    time,
    output_format='netcdf',
    download_format='unarchived'
)

CDS surface api call

Args:

  • dataset (str): copernicus dataset (era5)
  • year (str or list): year of interest
  • month (str or list): month of interest
  • bbox (list): bonding box in lat-lon
  • target (str): filename
  • product (str): type of model run. defaul: reanalysis
  • time (str or list): hours for which to download data
  • output_format (str): default is "netcdf", can be "grib".
  • download_format (str): default "unarchived". Can be "zip"

Returns: Store to disk dataset as indicated


function era5_request_plev

era5_request_plev(
    dataset,
    year,
    month,
    day,
    bbox,
    target,
    product,
    time,
    plevels,
    output_format='netcdf',
    download_format='unarchived'
)

CDS plevel api call

Args:

  • dataset (str): copernicus dataset (era5)
  • year (str or list): year of interest
  • month (str or list): month of interest
  • bbox (list): bonding box in lat-lon
  • target (str): filename
  • product (str): type of model run. defaul: reanalysis
  • time (str or list): hours to query
  • plevels (str or list): pressure levels to query
  • output_format (str): default is "netcdf", can be "grib".
  • download_format (str): default "unarchived". Can be "zip"

Returns: Store to disk dataset as indicated


function era5_realtime_surf

era5_realtime_surf(eraDir, dataset, bbox, product)

function era5_realtime_plev

era5_realtime_plev(eraDir, dataset, bbox, product, plevels)

function return_last_fullday

return_last_fullday()

TODO: NEED docstring and explanation


function grib2netcdf

grib2netcdf(gribname, outname=None)

Function to convert grib file to netcdf

Args:

  • gribname: filename fo grib file to convert

function process_SURF_file

process_SURF_file(wdir)

Function to unpack and repack as NETCDF data sent by the new CDS API, which sends a ZIP file as NETCDF file.

Args:

  • wdir: path of era5 data. Typically in TopoPyScale project it will be at: ./inputs/climate

function remap_CDSbeta

remap_CDSbeta(wdir)

Remapping of variable names from CDS beta to CDS legacy standard.

Args:

  • wdir: path of era5 data. Typically in TopoPyScale project it will be at: ./inputs/climate

function era5_request_surf_snowmapper

era5_request_surf_snowmapper(
    today,
    latN,
    latS,
    lonE,
    lonW,
    eraDir,
    output_format='netcdf'
)

CDS surface api call

Args:

  • dataset (str): copernicus dataset (era5)
  • today (datetime object): day to download
  • target (str): filename
  • product (str): type of model run. defaul: reanalysis
  • time (str or list): hours for which to download data
  • format (str): "grib" or "netcdf"

Returns: Store to disk dataset as indicated


function era5_request_plev_snowmapper

era5_request_plev_snowmapper(
    today,
    latN,
    latS,
    lonE,
    lonW,
    eraDir,
    plevels,
    output_format='netcdf'
)

CDS plevel api call

Args:

  • dataset (str): copernicus dataset (era5)
  • year (str or list): year of interest
  • month (str or list): month of interest
  • bbox (list): bonding box in lat-lon
  • target (str): filename
  • product (str): type of model run. defaul: reanalysis
  • time (str or list): hours to query
  • plevels (str or list): pressure levels to query

Returns: Store to disk dataset as indicated


This file was automatically generated via lazydocs.