Skip to content
Merged
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
20 changes: 18 additions & 2 deletions isce2_topsapp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,19 @@ def gunw_slc():
# Also validate CDSE credentials if using CDSE for download
if args.download_source == "cdse":
from isce2_topsapp.localize_slc_cdse import ensure_cdse_credentials

ensure_cdse_credentials()
cli_params = vars(args).copy()
[
cli_params.pop(key)
for key in ["username", "password", "bucket", "bucket_prefix", "dry_run", "download_source"]
for key in [
"username",
"password",
"bucket",
"bucket_prefix",
"dry_run",
"download_source",
]
]
topsapp_params_obj = topsappParams(**cli_params)

Expand Down Expand Up @@ -484,11 +492,19 @@ def coseis_sar():
# Also validate CDSE credentials if using CDSE for download
if args.download_source == "cdse":
from isce2_topsapp.localize_slc_cdse import ensure_cdse_credentials

ensure_cdse_credentials()
cli_params = vars(args).copy()
[
cli_params.pop(key)
for key in ["username", "password", "bucket", "bucket_prefix", "dry_run", "download_source"]
for key in [
"username",
"password",
"bucket",
"bucket_prefix",
"dry_run",
"download_source",
]
]
topsapp_params_obj = topsappParams(**cli_params)

Expand Down
7 changes: 6 additions & 1 deletion isce2_topsapp/localize_slc.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ def download_slcs(
dry_run=dry_run,
)
else:

def download_one(resp):
session = get_session()
file_name = resp.properties["fileName"]
Expand All @@ -256,7 +257,11 @@ def download_one(resp):
n = len(all_obs)
with ThreadPoolExecutor(max_workers=max_workers_for_download) as executor:
results = list(
tqdm(executor.map(download_one, all_obs), total=n, desc="Downloading SLCs")
tqdm(
executor.map(download_one, all_obs),
total=n,
desc="Downloading SLCs",
)
)

n0 = len(reference_obs)
Expand Down
10 changes: 5 additions & 5 deletions isce2_topsapp/localize_slc_cdse.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ def search_cdse_by_granule_name(granule_name: str) -> dict:

if not results:
raise LookupError(
f"Product '{safe_name}' not found in CDSE catalog. "
f"Query: {query}"
f"Product '{safe_name}' not found in CDSE catalog. Query: {query}"
)

# Return the first match (there should be exactly one for a unique granule name)
Expand Down Expand Up @@ -241,7 +240,6 @@ def download_single_slc_from_cdse(
# Search for the product to get its UUID
product = search_cdse_by_granule_name(granule_name)
product_id = product["Id"]
product_name = product["Name"] # e.g., S1A_...SAFE

download_url = f"{CDSE_DOWNLOAD_URL}({product_id})/$zip"
headers = {"Authorization": f"Bearer {access_token}"}
Expand All @@ -267,10 +265,12 @@ def download_single_slc_from_cdse(

# Verify the file is non-empty
if out_path.stat().st_size > 0:
print(f"Successfully downloaded {out_filename} from CDSE ({out_path.stat().st_size / 1e6:.1f} MB)")
print(
f"Successfully downloaded {out_filename} from CDSE ({out_path.stat().st_size / 1e6:.1f} MB)"
)
return out_filename

print(f"Downloaded file is empty, retrying...")
print("Downloaded file is empty, retrying...")
out_path.unlink(missing_ok=True)

except requests.RequestException as e:
Expand Down