Module: sarpyx.cli.utils

File: sarpyx/cli/utils.py

Utility functions for SARPyX CLI tools. This module provides common utility functions used across multiple CLI commands.

Exported Symbols (__all__)

No explicit __all__ list. Public symbols inferred from implementation.

Public Functions (8)

validate_path function

Validate and convert a path string to a Path object.

File location: sarpyx/cli/utils.py:13

Signature

validate_path(path: Union[str, Path], must_exist: bool=True) -> Path

Parameters

ParameterTypeRequiredDefaultDescription
pathUnion[str, Path]yes-Path string or Path object to validate.
must_existboolnoTrueWhether the path must exist.

Return Type

Path

Validated Path object.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • io

Example Usage

from sarpyx.cli.utils import validate_path

result = validate_path(path=<path>)

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

create_output_directory function

Create output directory if it doesn't exist.

File location: sarpyx/cli/utils.py:36

Signature

create_output_directory(output_dir: Union[str, Path]) -> Path

Parameters

ParameterTypeRequiredDefaultDescription
output_dirUnion[str, Path]yes-Output directory path.

Return Type

Path

Path object for the output directory.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • io

Example Usage

from sarpyx.cli.utils import create_output_directory

result = create_output_directory(output_dir=<output_dir>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

check_snap_installation function

Check if SNAP GPT is available.

File location: sarpyx/cli/utils.py:59

Signature

check_snap_installation(gpt_path: Optional[str]=None) -> bool

Parameters

ParameterTypeRequiredDefaultDescription
gpt_pathOptional[str]noNoneOptional path to GPT executable.

Return Type

bool

True if SNAP GPT is available, False otherwise.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • subprocess

Example Usage

from sarpyx.cli.utils import check_snap_installation

result = check_snap_installation()

Edge Cases

Includes optional parameters with implementation-defined fallback behavior.

print_processing_summary function

Print a summary of processing parameters.

File location: sarpyx/cli/utils.py:110

Signature

print_processing_summary(product_path: str, output_path: str, parameters: Dict[str, Union[str, float, bool, List[str]]]) -> None

Parameters

ParameterTypeRequiredDefaultDescription
product_pathstryes-Input product path.
output_pathstryes-Output path.
parametersDict[str, Union[str, float, bool, List[str]]]yes-Dictionary of processing parameters.

Return Type

None

inferred from implementation.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • io

Example Usage

from sarpyx.cli.utils import print_processing_summary

result = print_processing_summary(product_path=<product_path>, output_path=<output_path>, parameters=<parameters>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

format_file_size function

Format file size in human-readable format.

File location: sarpyx/cli/utils.py:141

Signature

format_file_size(size_bytes: int) -> str

Parameters

ParameterTypeRequiredDefaultDescription
size_bytesintyes-Size in bytes.

Return Type

str

Formatted size string.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.cli.utils import format_file_size

result = format_file_size(size_bytes=<size_bytes>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

get_product_info function

Extract basic information from a SAR product path.

File location: sarpyx/cli/utils.py:163

Signature

get_product_info(product_path: Union[str, Path]) -> Dict[str, str]

Parameters

ParameterTypeRequiredDefaultDescription
product_pathUnion[str, Path]yes-Path to SAR product.

Return Type

Dict[str, str]

Dictionary with product information.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.cli.utils import get_product_info

result = get_product_info(product_path=<product_path>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

validate_window_sizes function

Validate that window sizes are in correct relationship.

File location: sarpyx/cli/utils.py:207

Signature

validate_window_sizes(target_window: float, guard_window: float, background_window: float) -> None

Parameters

ParameterTypeRequiredDefaultDescription
target_windowfloatyes-Target window size.
guard_windowfloatyes-Guard window size.
background_windowfloatyes-Background window size.

Return Type

None

inferred from implementation.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • io

Example Usage

from sarpyx.cli.utils import validate_window_sizes

result = validate_window_sizes(target_window=<target_window>, guard_window=<guard_window>, background_window=<background_window>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

estimate_processing_time function

Provide a rough estimate of processing time based on product size.

File location: sarpyx/cli/utils.py:239

Signature

estimate_processing_time(product_path: Union[str, Path]) -> str

Parameters

ParameterTypeRequiredDefaultDescription
product_pathUnion[str, Path]yes-Path to SAR product.

Return Type

str

Estimated processing time string.

Exceptions

None explicitly documented; inferred from implementation.

Side Effects

  • inferred from implementation

Example Usage

from sarpyx.cli.utils import estimate_processing_time

result = estimate_processing_time(product_path=<product_path>)

Edge Cases

No explicit edge-case section found; behavior is inferred from implementation.

Public Classes (0)

No public classes detected.