Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
#153 ODP datasource, open_dataset method, removed protocol support
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof (Chris) Bernat committed Apr 10, 2017
1 parent a24b4c6 commit 72245af
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions cate/ds/esa_cci_odp.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,15 +548,8 @@ def open_dataset(self,
var_names: VarNamesLike.TYPE = None,
protocol: str = None) -> Any:
time_range = TimeRangeLike.convert(time_range) if time_range else None
if region:
region = PolygonLike.convert(region)
if var_names:
var_names = VarNamesLike.convert(var_names)
if protocol is None:
protocol = _ODP_PROTOCOL_HTTP
if protocol not in self.protocols:
raise ValueError('Protocol \'{}\' is not supported.'
.format(protocol))
region = PolygonLike.convert(region) if region else None
var_names = VarNamesLike.convert(var_names) if var_names else None

selected_file_list = self._find_files(time_range)
if not selected_file_list:
Expand All @@ -565,15 +558,7 @@ def open_dataset(self,
msg += ' in given time range {}'.format(TimeRangeLike.format(time_range))
raise IOError(msg)

files = []
if protocol == _ODP_PROTOCOL_OPENDAP:
files = [file_rec[4][protocol].replace('.html', '') for file_rec in selected_file_list]
elif protocol == _ODP_PROTOCOL_HTTP:
dataset_dir = self.local_dataset_dir()
files = [os.path.join(dataset_dir, file_rec[0]) for file_rec in selected_file_list]
for file in files:
if not os.path.exists(file):
raise IOError('Missing local data files, consider synchronizing the dataset first.')
files = self._get_urls_list(selected_file_list, _ODP_PROTOCOL_OPENDAP)
try:
ds = open_xarray_dataset(files)
if region:
Expand Down

0 comments on commit 72245af

Please sign in to comment.