Skip to content
  • Anne Hommelberg's avatar
    Add NetCDF import and export support · fd9f0da2
    Anne Hommelberg authored
    NetCDF is a popular file format in environmental forecasting to provide
    large amounts of (ensemble) data in binary format. The NetCDF4
    specification uses HDF5 under the hood, enforcing a simplified layout.
    Delft-FEWS also support NetCDF(-CF), and reading/writing it can be much
    faster than PI-XML.
    
    This commit adds support for NetCDF files. The data format is provided
    in data/netcdf.py, just like CSV and PI support. On top of this data
    wrapper, there is a NetCDFMixin implementing the read/write methods of
    the generic IOMixin base class.
    
    There are specific requirements to the NetCDF (.nc) files to match
    Delft-FEWS (and the NetCDF-CF standard):
    
    - The station identifier variable in the .nc file should have a
      "cf_role" attribute with value "timeseries_id"
    - The time variable should have an axis attribute with value "T" and
      "standard_name" attribute with value "time"
    - Members in an ensemble are indexed with coordinate variable
      "realization".
    
    Note that when only a single ensemble member is to be read the use of
    "realization" is optional.
    
    NetCDF import has been added as _optional_ functionality. We are not yet
    sure if we want to force all users to install all dependencies for all
    (future) IO formats, even if they do not need them. As it stands, "pip
    install rtc-tools" will therefore not install the netCDF4 requirement.
    Instead, one can either install the "netCDF4" dependency manually, or
    use "pip install rtc-tools[netcdf]" or "pip install rtc-tools[all]".
    
    Closes #1007
    fd9f0da2