Skip to content

Commit

Permalink
fix the cli to download both S1A/B if only date is specified
Browse files Browse the repository at this point in the history
pointed out by @bbuzz31 that the help string was wrong, and it would error without the mission
  • Loading branch information
scottstanie committed Dec 7, 2022
1 parent 6c764fb commit fd41c56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
13 changes: 10 additions & 3 deletions eof/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,26 @@
help="Specify path to download only 1 .EOF for a Sentinel-1 file/folder",
show_default=True,
)
@click.option("--date", "-d", help="Validity date for EOF to download")
@click.option(
"--date",
"-d",
help="Alternative to specifying Sentinel products: choose date to download for.",
)
@click.option(
"--mission",
"-m",
type=click.Choice(["S1A", "S1B"]),
help="Optionally specify Sentinel satellite to download (default: gets both S1A and S1B)",
help=(
"If using `--date`, optionally specify Sentinel satellite to download"
" (default: gets both S1A and S1B)"
),
)
@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))",
"(default: precise (POEORB), but fallback to restituted (RESORB))",
)
def cli(search_path, save_dir, sentinel_file, date, mission, orbit_type):
"""Download Sentinel precise orbit files.
Expand Down
10 changes: 5 additions & 5 deletions eof/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def download_eofs(orbit_dts=None, missions=None, sentinel_file=None, save_dir=".
if not missions:
missions = itertools.repeat(None)

# First make sures all are datetimes if given string
# First make sure all are datetimes if given string
orbit_dts = [parse(dt) if isinstance(dt, str) else dt for dt in orbit_dts]

filenames = []
Expand Down Expand Up @@ -216,15 +216,15 @@ def main(search_path=".", save_dir=",", sentinel_file=None, mission=None, date=N
logger.info("Creating directory for output: %s", save_dir)
os.mkdir(save_dir)

if (mission and not date) or (date and not mission):
raise ValueError("Must specify date and mission together")
if (mission and not date):
raise ValueError("Must specify date if providing mission.")

if sentinel_file:
# Handle parsing in download_eof
orbit_dts, missions = None, None
elif date:
orbit_dts = [date]
missions = [mission]
missions = [mission] if mission else ["S1A", "S1B"]
orbit_dts = [date] * len(missions)
else:
# No command line args given: search current directory
orbit_dts, missions = find_scenes_to_download(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="sentineleof",
version="0.6.4",
version="0.6.5",
author="Scott Staniewicz",
author_email="scott.stanie@gmail.com",
description="Download precise orbit files for Sentinel 1 products",
Expand Down

0 comments on commit fd41c56

Please sign in to comment.