metobs_toolkit.station.Station.to_netcdf#
- Station.to_netcdf(filepath: str | PathLike | None = None, overwrite: bool = False, **kwargs) None[source]#
Save the Station as a netCDF file.
This method converts the Station to an xarray Dataset and saves it as a netCDF file.
- Parameters:
filepath (str or path-like or None, optional) – Path where the netCDF file will be saved. If None, defaults to ‘<stationname>_station.nc’ in the current working directory. Default is None.
overwrite (bool, optional) – If True, overwrites existing file. Default is False.
**kwargs – Additional keyword arguments passed to xarray.Dataset.to_netcdf(). Common options include: - format : str, netCDF format (‘NETCDF4’, ‘NETCDF4_CLASSIC’, ‘NETCDF3_64BIT’, ‘NETCDF3_CLASSIC’) - engine : str, netCDF engine to use (‘netcdf4’, ‘scipy’, ‘h5netcdf’) - encoding : dict, variable-specific encoding parameters
Examples
>>> station.to_netcdf('station_data.nc') >>> station.to_netcdf('data.nc', format='NETCDF4_CLASSIC')
Notes
This method is an export method. It is not possible to convert a netCDF to a metobs_toolkit.Station object.
The method uses the ‘netcdf4’ engine by default for better Unicode string compatibility. The scipy engine has limitations with certain Unicode datatypes.