[GitHub] fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to support datainbounds algorithm

2018-03-23 Thread GitBox
fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to 
support datainbounds algorithm
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/12#discussion_r176896255
 
 

 ##
 File path: client/nexuscli/nexuscli.py
 ##
 @@ -230,7 +229,7 @@ def data_in_bounds(dataset, bounding_box, start_datetime, 
end_datetime, paramete
 __parameter__ Name of the dataset as a String  
 
 Review comment:
   Update description of the `parameter` parameter


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to support datainbounds algorithm

2018-03-14 Thread GitBox
fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to 
support datainbounds algorithm
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/12#discussion_r174620542
 
 

 ##
 File path: client/nexuscli/nexuscli.py
 ##
 @@ -207,3 +217,59 @@ def time_series(datasets, bounding_box, start_datetime, 
end_datetime, spark=Fals
 )
 
 return time_series_result
+
+
+def data_in_bounds(dataset, bounding_box, start_datetime, end_datetime, 
parameter, metadata_filter):
 
 Review comment:
   Should we just name the method subset?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to support datainbounds algorithm

2018-03-14 Thread GitBox
fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to 
support datainbounds algorithm
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/12#discussion_r174625255
 
 

 ##
 File path: client/nexuscli/nexuscli.py
 ##
 @@ -207,3 +217,59 @@ def time_series(datasets, bounding_box, start_datetime, 
end_datetime, spark=Fals
 )
 
 return time_series_result
+
+
+def data_in_bounds(dataset, bounding_box, start_datetime, end_datetime, 
parameter, metadata_filter):
+"""
+Fetches point values for a given dataset and geographical area or metadata 
criteria and time range.
+
+__dataset__ Name of the dataset as a String  
+__bounding_box__ Bounding box for area of interest as a 
`shapely.geometry.polygon.Polygon`  
+__start_datetime__ Start time as a `datetime.datetime`  
+__end_datetime__ End time as a `datetime.datetime`  
+__parameter__ Name of the dataset as a String  
+__metadata_filter__ List of key:value String metadata criteria  
+
+__return__ List of `nexuscli.nexuscli.TimeSeries` namedtuples
+"""
+url = "{}/datainbounds?".format(target)
+
+params = {
+'ds': dataset,
+'startTime': start_datetime.strftime(ISO_FORMAT),
+'endTime': end_datetime.strftime(ISO_FORMAT),
+'parameter': parameter,
+'metadataFilter': metadata_filter,
+}
+if bounding_box:
+params['b'] = ','.join(str(b) for b in bounding_box.bounds)
+
+response = session.get(url, params=params)
+response.raise_for_status()
+response = response.json()
+
+data = np.array(response['data']).flatten()
+
+assert len(data) > 0, "No data found in {} between {} and {} for Datasets 
{}.".format(bounding_box.wkt if bounding_box is not None else metadata_filter,
+   
   start_datetime.strftime(
+   
   ISO_FORMAT),
+   
   end_datetime.strftime(
+   
   ISO_FORMAT),
+   
   dataset)
+
+variable_values = {}
+for variable in data[0]['data'][0].keys():
+variable_values[variable] = np.array([d['data'][0][variable] for d in 
data])
+
+subset_result = []
+subset_result.append(
 
 Review comment:
   This doesn't seem quite right. I think the result of a subset should be a 
list of points. Arranging the time/data into np arrays worked for the Time 
Series code because the nature of Time Series is 1 value per timestep; but I 
don't think you can rely on that here. Thoughts?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to support datainbounds algorithm

2018-03-14 Thread GitBox
fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to 
support datainbounds algorithm
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/12#discussion_r174621731
 
 

 ##
 File path: client/nexuscli/nexuscli.py
 ##
 @@ -207,3 +217,59 @@ def time_series(datasets, bounding_box, start_datetime, 
end_datetime, spark=Fals
 )
 
 return time_series_result
+
+
+def data_in_bounds(dataset, bounding_box, start_datetime, end_datetime, 
parameter, metadata_filter):
+"""
+Fetches point values for a given dataset and geographical area or metadata 
criteria and time range.
+
+__dataset__ Name of the dataset as a String  
+__bounding_box__ Bounding box for area of interest as a 
`shapely.geometry.polygon.Polygon`  
+__start_datetime__ Start time as a `datetime.datetime`  
+__end_datetime__ End time as a `datetime.datetime`  
+__parameter__ Name of the dataset as a String  
+__metadata_filter__ List of key:value String metadata criteria  
+
+__return__ List of `nexuscli.nexuscli.TimeSeries` namedtuples
+"""
+url = "{}/datainbounds?".format(target)
+
+params = {
+'ds': dataset,
+'startTime': start_datetime.strftime(ISO_FORMAT),
+'endTime': end_datetime.strftime(ISO_FORMAT),
+'parameter': parameter,
+'metadataFilter': metadata_filter,
+}
+if bounding_box:
+params['b'] = ','.join(str(b) for b in bounding_box.bounds)
+
+response = session.get(url, params=params)
+response.raise_for_status()
+response = response.json()
+
+data = np.array(response['data']).flatten()
+
+assert len(data) > 0, "No data found in {} between {} and {} for Datasets 
{}.".format(bounding_box.wkt if bounding_box is not None else metadata_filter,
 
 Review comment:
   Looks like the logic as implemented will allow
   
   1. `bounding_box` only
   2. `metadataFilter` only
   3. `bounding_box` and `metadatafilter`
   
   But this message only checks for 1 & 2


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to support datainbounds algorithm

2018-03-14 Thread GitBox
fgreg commented on a change in pull request #12: SDAP-47 Update NEXUS CLI to 
support datainbounds algorithm
URL: 
https://github.com/apache/incubator-sdap-nexus/pull/12#discussion_r174620404
 
 

 ##
 File path: client/nexuscli/nexuscli.py
 ##
 @@ -207,3 +217,59 @@ def time_series(datasets, bounding_box, start_datetime, 
end_datetime, spark=Fals
 )
 
 return time_series_result
+
+
+def data_in_bounds(dataset, bounding_box, start_datetime, end_datetime, 
parameter, metadata_filter):
+"""
+Fetches point values for a given dataset and geographical area or metadata 
criteria and time range.
+
+__dataset__ Name of the dataset as a String  
+__bounding_box__ Bounding box for area of interest as a 
`shapely.geometry.polygon.Polygon`  
+__start_datetime__ Start time as a `datetime.datetime`  
+__end_datetime__ End time as a `datetime.datetime`  
+__parameter__ Name of the dataset as a String  
+__metadata_filter__ List of key:value String metadata criteria  
+
+__return__ List of `nexuscli.nexuscli.TimeSeries` namedtuples
 
 Review comment:
   Returns list of `Subset` namedtuples


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services