Skip to content

Commit

Permalink
use single value search for time
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lat1le committed Nov 22, 2016
1 parent f599352 commit 3f5b523
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions datacube/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, index=None, product=None, geopolygon=None, like=None, **kwarg
self.search['time'] = _time_to_search_dims(
(pandas_to_datetime(time_coord.values[0]).to_pydatetime(),
pandas_to_datetime(time_coord.values[-1]).to_pydatetime()
+ datetime.timedelta(milliseconds=1))
+ datetime.timedelta(milliseconds=1)) # TODO: inclusive time searches
)

@property
Expand Down Expand Up @@ -277,11 +277,10 @@ def _time_to_search_dims(time_range):
if hasattr(time_range, '__iter__') and len(time_range) == 2:
time_range = Range(_to_datetime(time_range[0]), _to_datetime(time_range[1]))
if time_range[0] == time_range[1]:
return Range(time_range[0], time_range[0] + datetime.timedelta(milliseconds=1))
return time_range[0]
return time_range
else:
single_query_time = _to_datetime(time_range)
return Range(single_query_time, single_query_time + datetime.timedelta(milliseconds=1))
return _to_datetime(time_range)


def _convert_to_solar_time(utc, longitude):
Expand Down
3 changes: 3 additions & 0 deletions integration_tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def check_open_with_dc(index):
data_array = dc.load(product='ls5_nbar_albers', measurements=['blue'], stack='variable')
assert data_array.shape

data_array = dc.load(product='ls5_nbar_albers', measurements=['blue'], time='1992-03-23T23:14:25.500000')
assert data_array['blue'].shape

data_array = dc.load(product='ls5_nbar_albers', latitude=(-35, -36), longitude=(149, 150), stack='variable')
assert data_array.ndim == 4
assert 'variable' in data_array.dims
Expand Down

0 comments on commit 3f5b523

Please sign in to comment.