From 5812b0d3d8d4d4169038820504ca2bb460dd02e4 Mon Sep 17 00:00:00 2001 From: scott Date: Wed, 24 Jan 2024 09:31:51 -0500 Subject: [PATCH] start implementing a stricter orbit type selection --- eof/asf_client.py | 4 ++-- eof/cli.py | 9 +++++---- eof/download.py | 14 +++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/eof/asf_client.py b/eof/asf_client.py index 40605bf..48e9f50 100644 --- a/eof/asf_client.py +++ b/eof/asf_client.py @@ -129,9 +129,9 @@ def get_download_urls(self, orbit_dts, missions, orbit_type="precise"): remaining_orbits.append((dt, mission)) if remaining_orbits: - logger.warning("The following dates were not found: %s", remaining_orbits) + logger.info("The following dates were not found: %s", remaining_orbits) if orbit_type == "precise": - logger.warning( + logger.info( "Attempting to download the restituted orbits for these dates." ) remaining_dts, remaining_missions = zip(*remaining_orbits) diff --git a/eof/cli.py b/eof/cli.py index d7d771c..81672e3 100644 --- a/eof/cli.py +++ b/eof/cli.py @@ -49,10 +49,11 @@ ) @click.option( "--orbit-type", - type=click.Choice(["precise", "restituted"]), - default="precise", - help="Optionally specify the type of orbit file to get " - "(default: precise (POEORB), but fallback to restituted (RESORB))", + type=click.Choice(["precise", "restituted", None]), + default=None, + help="Optionally specify the type of orbit file to get. " + "If None, will attempt precise (POEORB) but fallback to restituted (RESORB)." + " Otherwise, will fail if selected orbit type is not available.", ) @click.option( "--force-asf", diff --git a/eof/download.py b/eof/download.py index 0eec401..0f83830 100644 --- a/eof/download.py +++ b/eof/download.py @@ -28,6 +28,7 @@ import os from multiprocessing.pool import ThreadPool from pathlib import Path +from typing import Literal, Optional from dateutil.parser import parse from requests.exceptions import HTTPError @@ -45,7 +46,7 @@ def download_eofs( missions=None, sentinel_file=None, save_dir=".", - orbit_type="precise", + orbit_type: Optional[Literal["precise", "restituted"]] = None, force_asf: bool = False, asf_user: str = "", asf_password: str = "", @@ -61,7 +62,14 @@ def download_eofs( No input downloads both, must be same len as orbit_dts sentinel_file (str): path to Sentinel-1 filename to download one .EOF for save_dir (str): directory to save the EOF files into - orbit_type (str): precise or restituted + orbit_type (str): "precise" or "restituted", optional. + If None, will attempt "precise" first, then fallback to "restituted" + force_asf (bool): force download from ASF even if credentials are provided + asf_user (str): ASF username + asf_password (str): ASF password + cdse_user (str): CDSE username + cdse_password (str): CDSE password + max_workers (int): number of workers to use for parallel downloads Returns: list[str]: all filenames of saved orbit files @@ -204,7 +212,7 @@ def main( sentinel_file=None, mission=None, date=None, - orbit_type="precise", + orbit_type: Optional[Literal["precise", "restituted"]] = None, force_asf: bool = False, asf_user: str = "", asf_password: str = "",