netcdf4-python icon indicating copy to clipboard operation
netcdf4-python copied to clipboard

How can I use a dataset with pyfilesystem2

Open ReimarBauer opened this issue 8 years ago • 1 comments

Hi all

where have I to look at for accessing netCDF files by the pyfilesystem2 approach http://pyfilesystem2.readthedocs.io/en/latest/

By this idea I could access files over many protocols on various storage platforms by just defining an open_fs string.

e.g.

>>> from fs import open_fs
>>> storage_fs = open_fs(u'~/')
>>> # storage_fs = open_fs(u"ssh://[user[:password]@]host[:port]/[directory]")
>>> # storage_fs = open_fs(u"ftp://ftp.example.org/pub")
>>> fid = storage_fs.open(u'data.nc', 'r')
>>> with storage_fs.open(u'data.nc', 'r') as fid:

How can I open a netCDF file by passing in the fid ?

regards Reimar

ReimarBauer avatar Oct 18 '17 09:10 ReimarBauer

I don't think you can. netCDF4-python is just wrapping the netCDF-C library. This requires either a filename or a buffer containing the contents of the file in memory.

dopplershift avatar Oct 18 '17 16:10 dopplershift