1010can be renamed and the v1 versions removed.
1111"""
1212
13+ import json
1314from pathlib import Path
1415from typing import Union
15- import json
1616
17+ import earthaccess
1718from fsspec .utils import tempfile
1819import harmony
19- import earthaccess
2020
21- from icepyx .core .harmony import HarmonyApi , HarmonyTemporal
22- from icepyx .core .base_query import BaseQuery
23- import icepyx .core .temporal as tp
2421import icepyx .core .APIformatting as apifmt
25-
22+ from icepyx . core . base_query import BaseQuery
2623from icepyx .core .granules import Granules , gran_IDs
27- import icepyx .core .validate_inputs as val
28-
24+ from icepyx .core .harmony import HarmonyApi , HarmonyTemporal
25+ import icepyx . core . temporal as tp
2926from icepyx .core .types import CMRParams
27+ import icepyx .core .validate_inputs as val
3028
3129
3230class Query (BaseQuery ):
@@ -55,7 +53,6 @@ def __init__(self, *args, **kwargs):
5553 self ._prod , cycles = self .cycles , tracks = self .tracks
5654 )
5755
58-
5956 @property
6057 def cycles (self ):
6158 """
@@ -96,11 +93,10 @@ def tracks(self):
9693 else :
9794 return sorted (set (self ._tracks ))
9895
99-
10096 def _get_concept_id (self , product , version ) -> Union [str , None ]:
101- collections = earthaccess .search_datasets (short_name = product ,
102- version = version ,
103- cloud_hosted = True )
97+ collections = earthaccess .search_datasets (
98+ short_name = product , version = version , cloud_hosted = True
99+ )
104100 if collections :
105101 return collections [0 ].concept_id ()
106102 else :
@@ -119,12 +115,10 @@ def show_custom_options(self) -> None:
119115
120116 """
121117 if self .concept_id :
122-
123118 capabilities = self .harmony_api .get_capabilities (concept_id = self .concept_id )
124119 print (json .dumps (capabilities , indent = 2 ))
125120 return None
126121
127-
128122 @property
129123 def CMRparams (self ) -> CMRParams :
130124 """
@@ -143,7 +137,6 @@ def CMRparams(self) -> CMRParams:
143137 self ._CMRparams = apifmt .Parameters ("CMR" )
144138 # print(self._CMRparams)
145139 # print(self._CMRparams.fmted_keys)
146-
147140
148141 # dictionary of optional CMR parameters
149142 kwargs = {}
@@ -168,7 +161,7 @@ def CMRparams(self) -> CMRParams:
168161 )
169162
170163 return self ._CMRparams .fmted_keys
171-
164+
172165 @property
173166 def granules (self ):
174167 """
@@ -257,16 +250,16 @@ def avail_granules(self, ids=False, cycles=False, tracks=False, cloud=False):
257250 else :
258251 return self .granules .avail
259252
260-
261-
262253 def _order_subset_granules (self ) -> str :
263254 concept_id = self ._get_concept_id (
264255 product = self ._prod ,
265256 version = self ._version ,
266257 )
267258
268259 if concept_id is None :
269- raise ValueError (f"Could not find concept ID for { self ._prod } v{ self ._version } " )
260+ raise ValueError (
261+ f"Could not find concept ID for { self ._prod } v{ self ._version } "
262+ )
270263
271264 harmony_temporal = None
272265 if self ._temporal :
@@ -317,15 +310,19 @@ def get_granule_links(self, cloud_hosted=False) -> list[str]:
317310 links = []
318311 for granule in self .granules .avail :
319312 for link in granule ["links" ]:
320- if cloud_hosted and link ["rel" ] == "http://esipfed.org/ns/fedsearch/1.1/s3#" :
313+ if (
314+ cloud_hosted
315+ and link ["rel" ] == "http://esipfed.org/ns/fedsearch/1.1/s3#"
316+ ):
321317 links .append (link ["href" ])
322318 elif link ["rel" ] == "http://esipfed.org/ns/fedsearch/1.1/data#" :
323- if "type" in link and link ["type" ] in ["application/x-hdf5" ,
324- "application/x-hdfeos" ]:
319+ if "type" in link and link ["type" ] in [
320+ "application/x-hdf5" ,
321+ "application/x-hdfeos" ,
322+ ]:
325323 links .append (link ["href" ])
326324 return links
327325
328-
329326 def _order_whole_granules (self , cloud_hosted = False , path = "./" ) -> None :
330327 """
331328 Downloads the whole granules for the query object. This is not an asnc operation
@@ -340,11 +337,10 @@ def _order_whole_granules(self, cloud_hosted=False, path="./") -> None:
340337 The local directory to download the granules to.
341338
342339 """
343-
340+
344341 links = self .get_granule_links (cloud_hosted = cloud_hosted )
345342 earthaccess .download (links , local_path = path )
346343
347-
348344 def order_granules (self , subset = True ):
349345 """
350346 Place an order for the available granules for the query object.
0 commit comments