Skip to content

Commit fb348a2

Browse files
committed
enable downloading data from ASF
1 parent 507886f commit fb348a2

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

prep/NISAR_prep.ipynb

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
"from rasterio.warp import reproject, Resampling, transform_bounds\n",
8282
"import h5py\n",
8383
"from pyproj import Transformer\n",
84-
"import tile_mate"
84+
"import tile_mate\n",
85+
"import asf_search as asf"
8586
]
8687
},
8788
{
@@ -102,12 +103,12 @@
102103
"outputs": [],
103104
"source": [
104105
"# === Basic Configuration ===\n",
105-
"site = \"OregonA34\" # Cal/Val location ID\n",
106+
"site = \"LosAngelesA34\" # Cal/Val location ID\n",
106107
"requirement = \"Transient\" # Options: 'Secular', 'Coseismic', 'Transient'\n",
107108
"dataset = \"NISAR\" # Dataset type: 'NISAR_sample', 'ARIA_S1', 'ARIA_S1_new'\n",
108109
"\n",
109110
"\n",
110-
"rundate = \"20260227\" # Date of this Cal/Val run\n",
111+
"rundate = \"20260312\" # Date of this Cal/Val run\n",
111112
"version = \"1\" # Version of this Cal/Val run\n",
112113
"custom_sites = \"/home/jovyan/my_nisar_sites.txt\" # Path to custom site metadata\n",
113114
"\n",
@@ -217,7 +218,7 @@
217218
" print(f\"Earthdata credentials found for user: {earthdata_user}\")\n",
218219
"\n",
219220
"if not earthdata:\n",
220-
" print(\"\\nNEEDED to Download ARIA GUNWs\")\n",
221+
" print(\"\\nNEEDED to Download ARIA/NISAR GUNWs\")\n",
221222
" print(\"Create account at: https://urs.earthdata.nasa.gov/\")\n",
222223
" earthdata_user = input(\"Earthdata username: \").strip()\n",
223224
" earthdata_password = input(\"Earthdata password: \").strip()\n",
@@ -266,9 +267,40 @@
266267
"<hr>\n",
267268
"\n",
268269
"<a id='prep_ifg'></a>\n",
269-
"# 1. Download and Prepare Interferograms\n",
270-
"\n",
271-
"In this initial processing step, all the necessary Level-2 unwrapped interferogram products are gathered and organized for analysis with MintPy."
270+
"# 1. Download and Prepare Interferograms"
271+
]
272+
},
273+
{
274+
"cell_type": "code",
275+
"execution_count": null,
276+
"id": "95f2582c-8291-4cdc-b4b6-c3e1b2e66c37",
277+
"metadata": {},
278+
"outputs": [],
279+
"source": [
280+
"print(f\"CalVal site: {site}\")\n",
281+
"\n",
282+
"# Extract site-specific metadata\n",
283+
"bbox = site_info.get('download_region')\n",
284+
"startdate = site_info.get('download_start_date')\n",
285+
"enddate = site_info.get('download_end_date')\n",
286+
"track = site_info.get('nisar_track')\n",
287+
"\n",
288+
"s, n, w, e = map(float, bbox.strip(\"'\").split())\n",
289+
"bbox_wkt = f\"POLYGON(({w} {s}, {e} {s}, {e} {n}, {w} {n}, {w} {s}))\"\n",
290+
"startdate_fmt = f\"{enddate[:4]}-{enddate[4:6]}-{enddate[6:]}\"\n",
291+
"enddate_fmt = f\"{enddate[:4]}-{enddate[4:6]}-{enddate[6:]}\"\n",
292+
"data_list = asf.search(dataset=asf.DATASET.NISAR, processingLevel=asf.PRODUCT_TYPE.GUNW, relativeOrbit=int(track), intersectsWith=bbox_wkt)\n",
293+
"prod_list = data_list.find_urls(extension='.h5', pattern=r'.*\\d.h5')"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"id": "460d1964-b369-48c0-b915-6ca8e7a717ee",
300+
"metadata": {},
301+
"outputs": [],
302+
"source": [
303+
"asf.download_urls(prod_list, path=gunw_dir)"
272304
]
273305
},
274306
{
@@ -505,15 +537,24 @@
505537
"outputs": [],
506538
"source": [
507539
"command = f'prep_nisar.py -i \"{gunw_dir}/*.h5\" -d {out_dem} -m {out_mask} -o {mintpy_dir}'\n",
508-
"process = subprocess.run(command, shell=True)\n",
540+
"process = subprocess.run(command, shell=True, check=True)"
541+
]
542+
},
543+
{
544+
"cell_type": "code",
545+
"execution_count": null,
546+
"id": "d64d0033-49da-4b8f-9a44-8cd66ecd589d",
547+
"metadata": {},
548+
"outputs": [],
549+
"source": [
509550
"print('Mintpy input files:')\n",
510551
"[x for x in os.listdir(mintpy_dir + '/inputs') if x.endswith('.h5')]"
511552
]
512553
},
513554
{
514555
"cell_type": "code",
515556
"execution_count": null,
516-
"id": "d64d0033-49da-4b8f-9a44-8cd66ecd589d",
557+
"id": "8cd8b317-b54b-40b8-aa79-80bef0298c98",
517558
"metadata": {},
518559
"outputs": [],
519560
"source": []

0 commit comments

Comments
 (0)