unifhy.DataSet.load_from_file

DataSet.load_from_file(files, name_mapping=None, select=None)

Append to the DataSet the variables that are contained in the file(s) provided.

Parameters
files: (sequence of) str

A string or sequence of strings providing the netCDF file names or directory names containing netCDF files from which to read the variables.

Parameter example:

files='tests/data/sciencish_driving_data_daily.nc'

Parameter example:

files=['tests/data/sciencish_driving_data_daily.nc',
       'tests/data/sciencish_ancillary_data.nc'
select: (sequence of) str, optional

A string or sequence of strings providing the identities of the variables to read in the netCDF file. By default, all variables in the netCDF file are read.

Parameter example:

select=['rainfall_flux', 'snowfall_flux']
name_mapping: dict, optional

A dictionary with the Field identities as keys and the desired new name variables as values. If a Field is read from the netCDF file, and its identity is not a key in name_mapping (if provided), its ‘standard_name’ attribute is used instead.

Examples

>>> ds = DataSet()
>>> print(ds)
DataSet{ }
>>> ds.load_from_file(
...     files='data/sciencish_driving_data_daily.nc',
...     select='snowfall_flux'
... )
>>> print(ds)
DataSet{
    snowfall_flux(time(6), atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) kg m-2 s-1
}
>>> ds.load_from_file(
...     files='data/sciencish_driving_data_daily.nc',
...     select=('rainfall_flux',)
... )
>>> print(ds)
DataSet{
    rainfall_flux(time(6), atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) kg m-2 s-1
    snowfall_flux(time(6), atmosphere_hybrid_height_coordinate(1), grid_latitude(10), grid_longitude(9)) kg m-2 s-1
}