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
24 changes: 19 additions & 5 deletions src/dolphin/_cli_timeseries.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse
from pathlib import Path
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any

from dolphin.workflows import CallFunc

Expand Down Expand Up @@ -82,17 +82,18 @@ def get_parser(subparser=None, subcommand_name="timeseries") -> argparse.Argumen
)
parser.add_argument(
"--reference-point",
type=Optional[tuple[int, int]],
default=None,
type=int,
nargs=2,
metavar=("ROW", "COL"),
default=(-1, -1),
help="Reference point (row, col) used if performing a time series inversion. "
"If not provided, a point will be selected from a consistent connected "
"component with low amplitude dispersion or high temporal coherence.",
)
parser.add_argument(
"--correlation-threshold",
type=float,
type=range_limited_float_type,
default=0.2,
choices=range(1),
metavar="[0-1]",
help="Pixels with correlation below this value will be masked out.",
)
Expand All @@ -102,6 +103,19 @@ def get_parser(subparser=None, subcommand_name="timeseries") -> argparse.Argumen
return parser


def range_limited_float_type(arg):
"""Type function for argparse - a float within some predefined bounds."""
try:
f = float(arg)
except ValueError as err:
raise argparse.ArgumentTypeError("Must be a floating point number") from err
if f < 0 or f > 1:
raise argparse.ArgumentTypeError(
"Argument must be < " + str(1) + "and > " + str(0)
)
return f


def _run_timeseries(*args, **kwargs):
"""Run `dolphin.timeseries.run`.

Expand Down
6 changes: 3 additions & 3 deletions src/dolphin/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run(
velocity_file: Optional[PathOrStr] = None,
correlation_threshold: float = 0.2,
num_threads: int = 5,
reference_point: Optional[ReferencePoint] = None,
reference_point: tuple[int, int] = (-1, -1),
) -> list[Path]:
"""Invert the unwrapped interferograms, estimate timeseries and phase velocity.

Expand Down Expand Up @@ -88,15 +88,15 @@ def run(
Path(output_dir).mkdir(exist_ok=True, parents=True)

# First we find the reference point for the unwrapped interferograms
if reference_point is None:
if reference_point == (-1, -1):
reference = select_reference_point(
conncomp_paths,
condition_file,
output_dir=Path(output_dir),
condition_func=condition_func,
)
else:
reference = reference_point
reference = ReferencePoint(row=reference_point[0], col=reference_point[1])

ifg_date_pairs = [get_dates(f) for f in unwrapped_paths]
sar_dates = sorted(set(utils.flatten(ifg_date_pairs)))
Expand Down