Skip to content

Commit 19ae1b5

Browse files
committed
add MintPY config file generation
1 parent 5d5ac54 commit 19ae1b5

File tree

1 file changed

+77
-26
lines changed

1 file changed

+77
-26
lines changed

prep/NISAR_prep.ipynb

Lines changed: 77 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"[**1. Download and Prepare Interferograms**](#prep_ifg)\n",
3535
"- [1.1. Get Data List](#prep_data)\n",
3636
"- [1.2. Download DEM](#prep_dem)\n",
37-
"- [1.3. Load Data into MintPy](#prep_load_data)\n",
37+
"- [1.3. Create MintPy configuration file](#create_config)\n",
38+
"- [1.4. Load Data into MintPy](#prep_load_data)\n",
3839
"\n",
3940
"<hr/>"
4041
]
@@ -85,17 +86,17 @@
8586
{
8687
"cell_type": "code",
8788
"execution_count": null,
88-
"id": "8b464e26-d7a9-4834-bc77-da3968e90f57",
89+
"id": "18978e7b-b33d-4f6d-a38d-a87044275edb",
8990
"metadata": {},
9091
"outputs": [],
9192
"source": [
9293
"# === Basic Configuration ===\n",
93-
"site = \"NISAR_ALOS1_Hawaii_0380\" # Cal/Val location ID\n",
94+
"site = \"Erta_Ale\" # Cal/Val location ID\n",
9495
"requirement = \"Transient\" # Options: 'Secular', 'Coseismic', 'Transient'\n",
9596
"dataset = \"NISAR_sample\" # Dataset type: 'NISAR_sample', 'ARIA_S1', 'ARIA_S1_new'\n",
9697
"\n",
9798
"\n",
98-
"rundate = \"20251008\" # Date of this Cal/Val run\n",
99+
"rundate = \"20260205\" # Date of this Cal/Val run\n",
99100
"version = \"1\" # Version of this Cal/Val run\n",
100101
"custom_sites = \"/home/jovyan/my_sites.txt\" # Path to custom site metadata\n",
101102
"\n",
@@ -326,37 +327,87 @@
326327
"\n",
327328
"out_dem = os.path.join(dem_dir, f\"{site}_elevation.dem\")\n",
328329
"\n",
329-
"cmd = [\n",
330-
" \"sardem\",\n",
331-
" \"--bbox\", *bbox,\n",
332-
" \"--output\", out_dem,\n",
333-
" \"--output-format\", \"ENVI\"\n",
334-
"]\n",
330+
"if os.path.isfile(out_dem):\n",
331+
" print(f\"{out_dem} exists, skip downloading\")\n",
332+
"else:\n",
333+
" cmd = [\n",
334+
" \"sardem\",\n",
335+
" \"--bbox\", *bbox,\n",
336+
" \"--output\", out_dem,\n",
337+
" \"--output-format\", \"ENVI\"\n",
338+
" ]\n",
339+
" \n",
340+
" print(\"Running:\", \" \".join(cmd))\n",
341+
" try:\n",
342+
" res = subprocess.run(cmd, check=True, capture_output=True, text=True)\n",
343+
" if res.stdout:\n",
344+
" print(res.stdout)\n",
345+
" print(\"DEM files:\", os.listdir(dem_dir))\n",
346+
" except subprocess.CalledProcessError as e:\n",
347+
" print(\"sardem failed:\")\n",
348+
" print(e.stdout or \"\")\n",
349+
" print(e.stderr or \"\")\n",
350+
" raise"
351+
]
352+
},
353+
{
354+
"cell_type": "markdown",
355+
"id": "54c045a9-65ce-47ac-9fd3-d32d560667f8",
356+
"metadata": {},
357+
"source": [
358+
"### 1.3. Create MintPy configuration file <a id='create_config'></a>"
359+
]
360+
},
361+
{
362+
"cell_type": "code",
363+
"execution_count": null,
364+
"id": "c3817649-4966-4ab9-a213-27c6dddbfd00",
365+
"metadata": {},
366+
"outputs": [],
367+
"source": [
368+
"os.chdir(mintpy_dir)\n",
335369
"\n",
336-
"print(\"Running:\", \" \".join(cmd))\n",
337-
"try:\n",
338-
" res = subprocess.run(cmd, check=True, capture_output=True, text=True)\n",
339-
" if res.stdout:\n",
340-
" print(res.stdout)\n",
341-
" print(\"DEM files:\", os.listdir(dem_dir))\n",
342-
"except subprocess.CalledProcessError as e:\n",
343-
" print(\"sardem failed:\")\n",
344-
" print(e.stdout or \"\")\n",
345-
" print(e.stderr or \"\")\n",
346-
" raise"
370+
"# Build config as a dictionary first\n",
371+
"config_file_content = {\n",
372+
" \"mintpy.load.processor\": \"nisar\",\n",
373+
" \"mintpy.compute.cluster\": \"local\",\n",
374+
" \"mintpy.compute.numWorker\": \"auto\",\n",
375+
" \"mintpy.topographicResidual.pixelwiseGeometry\": \"no\",\n",
376+
" \"mintpy.troposphericDelay.method\": \"no\",\n",
377+
" \"mintpy.topographicResidual\": \"no\",\n",
378+
" \"mintpy.network.tempBaseMax\": site_info.get('tempBaseMax'),\n",
379+
" \"mintpy.network.startDate\": site_info.get('download_start_date'),\n",
380+
" \"mintpy.network.endDate\": site_info.get('download_end_date'),\n",
381+
" \"mintpy.velocity.startDate\": site_info.get('download_start_date'),\n",
382+
" \"mintpy.velocity.endDate\": site_info.get('download_end_date'),\n",
383+
" \"mintpy.reference.lalo\": site_info.get('reference_lalo'),\n",
384+
" \"mintpy.network.excludeDate12\": site_info.get('ifgExcludePair'),\n",
385+
" \"mintpy.network.excludeDate\" : site_info.get('ifgExcludeDate'),\n",
386+
" \"mintpy.network.excludeIfgIndex\" : site_info.get('ifgExcludeIndex'),\n",
387+
"}\n",
388+
"\n",
389+
"# Write config dictionary to text file\n",
390+
"with open(config_file, \"w\") as f:\n",
391+
" f.writelines(f\"{k} = {v}\\n\" for k, v in config_file_content.items())\n",
392+
"\n",
393+
"# Confirm output\n",
394+
"print(f\"MintPy config file written to:\\n {config_file}\\n\")\n",
395+
"with open(config_file, \"r\") as f:\n",
396+
" print(f.read())\n"
347397
]
348398
},
349399
{
350400
"cell_type": "markdown",
351401
"id": "0de4a38e-60f3-421b-949f-aff1145e5881",
352402
"metadata": {},
353403
"source": [
354-
"### 1.3. Load Data into MintPy Cubes <a id='prep_load_data'></a>\n",
404+
"### 1.4. Load Data into MintPy Cubes <a id='prep_load_data'></a>\n",
355405
"\n",
356406
"The output of this step is an \"inputs\" directory in 'calval_directory/calval_location/MintPy/\" containing three HDF5 files:\n",
357-
"- ifgramStack.h5: This file contains 6 dataset cubes (e.g. unwrapped phase, coherence, connected components etc.) and multiple metadata\n",
358-
"- geometryGeo.h5: This file contains geometrical datasets (e.g., incidence/azimuth angle, masks, etc.)\n",
359-
"- ionStack.h5 : This file contains pairwise ionosphere data present in the NISAR data "
407+
"- ifgramStack.h5: Contains 6 dataset cubes (e.g. unwrapped phase, coherence, connected components etc.) and multiple metadata.\n",
408+
"- geometryGeo.h5: Contains geometrical datasets (e.g., incidence/azimuth angle, masks, etc.).\n",
409+
"- ionStack.h5 : Contains pairwise ionosphere data present in the NISAR L2 GUNW.\n",
410+
"- tropoStack.h5 : Contains 3D interpolated total tropospheric delay calculated from NISAR radar grid tropospheric delay layers."
360411
]
361412
},
362413
{
@@ -389,7 +440,7 @@
389440
"name": "python",
390441
"nbconvert_exporter": "python",
391442
"pygments_lexer": "ipython3",
392-
"version": "3.13.7"
443+
"version": "3.14.3"
393444
}
394445
},
395446
"nbformat": 4,

0 commit comments

Comments
 (0)