Skip to content

Commit 608b52b

Browse files
committed
Add total_size_mb property to IceflowSearchResult and log size when downloading
1 parent ebb2d79 commit 608b52b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/nsidc/iceflow/data/fetch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def _download_iceflow_search_result(
6161

6262
logger.info(
6363
f"Downloading {len(iceflow_search_result.granules)} granules"
64+
f" (approx. {iceflow_search_result.total_size_mb} MB)"
6465
f" to {output_subdir}."
6566
)
6667

src/nsidc/iceflow/data/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,5 +247,10 @@ class IceflowSearchResult(pydantic.BaseModel):
247247
# this that type
248248
model_config = pydantic.ConfigDict(arbitrary_types_allowed=True)
249249

250+
@property
251+
def total_size_mb(self):
252+
granule_sizes_mb = [granule.size() for granule in self.granules]
253+
return sum(granule_sizes_mb)
254+
250255

251256
IceflowSearchResults = list[IceflowSearchResult]

0 commit comments

Comments
 (0)