[GRASS-SVN] r74347 - grass-addons/grass7/imagery/i.sentinel/i.sentinel.download

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 4 12:48:12 PDT 2019


Author: martinl
Date: 2019-04-04 12:48:12 -0700 (Thu, 04 Apr 2019)
New Revision: 74347

Modified:
   grass-addons/grass7/imagery/i.sentinel/i.sentinel.download/i.sentinel.download.py
Log:
i.sentinel.download: fix GRD product type search

Modified: grass-addons/grass7/imagery/i.sentinel/i.sentinel.download/i.sentinel.download.py
===================================================================
--- grass-addons/grass7/imagery/i.sentinel/i.sentinel.download/i.sentinel.download.py	2019-04-04 14:00:58 UTC (rev 74346)
+++ grass-addons/grass7/imagery/i.sentinel/i.sentinel.download/i.sentinel.download.py	2019-04-04 19:48:12 UTC (rev 74347)
@@ -180,9 +180,11 @@
                start=None, end=None, sortby=[], asc=True):
         args = {}
         if clouds:
-            args['cloudcoverpercentage'] = (0, clouds)
+            args['cloudcoverpercentage'] = (0, int(clouds))
         if producttype:
             args['producttype'] = producttype
+            if producttype != 'GRD':
+                args['platformname'] = 'Sentinel-2'
         if not start:
             start = 'NOW-60DAYS'
         else:
@@ -193,7 +195,7 @@
             end = end.replace('-', '')
         products = self._api.query(
             area=area, area_relation=area_relation,
-            platformname='Sentinel-2',
+            
             date=(start, end),
             **args
         )
@@ -208,6 +210,8 @@
                 sortby,
                 ascending=[asc] * len(sortby)
             )
+        else:
+            self._products_df_sorted = products_df
 
         if limit:
             self._products_df_sorted = self._products_df_sorted.head(int(limit))
@@ -365,6 +369,17 @@
 
     map_box = get_aoi_box(options['map'])
 
+    sortby = options['sort'].split(',')
+    if options['producttype'] == 'GRD':
+        gs.info("Option <{}> ignored: cloud cover percentage "
+                "is not defined for product type GRD".format(
+                    "clouds"
+        ))
+        options['clouds'] = None
+        try:
+            sortby.remove('cloudcoverpercentage')
+        except ValueError:
+            pass
     try:
         downloader = SentinelDownloader(user, password, api_url)
 
@@ -378,7 +393,7 @@
                               limit=options['limit'],
                               start=options['start'],
                               end=options['end'],
-                              sortby=options['sort'].split(','),
+                              sortby=sortby,
                               asc=options['order'] == 'asc'
             )
     except StandardError as e:



More information about the grass-commit mailing list