New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read a gzipped netcdf file #239
Conversation
# If the initialization nc is a string and | ||
if nc.endswith('.gz'): | ||
# the name ends with .gz, then gunzip and open as netcdf file | ||
# FIXME: does ScipyDataStore handle NetCDF4 files? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be fine to only support gzipped NetCDF3 since NetCFD4 allows for internal compression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScipyDataStore only does netCDF3.
It would be nice to support this for netCDF4, too, but given that the Python netCDF4 library cannot handle file objects (it can only take paths), I don't see any workable way to make that happen.
This looks great, but it needs a test. Take a look at https://github.com/xray/xray/blob/master/xray/test/test_backends.py for some examples. |
if nc.endswith('.gz'): | ||
# the name ends with .gz, then gunzip and open as netcdf file | ||
# FIXME: does ScipyDataStore handle NetCDF4 files? | ||
store = backends.ScipyDataStore(gzip.open(nc), *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this won't work on Python 2.6. That's OK, but we should give an informative error message:
if sys.version_info[:2] < (2, 7):
raise ValueError('reading a gzipped netCDF not supported on Python 2.6')
Looks good to me! Next time, it's probably a good idea to work in another branch rather than master. |
No description provided.