Skip to content
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

Merged
merged 3 commits into from Sep 23, 2014
Merged

Read a gzipped netcdf file #239

merged 3 commits into from Sep 23, 2014

Conversation

lakshmanok
Copy link

No description provided.

# 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?
Copy link
Contributor

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.

Copy link
Member

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.

@shoyer
Copy link
Member

shoyer commented Sep 23, 2014

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)
Copy link
Member

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')

@shoyer shoyer added this to the 0.3.1 milestone Sep 23, 2014
@shoyer
Copy link
Member

shoyer commented Sep 23, 2014

Looks good to me!

Next time, it's probably a good idea to work in another branch rather than master.

shoyer added a commit that referenced this pull request Sep 23, 2014
Read a gzipped netcdf file
@shoyer shoyer merged commit b69fe0d into pydata:master Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants