From b595d0625d642666fa407ea9d0d772870ff515bb Mon Sep 17 00:00:00 2001 From: Steve Nesbitt Date: Tue, 5 Apr 2016 13:36:13 -0500 Subject: [PATCH 1/3] modified: xarray/backends/api.py --- xarray/backends/api.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xarray/backends/api.py b/xarray/backends/api.py index 7afd796fafa..e590580b476 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -188,15 +188,23 @@ def maybe_decode_store(store, lock=False): store = filename_or_obj elif isinstance(filename_or_obj, basestring): if filename_or_obj.endswith('.gz'): - if engine is not None and engine != 'scipy': - raise ValueError('can only read gzipped netCDF files with ' - "default engine or engine='scipy'") - # if the string ends with .gz, then gunzip and open as netcdf file + if is_remote_uri(filename_or_obj): + if engine !='netcdf4': + raise ValueError('can only read remote gzipped netCDF files ' + "with engine='netcdf4'") + else: + if engine is not None and engine != 'scipy': + raise ValueError('can only read gzipped netCDF files with ' + "default engine or engine='scipy'") + # if the string ends with .gz, then gunzip and open as netcdf file if sys.version_info[:2] < (2, 7): raise ValueError('reading a gzipped netCDF not ' 'supported on Python 2.6') try: - store = backends.ScipyDataStore(gzip.open(filename_or_obj)) + if engine == 'netcdf4': + store = backends.NetCDF4DataStore(filename_or_obj, group=group) + else: + store = backends.ScipyDataStore(gzip.open(filename_or_obj)) except TypeError as e: # TODO: gzipped loading only works with NetCDF3 files. if 'is not a valid NetCDF 3 file' in e.message: From 7a910ead3291e26176abd9b8c70f5acbdabef7a6 Mon Sep 17 00:00:00 2001 From: swnesbitt Date: Wed, 6 Apr 2016 11:53:41 -0500 Subject: [PATCH 2/3] modified: xarray/backends/api.py --- xarray/backends/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xarray/backends/api.py b/xarray/backends/api.py index e590580b476..dae7e777a59 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -195,7 +195,8 @@ def maybe_decode_store(store, lock=False): else: if engine is not None and engine != 'scipy': raise ValueError('can only read gzipped netCDF files with ' - "default engine or engine='scipy'") + "default engine, engine='pydap' or " + "engine='scipy'") # if the string ends with .gz, then gunzip and open as netcdf file if sys.version_info[:2] < (2, 7): raise ValueError('reading a gzipped netCDF not ' @@ -203,6 +204,8 @@ def maybe_decode_store(store, lock=False): try: if engine == 'netcdf4': store = backends.NetCDF4DataStore(filename_or_obj, group=group) + elif engine == 'pydap': + store = backends.PydapDataStore(filename_or_obj) else: store = backends.ScipyDataStore(gzip.open(filename_or_obj)) except TypeError as e: From a6ac501b894074264da014e1c15d63bb6efc4d09 Mon Sep 17 00:00:00 2001 From: swnesbitt Date: Wed, 6 Apr 2016 12:09:09 -0500 Subject: [PATCH 3/3] modified: xarray/backends/api.py --- xarray/backends/api.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xarray/backends/api.py b/xarray/backends/api.py index dae7e777a59..2e530b39f8b 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -189,14 +189,13 @@ def maybe_decode_store(store, lock=False): elif isinstance(filename_or_obj, basestring): if filename_or_obj.endswith('.gz'): if is_remote_uri(filename_or_obj): - if engine !='netcdf4': + if engine !='netcdf4' and engine !='pydap': raise ValueError('can only read remote gzipped netCDF files ' - "with engine='netcdf4'") + "with engine='netcdf4' or 'pydap'") else: if engine is not None and engine != 'scipy': raise ValueError('can only read gzipped netCDF files with ' - "default engine, engine='pydap' or " - "engine='scipy'") + "default engine, engine='scipy'") # if the string ends with .gz, then gunzip and open as netcdf file if sys.version_info[:2] < (2, 7): raise ValueError('reading a gzipped netCDF not '