tsdat.io.writers

Classes

CSVWriter

Converts a xr.Dataset object to a pandas DataFrame and saves the result to a csv

NetCDFWriter

Thin wrapper around xarray's Dataset.to_netcdf() function for saving a dataset to a

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 Parameters[source]

Bases: pydantic.BaseModel

dim_order :Optional[List[str]][source]
to_csv_kwargs :Dict[str, Any][source]
file_extension :str = csv[source]
parameters :CSVWriter.Parameters[source]

Class Methods

write

Writes the dataset to the provided filepath.

Method Descriptions

write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None) 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 use_compression parameter to False.

class Parameters[source]

Bases: pydantic.BaseModel

compression_kwargs :Dict[str, Any][source]
to_netcdf_kwargs :Dict[str, Any][source]
use_compression :bool = True[source]
file_extension :str = nc[source]
parameters :NetCDFWriter.Parameters[source]

Class Methods

write

Writes the dataset to the provided filepath.

Method Descriptions

write(self, dataset: xarray.Dataset, filepath: Optional[pathlib.Path] = None) 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.