Skip to content

Commit ddab53b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0158168 commit ddab53b

File tree

6 files changed

+34
-42
lines changed

6 files changed

+34
-42
lines changed

icepyx/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _icepyx_version import version as __version__
2-
from icepyx.core.base_query import GenQuery, BaseQuery, LegacyQuery
2+
3+
from icepyx.core.base_query import BaseQuery, GenQuery, LegacyQuery
34
from icepyx.core.query import Query
45
from icepyx.core.read import Read
56
from icepyx.core.variables import Variables

icepyx/core/base_query.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from functools import cached_property
22
import pprint
33
from typing import Optional, Union, cast
4-
from deprecated import deprecated
5-
import earthaccess
64

5+
import earthaccess
76
import geopandas as gpd
87
import matplotlib.pyplot as plt
98
from typing_extensions import Never
@@ -420,7 +419,6 @@ def __init__(
420419
auth=None,
421420
**kwargs,
422421
):
423-
424422
self._prod = is2ref._validate_product(product)
425423

426424
super().__init__(spatial_extent, date_range, start_time, end_time, **kwargs)
@@ -449,9 +447,9 @@ def concept_id(self) -> Union[str, None]:
449447
version = self._version
450448
else:
451449
version = is2ref.latest_version(short_name)
452-
collections = earthaccess.search_datasets(short_name=short_name,
453-
version=version,
454-
cloud_hosted=True)
450+
collections = earthaccess.search_datasets(
451+
short_name=short_name, version=version, cloud_hosted=True
452+
)
455453
if collections:
456454
return collections[0].concept_id()
457455
else:
@@ -902,7 +900,6 @@ def granules(self):
902900
# ----------------------------------------------------------------------
903901
# Methods - Get and display neatly information at the product level
904902

905-
906903
# ----------------------------------------------------------------------
907904
# Methods - Granules (NSIDC-API)
908905

icepyx/core/granules.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from icepyx.core.types import (
2121
CMRParams,
2222
EGIRequiredParamsDownload,
23-
EGIRequiredParamsSearch,
2423
)
2524
from icepyx.core.urls import DOWNLOAD_BASE_URL, GRANULE_SEARCH_BASE_URL, ORDER_BASE_URL
2625

@@ -208,9 +207,7 @@ def get_avail(
208207
query.Query.avail_granules
209208
"""
210209

211-
assert (
212-
CMRparams is not None
213-
), "Missing required input parameter dictionaries"
210+
assert CMRparams is not None, "Missing required input parameter dictionaries"
214211

215212
# if not hasattr(self, 'avail'):
216213
self.avail = []

icepyx/core/is2ref.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111

1212
# ICESat-2 specific reference functions
1313

14+
1415
def _get_concept_id(product, version):
15-
collections = earthaccess.search_datasets(short_name=product,
16-
version=version,
17-
cloud_hosted=True)
16+
collections = earthaccess.search_datasets(
17+
short_name=product, version=version, cloud_hosted=True
18+
)
1819
if collections:
1920
return collections[0].concept_id()
2021

icepyx/core/query.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,21 @@
1010
can be renamed and the v1 versions removed.
1111
"""
1212

13+
import json
1314
from pathlib import Path
1415
from typing import Union
15-
import json
1616

17+
import earthaccess
1718
from fsspec.utils import tempfile
1819
import 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
2421
import icepyx.core.APIformatting as apifmt
25-
22+
from icepyx.core.base_query import BaseQuery
2623
from 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
2926
from icepyx.core.types import CMRParams
27+
import icepyx.core.validate_inputs as val
3028

3129

3230
class 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.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
backoff
22
dask[dataframe]
33
datashader
4+
deprecated
45
earthaccess>=0.12.0
56
fiona
67
geopandas
@@ -15,4 +16,3 @@ requests
1516
s3fs
1617
shapely
1718
xarray
18-
deprecated

0 commit comments

Comments
 (0)