Skip to content

Commit 8a24aa7

Browse files
Merge pull request #4 from gregory-halverson/main
search and download of swath granules by tile
2 parents 5117972 + 4db60cb commit 8a24aa7

File tree

5 files changed

+147
-26
lines changed

5 files changed

+147
-26
lines changed

Search and Download.ipynb

Lines changed: 121 additions & 21 deletions
Large diffs are not rendered by default.

VIIRS_swath_granules/granule_ID.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ def parse_VIIRS_build(granule_ID: str) -> int:
4747
Returns:
4848
int: The build number extracted from the granule_ID.
4949
"""
50-
return int(basename(granule_ID).split(".")[3])
50+
print(f"granule_ID: {granule_ID}")
51+
build = int(basename(granule_ID).split(".")[3])
52+
print(f"build: {build}")
53+
return build

VIIRS_swath_granules/retrieve_granule.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import os
2-
from os.path import join, abspath, expanduser
2+
from os.path import join, abspath, expanduser, splitext
3+
import posixpath
34
import earthaccess
5+
46
from modland import generate_modland_grid
7+
58
from .VIIRS_swath_granule import VIIRSSwathGranule
69
from .granule_ID import *
710

@@ -27,8 +30,23 @@ def retrieve_granule(
2730
Returns:
2831
VIIRSSwathGranule: The downloaded and processed VIIRS tiled granule.
2932
"""
33+
# determine the URL of the remote granule
34+
URL = None
35+
36+
for related_URL_dict in remote_granule["umm"]["RelatedUrls"]:
37+
if related_URL_dict["Type"] == "GET DATA":
38+
URL = related_URL_dict["URL"]
39+
40+
if URL is None:
41+
raise ValueError("No GET DATA URL found in the remote granule metadata.")
42+
43+
# Extract the granule ID from the URL
44+
granule_ID = splitext(posixpath.basename(URL))[0]
45+
3046
# Extract the granule ID from the remote granule metadata
31-
granule_ID = remote_granule["meta"]["native-id"]
47+
# import json
48+
# print(json.dumps(remote_granule["meta"], indent=4))
49+
# granule_ID = remote_granule["meta"]["native-id"]
3250

3351
# Parse the product name, build number, and date from the granule ID
3452
product_name = parse_VIIRS_product(granule_ID)

VIIRS_swath_granules/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.1.1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "VIIRS-Swath-Granules"
7-
version = "1.1.0"
7+
version = "1.1.1"
88
description = "Visible Infrared Imaging Radiometer Suite (VIIRS) Swath Product Search and Download Utility"
99
readme = "README.md"
1010
authors = [

0 commit comments

Comments
 (0)