use netCDF4 dataset by PyFilesystem2 as zip files

Issue #398 new
Reimar Bauer created an issue

netCDF4 yet has no option to manage it by PyFilesystem2 directly. This nice idea was send to me on the ML.

We maybe can use this on demodata for our tests. The files should be accessible by the MemoryFS().

This may enable the full tests on the build CIs

from Ales Kuchar netcdf4 ML

@ReimarBauer if still interested, here is the solution where I used pyfilesystem2 to read zipped netcdf files:

from fs.zipfs import ZipFS
import xarray as xr
import netCDF4

new_zip = ZipFS("results.zip")
bytes = new_zip.getbytes(u'one_file_within_zip.nc')
nc4_ds = netCDF4.Dataset('name',mode = 'r', memory=bytes)
store = xr.backends.NetCDF4DataStore(nc4_ds)
ds = xr.open_dataset(store)

Comments (7)

  1. Log in to comment