tsdat.io.writers
¶
Classes¶
Converts a xr.Dataset object to a pandas DataFrame and saves the result to a csv |
|
Thin wrapper around xarray's Dataset.to_netcdf() function for saving a dataset to a |
|
Writes the dataset to a parquet file. |
|
Wrapper around xarray's Dataset.to_netcdf() function for saving a dataset to a |
|
Writes the dataset to a basic zarr archive. |
- class tsdat.io.writers.CSVWriter[source]¶
Bases:
tsdat.io.base.FileWriter
Converts a xr.Dataset object to a pandas DataFrame and saves the result to a csv file using pd.DataFrame.to_csv(). Properties under the to_csv_kwargs parameter are passed to pd.DataFrame.to_csv() as keyword arguments.
Class Methods
Writes the dataset to the provided filepath.
Method Descriptions
- write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None, **kwargs: Any) None [source]¶
Writes the dataset to the provided filepath.
This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.
- Parameters
dataset (xr.Dataset) – The dataset to save.
filepath (Optional[Path]) – The path to the file to save.
- class tsdat.io.writers.NetCDFWriter[source]¶
Bases:
tsdat.io.base.FileWriter
Thin wrapper around xarray’s Dataset.to_netcdf() function for saving a dataset to a netCDF file. Properties under the to_netcdf_kwargs parameter will be passed to Dataset.to_netcdf() as keyword arguments.
File compression is used by default to save disk space. To disable compression set the compression_level parameter to 0.
- class Parameters[source]¶
Bases:
pydantic.BaseModel
- compression_level :int = 1[source]¶
The level of compression to use (0-9). Set to 0 to not use compression.
- to_netcdf_kwargs :Dict[str, Any][source]¶
Keyword arguments passed directly to xr.Dataset.to_netcdf().
Class Methods
Writes the dataset to the provided filepath.
Method Descriptions
- write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None, **kwargs: Any) None [source]¶
Writes the dataset to the provided filepath.
This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.
- Parameters
dataset (xr.Dataset) – The dataset to save.
filepath (Optional[Path]) – The path to the file to save.
- class tsdat.io.writers.ParquetWriter[source]¶
Bases:
tsdat.io.base.FileWriter
Writes the dataset to a parquet file.
Converts a xr.Dataset object to a pandas DataFrame and saves the result to a parquet file using pd.DataFrame.to_parquet(). Properties under the to_parquet_kwargs parameter are passed to pd.DataFrame.to_parquet() as keyword arguments.
Class Methods
Writes the dataset to the provided filepath.
Method Descriptions
- write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None, **kwargs: Any) None [source]¶
Writes the dataset to the provided filepath.
This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.
- Parameters
dataset (xr.Dataset) – The dataset to save.
filepath (Optional[Path]) – The path to the file to save.
- class tsdat.io.writers.SplitNetCDFWriter[source]¶
Bases:
NetCDFWriter
Wrapper around xarray’s Dataset.to_netcdf() function for saving a dataset to a netCDF file based on a particular time interval, and is an extension of the NetCDFWriter. Files are split (sliced) via a time interval specified in two parts, time_interval a literal value, and a time_unit character (year: “Y”, month: “M”, day: “D”, hour: “h”, minute: “m”, second: “s”).
Properties under the to_netcdf_kwargs parameter will be passed to Dataset.to_netcdf() as keyword arguments. File compression is used by default to save disk space. To disable compression set the compression_level parameter to 0.
- class Parameters[source]¶
Bases:
NetCDFWriter
Class Methods
Writes the dataset to the provided filepath.
Method Descriptions
- write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None, **kwargs: Any) None [source]¶
Writes the dataset to the provided filepath.
This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.
- Parameters
dataset (xr.Dataset) – The dataset to save.
filepath (Optional[Path]) – The path to the file to save.
- class tsdat.io.writers.ZarrWriter[source]¶
Bases:
tsdat.io.base.FileWriter
Writes the dataset to a basic zarr archive.
Advanced features such as specifying the chunk size or writing the zarr archive in AWS S3 will be implemented later.
Class Methods
Writes the dataset to the provided filepath.
Method Descriptions
- write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None, **kwargs: Any) None [source]¶
Writes the dataset to the provided filepath.
This method is typically called by the tsdat storage API, which will be responsible for providing the filepath, including the file extension.
- Parameters
dataset (xr.Dataset) – The dataset to save.
filepath (Optional[Path]) – The path to the file to save.