Skip to content

Commit

Permalink
Only do nearest-3 similarity if were unwrapping short baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie committed Oct 22, 2024
1 parent 2b01391 commit 2ef8204
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/dolphin/workflows/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def run_wrapped_phase_sequential(
shp_nslc: Optional[int] = None,
use_evd: bool = False,
beta: float = 0.00,
similarity_nearest_n: int | None = None,
compressed_slc_plan: CompressedSlcPlan = CompressedSlcPlan.ALWAYS_FIRST,
max_num_compressed: int = 100,
output_reference_idx: int = 0,
Expand Down Expand Up @@ -129,6 +130,7 @@ def already_processed(d: Path, search_ext: str = ".tif") -> bool:
shp_method=shp_method,
shp_alpha=shp_alpha,
shp_nslc=shp_nslc,
similarity_nearest_n=similarity_nearest_n,
block_shape=block_shape,
baseline_lag=baseline_lag,
**tqdm_kwargs,
Expand Down Expand Up @@ -169,8 +171,9 @@ def already_processed(d: Path, search_ext: str = ".tif") -> bool:
search_radius=11,
sim_type="median",
block_shape=block_shape,
nearest_n=3,
nearest_n=similarity_nearest_n,
num_threads=2,
add_overviews=False,
)
else:
output_similarity_file = similarity_files[0].rename(
Expand Down
3 changes: 2 additions & 1 deletion src/dolphin/workflows/single.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def run_wrapped_phase_single(
shp_method: ShpMethod = ShpMethod.NONE,
shp_alpha: float = 0.05,
shp_nslc: Optional[int] = None,
similarity_nearest_n: int | None = None,
block_shape: tuple[int, int] = (1024, 1024),
baseline_lag: Optional[int] = None,
**tqdm_kwargs,
Expand Down Expand Up @@ -298,7 +299,7 @@ def run_wrapped_phase_single(
output_file=output_folder / f"similarity_{start_end}.tif",
num_threads=2,
add_overviews=False,
nearest_n=3,
nearest_n=similarity_nearest_n,
)

written_comp_slc = output_files[0]
Expand Down
18 changes: 18 additions & 0 deletions src/dolphin/workflows/wrapped_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def run(
logger.info(f"Running sequential EMI step in {pl_path}")
kwargs = tqdm_kwargs | {"desc": f"Phase linking ({pl_path})"}

# Figure out if we should compute phase similarity based on single-ref,
# or using nearest-3 interferograms
is_single_ref = _is_single_reference_network(
cfg.interferogram_network, cfg.unwrap_options.unwrap_method
)
similarity_nearest_n = None if is_single_ref else 3

# TODO: Need a good way to store the nslc attribute in the PS file...
# If we pre-compute it from some big stack, we need to use that for SHP
# finding, not use the size of `slc_vrt_file`
Expand Down Expand Up @@ -186,6 +193,7 @@ def run(
shp_method=cfg.phase_linking.shp_method,
shp_alpha=cfg.phase_linking.shp_alpha,
shp_nslc=shp_nslc,
similarity_nearest_n=similarity_nearest_n,
cslc_date_fmt=cfg.input_options.cslc_date_fmt,
block_shape=cfg.worker_settings.block_shape,
baseline_lag=cfg.phase_linking.baseline_lag,
Expand Down Expand Up @@ -496,3 +504,13 @@ def _get_mask(
mask_filename = nodata_mask_file

return mask_filename


def _is_single_reference_network(
ifg_network: InterferogramNetwork, unwrap_method: UnwrapMethod
):
return (
unwrap_method != UnwrapMethod.SPURT
and ifg_network.max_bandwidth is None
and ifg_network.max_temporal_baseline is None
)

0 comments on commit 2ef8204

Please sign in to comment.