tsdat.io.filehandlers.netcdf_handler
¶
Classes¶
FileHandler to read from and write to netCDF files. Takes a number of |
|
FileHandler to read from and write to netCDF files. Takes a number of |
-
class
tsdat.io.filehandlers.netcdf_handler.
NetCdfHandler
(parameters: Union[Dict, None] = None)[source]¶ Bases:
tsdat.io.filehandlers.file_handlers.AbstractFileHandler
FileHandler to read from and write to netCDF files. Takes a number of parameters that are passed in from the storage config file. Parameters specified in the config file should follow the following example:
parameters: write: to_netcdf: # Parameters here will be passed to xr.Dataset.to_netcdf() read: load_dataset: # Parameters here will be passed to xr.load_dataset()
- Parameters
parameters (Dict, optional) – Parameters that were passed to the FileHandler when it was registered in the storage config file, defaults to {}.
Class Methods
Reads in the given file and converts it into an Xarray dataset for
Saves the given dataset to a netCDF file.
Method Descriptions
-
read
(self, filename: str, **kwargs) → xarray.Dataset[source]¶ Reads in the given file and converts it into an Xarray dataset for use in the pipeline.
- Parameters
filename (str) – The path to the file to read in.
- Returns
A xr.Dataset object.
- Return type
xr.Dataset
-
write
(self, ds: xarray.Dataset, filename: str, config: tsdat.config.Config = None, **kwargs) → None[source]¶ Saves the given dataset to a netCDF file.
- Parameters
ds (xr.Dataset) – The dataset to save.
filename (str) – The path to where the file should be written to.
config (Config, optional) – Optional Config object, defaults to None
-
class
tsdat.io.filehandlers.netcdf_handler.
SplitNetCdfHandler
(parameters: Union[Dict, None] = None)[source]¶ Bases:
NetCdfHandler
FileHandler to read from and write to netCDF files. Takes a number of parameters that are passed in from the storage config file. Parameters specified in the config file should follow the following example:
parameters: write: to_netcdf: # Parameters here will be passed to xr.Dataset.to_netcdf() read: load_dataset: # Parameters here will be passed to xr.load_dataset()
- Parameters
parameters (Dict, optional) – Parameters that were passed to the FileHandler when it was registered in the storage config file, defaults to {}.
Class Methods
Reads in the given file and converts it into an Xarray dataset for
Saves the given dataset to netCDF file(s) based on the ‘time_interval’
Method Descriptions
-
abstract
read
(self, filename: str, **kwargs)[source]¶ Reads in the given file and converts it into an Xarray dataset for use in the pipeline.
- Parameters
filename (str) – The path to the file to read in.
- Returns
A xr.Dataset object.
- Return type
xr.Dataset
-
write
(self, ds: xarray.Dataset, filename: str, config: tsdat.config.Config = None, **kwargs) → None[source]¶ Saves the given dataset to netCDF file(s) based on the ‘time_interval’ and ‘time_unit’ config parameters.
- Parameters
ds (xr.Dataset) – The dataset to save.
filename (str) – The path to where the file should be written to.
config (Config, optional) – Optional Config object, defaults to None