Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions notebooks/slc_download_test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "81d1d1db",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from uavsar_pytools.download.download_slcs import get_uavsar_slcs, download_uavsar_slcs"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "cedb8cea",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Created test directory at /Users/JULIALOBER/uavsar_pytools/notebooks/uavsar_test_downloads\n"
]
}
],
"source": [
"# Create a temporary directory for our test downloads\n",
"test_dir = './uavsar_test_downloads'\n",
"os.makedirs(test_dir, exist_ok=True)\n",
"test_dir = os.path.abspath(test_dir)\n",
"print(f\"Created test directory at {test_dir}\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "734e76cb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Generated 11 URLs for lowman_23205.\n",
"\n",
"First 3 URLs found:\n",
"lowman_23205_20011_003_200221_L090HH_01_BC_s1_2x8.slc\n",
"lowman_23205_01_BC_s1_2x8.llh\n",
"lowman_23205_01_BC_s1_2x8.lkv\n",
"lowman_23205_20011_003_200221_L090HH_01_BC_s2_2x8.slc\n",
"lowman_23205_01_BC_s2_2x8.llh\n",
"lowman_23205_01_BC_s2_2x8.lkv\n",
"lowman_23205_20011_003_200221_L090HH_01_BC.ann\n",
"lowman_23205_01_BC.dop\n",
"lowman_23205_20007_003_200213_L090HH_01_BC_s1_2x8.slc\n",
"lowman_23205_20007_003_200213_L090HH_01_BC_s2_2x8.slc\n",
"lowman_23205_20007_003_200213_L090HH_01_BC.ann\n"
]
}
],
"source": [
"# Query links for a narrow time window\n",
"test_links_dict = get_uavsar_slcs(\n",
" flight_name='lowman',\n",
" start_date='2020-02-01',\n",
" end_date='2020-02-28',\n",
" tag=['BC'],\n",
" seg=['s1', 's2'],\n",
" getann=True,\n",
" getdop=True,\n",
" getllh=True,\n",
" getlkv=True\n",
")\n",
"\n",
"# Extract the dictionary key (should be 'grmesa_03913' or similar)\n",
"test_key = list(test_links_dict.keys())[0]\n",
"generated_urls = test_links_dict[test_key]\n",
"\n",
"print(f\"Generated {len(generated_urls)} URLs for {test_key}.\")\n",
"print(\"\\nFirst 3 URLs found:\")\n",
"for url in generated_urls[:]:\n",
" print(url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "046d76ae",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Original URL: lowman_23205_20011_003_200221_L090HH_01_BC.ann\n",
"Testing download pipeline with: lowman_23205_20011_003_200221_L090HH_01_BC.ann\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a3224d50330c427a93af812fe9e5e8d8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading lowman_23205_20011_003_200221_L090HH_01_BC.ann: 0%| | 0.00/47.0k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fe1a4e96629245ad9e4e9aa38103fb66",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Downloading lowman_23205_20007_003_200213_L090HH_01_BC.ann: 0%| | 0.00/47.0k [00:00<?, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found file verified on disk at /Users/JULIALOBER/uavsar_pytools/notebooks/uavsar_test_downloads/lowman_23205_20011_003_200221_L090HH_01_BC.ann\n"
]
}
],
"source": [
"# Filter the list to ONLY include an .ann file to save bandwidth\n",
"ann_files_only = [url for url in generated_urls if url.endswith('.ann')]\n",
"\n",
"if not ann_files_only:\n",
" print(\"No .ann files found. Make sure getann=True was passed in Cell 3.\")\n",
"else:\n",
" # We will just pass the very first .ann file to the download function\n",
" test_download = ann_files_only\n",
" \n",
" print(f\"Testing download pipeline with: {test_download}\")\n",
" \n",
" # Run the download\n",
" download_uavsar_slcs(test_download, out_dir=test_dir)\n",
" \n",
" # Verify it exists\n",
" downloaded_path = os.path.join(test_dir, test_download[0])\n",
" if os.path.exists(downloaded_path):\n",
" print(f\"Found file verified on disk at {downloaded_path}\")\n",
" else:\n",
" print(\"Download failed or file not found.\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "uavsar_pytools",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.14.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 4 additions & 2 deletions uavsar_pytools/download/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from os.path import join, isdir, isfile, basename, dirname, exists
from tqdm.auto import tqdm
import logging

import urllib
from collections import defaultdict
import asf_search as asf
import time

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -155,4 +157,4 @@ def download_zip(url, output_dir):
else:
log.info(f'{local} already exists, skipping download!')

return local
return local
Loading