From 047063b32a5a3fabbe670012a5cd0cf1d8176007 Mon Sep 17 00:00:00 2001 From: dcherian Date: Wed, 29 May 2019 09:18:40 -0600 Subject: [PATCH] Fix io.rst. --- doc/io.rst | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/io.rst b/doc/io.rst index 66085d4a5aa..cfa921e3220 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -49,6 +49,11 @@ We can save a Dataset to disk using the .. ipython:: python + ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))}, + coords={'x': [10, 20, 30, 40], + 'y': pd.date_range('2000-01-01', periods=5), + 'z': ('x', list('abcd'))}) + ds.to_netcdf('saved_on_disk.nc') By default, the file is saved as netCDF4 (assuming netCDF4-Python is @@ -59,7 +64,7 @@ the ``format`` and ``engine`` arguments. Using the `h5netcdf `_ package by passing ``engine='h5netcdf'`` to :py:meth:`~xarray.open_dataset` can - be quicker than the default ``engine='netcdf4'`` that uses the + sometimes be quicker than the default ``engine='netcdf4'`` that uses the `netCDF4 `_ package. @@ -171,8 +176,6 @@ will remove encoding information. :suppress: ds_disk.close() - import os - os.remove('saved_on_disk.nc') .. _io.netcdf.writing_encoded: @@ -459,11 +462,6 @@ module: import pickle - ds = xr.Dataset({'foo': (('x', 'y'), np.random.rand(4, 5))}, - coords={'x': [10, 20, 30, 40], - 'y': pd.date_range('2000-01-01', periods=5), - 'z': ('x', list('abcd'))}) - # use the highest protocol (-1) because it is way faster than the default # text based pickle format pkl = pickle.dumps(ds, protocol=-1) @@ -523,6 +521,12 @@ To export just the dataset schema, without the data itself, use the This can be useful for generating indices of dataset contents to expose to search indices or other automated data discovery tools. +.. ipython:: python + :suppress: + + import os + os.remove('saved_on_disk.nc') + .. _io.rasterio: Rasterio