phidown.cli

Command-line interface for phidown download operations.

This module provides a CLI for downloading Copernicus Data Space products and PhiSat-2 INSULA platform files.

Attributes

logger

Functions

_compute_backoff_delay(attempt_index, backoff_base, ...) → float

Compute retry delay with exponential backoff and jitter.

_dir_has_files(directory) → bool

_warn_deprecated_option(option_name, replacement) → None

_resolve_download_mode([mode, resume_mode, ...]) → str

_parse_bbox_to_wkt(bbox) → str

Convert bbox values (csv string or 4-item sequence) to WKT polygon.

_parse_columns(columns) → Optional[List[str]]

Parse comma-separated columns into a list.

_render_listing_output(df, *, selected_columns, ...) → bool

download_by_name(product_name, output_dir[, ...]) → bool

Download a product by name from the selected provider.

download_by_s3path(s3_path, output_dir[, config_file, ...]) → bool

Download a product directly using its S3 path.

list_products(collection[, product_type, ...]) → bool

List products with AOI/date filters and optional output formats.

burst_coverage_analysis([aoi_wkt, bbox, start_date, ...]) → bool

Run Sentinel-1 burst coverage analysis over AOI and dates.

_validate_list_args(parser, args, mode_label) → None

Validate required spatial/temporal args for list operations.

_validate_phisat2_list_args(parser, args, mode_label) → None

Validate required inputs for PhiSat-2 list operations.

_main_list_subcommand([argv]) → None

Handle phidown list ... subcommand.

_main_merge_bursts_subcommand([argv]) → None

Handle phidown merge-bursts ....

main() → None

Main entry point for phidown CLI.

Module Contents

phidown.cli.logger[source]
phidown.cli._compute_backoff_delay(attempt_index: int, backoff_base: float, backoff_max: float) → float[source]

Compute retry delay with exponential backoff and jitter.

phidown.cli._dir_has_files(directory: str) → bool[source]
phidown.cli._warn_deprecated_option(option_name: str, replacement: str) → None[source]
phidown.cli._resolve_download_mode(mode: str = 'fast', *, resume_mode: str | None = None, connect_timeout: float = 30.0, read_timeout: float | None = None, robust: bool = False) → str[source]
phidown.cli._parse_bbox_to_wkt(bbox: str | Sequence[float]) → str[source]

Convert bbox values (csv string or 4-item sequence) to WKT polygon.

phidown.cli._parse_columns(columns: str | None) → List[str] | None[source]

Parse comma-separated columns into a list.

phidown.cli._render_listing_output(df, *, selected_columns: List[str] | None, default_columns: List[str], output_format: str, save_path: str | None, saved_message: str, listed_message: str) → bool[source]
phidown.cli.download_by_name(product_name: str, output_dir: str, config_file: str = '.s5cfg', mode: str = 'fast', show_progress: bool = True, reset_config: bool = False, retry_count: int = 1, connect_timeout: float = 30.0, read_timeout: float | None = None, state_file: str | None = None, resume_mode: str | None = None, s5cmd_retry_count: int | None = None, max_workers: int | None = None, backoff_base: float = 2.0, backoff_max: float = 60.0, provider: str = 'cdse') → bool[source]

Download a product by name from the selected provider.

Parameters:
  • product_name – Product name or unique token to download.

  • output_dir – Directory where the product will be downloaded.

  • config_file – Path to s5cmd configuration file with credentials.

  • mode – Download mode (‘fast’ for s5cmd, ‘safe’ for resumable native downloads).

  • show_progress – Whether to display download progress bar.

  • reset_config – Whether to reset configuration and prompt for credentials.

  • retry_count – Number of command-level retry attempts.

  • connect_timeout – Network connection timeout in seconds for native transfers.

  • read_timeout – Network read timeout in seconds for native transfers.

  • state_file – Optional JSON state file path for resumable runs.

  • resume_mode – Deprecated legacy resume selector. Prefer mode.

  • s5cmd_retry_count – Optional internal retry count for s5cmd.

  • max_workers – Optional worker count for s5cmd.

  • backoff_base – Base delay in seconds for retry backoff.

  • backoff_max – Max delay in seconds for retry backoff.

  • provider – Download backend (cdse or phisat2).

Returns:

True if download was successful, False otherwise.

Return type:

bool

Example

>>> success = download_by_name(
...     'S1A_IW_GRDH_1SDV_20240503T031929_20240503T031942_053701_0685FB_7532_COG',
...     '/path/to/output'
... )
phidown.cli.download_by_s3path(s3_path: str, output_dir: str, config_file: str = '.s5cfg', mode: str = 'fast', show_progress: bool = True, reset_config: bool = False, download_all: bool = True, retry_count: int = 1, connect_timeout: float = 30.0, read_timeout: float | None = None, state_file: str | None = None, resume_mode: str | None = None, s5cmd_retry_count: int | None = None, max_workers: int | None = None, backoff_base: float = 2.0, backoff_max: float = 60.0) → bool[source]

Download a product directly using its S3 path.

Parameters:
  • s3_path – S3 path of the product (starting with /eodata/).

  • output_dir – Directory where the product will be downloaded.

  • config_file – Path to s5cmd configuration file with credentials.

  • mode – Download mode (‘fast’ for s5cmd, ‘safe’ for resumable native downloads).

  • show_progress – Whether to display download progress bar.

  • reset_config – Whether to reset configuration and prompt for credentials.

  • download_all – If True, downloads entire directory; otherwise specific file.

  • retry_count – Number of command-level retry attempts.

  • connect_timeout – Network connection timeout in seconds for native transfers.

  • read_timeout – Network read timeout in seconds for native transfers.

  • state_file – Optional JSON state file path for resumable runs.

  • resume_mode – Deprecated legacy resume selector. Prefer mode.

  • s5cmd_retry_count – Optional internal retry count for s5cmd.

  • max_workers – Optional worker count for s5cmd.

  • backoff_base – Base delay in seconds for retry backoff.

  • backoff_max – Max delay in seconds for retry backoff.

Returns:

True if download was successful, False otherwise.

Return type:

bool

Example

>>> success = download_by_s3path(
...     '/eodata/Sentinel-1/SAR/IW_GRDH_1S/2024/05/03/...',
...     '/path/to/output'
... )
phidown.cli.list_products(collection: str, product_type: str | None = None, orbit_direction: str | None = None, cloud_cover: float | None = None, aoi_wkt: str | None = None, bbox: str | Sequence[float] | None = None, start_date: str | None = None, end_date: str | None = None, top: int = 50, order_by: str = 'ContentDate/Start desc', output_format: str = 'table', columns: str | None = None, save_path: str | None = None, provider: str = 'cdse', config_file: str = '.s5cfg', reset_config: bool = False, search_filter: str | None = None) → bool[source]

List products with AOI/date filters and optional output formats.

phidown.cli.burst_coverage_analysis(aoi_wkt: str | None = None, bbox: str | Sequence[float] | None = None, start_date: str | None = None, end_date: str | None = None, polarisation: str = 'VV', orbit_direction: str | None = None, relative_orbit_number: int | None = None, preferred_subswath: str | None = None, output_format: str = 'table', columns: str | None = None, save_path: str | None = None) → bool[source]

Run Sentinel-1 burst coverage analysis over AOI and dates.

phidown.cli._validate_list_args(parser: argparse.ArgumentParser, args: argparse.Namespace, mode_label: str) → None[source]

Validate required spatial/temporal args for list operations.

phidown.cli._validate_phisat2_list_args(parser: argparse.ArgumentParser, args: argparse.Namespace, mode_label: str) → None[source]

Validate required inputs for PhiSat-2 list operations.

phidown.cli._main_list_subcommand(argv: Sequence[str] | None = None) → None[source]

Handle phidown list … subcommand.

phidown.cli._main_merge_bursts_subcommand(argv: Sequence[str] | None = None) → None[source]

Handle phidown merge-bursts ....

phidown.cli.main() → None[source]

Main entry point for phidown CLI.