[ 
https://issues.apache.org/jira/browse/SDAP-47?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16399519#comment-16399519
 ] 

ASF GitHub Bot commented on SDAP-47:
------------------------------------

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


> Update NEXUS CLI to support datainbounds algorithm
> --------------------------------------------------
>
>                 Key: SDAP-47
>                 URL: https://issues.apache.org/jira/browse/SDAP-47
>             Project: Apache Science Data Analytics Platform
>          Issue Type: New Feature
>            Reporter: Nga Chung
>            Assignee: Nga Chung
>            Priority: Major
>
> Update the NEXUS CLI to support call to datainbounds algorithm



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to