scmdata.database.backends.netcdf
Database backend for handling local files stored as NetCDF
NetCDFDatabaseBackend
- class NetCDFDatabaseBackend(**kwargs)[source]
Bases:
BaseDatabaseBackend
Database backend for handling local files stored as NetCDF
- get_key(sr)[source]
Get key where the data will be stored
The key is the root directory joined with the other information provided. The filepath is also cleaned to remove spaces and special characters.
- Parameters:
sr (
scmdata.ScmRun
) – Data to save- Raises:
ValueError – If non-unique metadata is found for each of
self.kwargs["levels"]
If any metadata end with ‘.’KeyError – If missing metadata is found for each of
self.kwargs["levels"]
- Returns:
str – Path in which to save the data without spaces or special characters
- save(sr)[source]
Save a ScmRun to the database
The dataset should not contain any duplicate metadata for the database levels
- Parameters:
sr (
scmdata.ScmRun
) – Data to save- Raises:
ValueError – If duplicate metadata are present for the requested database levels
KeyError – If metadata for the requested database levels are not found
- Returns:
str – Key where the data is saved