Skip to content

Commit

Permalink
Change is_single_reference to only look for number of interferograms (
Browse files Browse the repository at this point in the history
#436)

* Skip network inversion for any set of `n-1` interferograms

* dedupe a possible `dayN_dayN` interferogram

* remove comments from requirements files

* fix ref change test
  • Loading branch information
scottstanie authored Sep 26, 2024
1 parent b8ad94c commit 868d70b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
5 changes: 2 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# mkdocs requirements
markdown # for mdx_bib
markdown
mkdocs
mkdocs-gen-files
mkdocs-jupyter
mkdocs-literate-nav
mkdocs-material
mkdocs-section-index
mkdocstrings[python]
pybtex # for mdx_bib
pybtex
pymdown-extensions
11 changes: 6 additions & 5 deletions src/dolphin/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def run(

condition_func = argmax_index if condition == CallFunc.MAX else argmin_index
if reference_point == (-1, -1):
logger.info("Selecting a reference point for unwrapped interferograms")
ref_point = select_reference_point(
condition_file=condition_file,
output_dir=Path(output_dir),
Expand All @@ -142,9 +143,11 @@ def run(
sar_dates = sorted(set(utils.flatten(ifg_date_pairs)))
# if we did single-reference interferograms, for `n` sar dates, we will only have
# `n-1` interferograms. Any more than n-1 ifgs means we need to invert
is_single_reference = (len(unwrapped_paths) == len(sar_dates) - 1) and all(
pair[0] == ifg_date_pairs[0][0] for pair in ifg_date_pairs
)
is_single_reference = len(unwrapped_paths) == len(sar_dates) - 1
# TODO: Do we ever want to invert this case: the "trivial" network,
# which has 1 ifg per date difference, but a moving reference date?
# The extra condition to check is
# ... and all(pair[0] == ifg_date_pairs[0][0] for pair in ifg_date_pairs)

# check if we even need to invert, or if it was single reference
inverted_phase_paths: list[Path] = []
Expand All @@ -160,8 +163,6 @@ def run(
wavelength=wavelength,
)
else:
logger.info("Selecting a reference point for unwrapped interferograms")

logger.info("Inverting network of %s unwrapped ifgs", len(unwrapped_paths))
inverted_phase_paths = invert_unw_network(
unw_file_list=unwrapped_paths,
Expand Down
4 changes: 4 additions & 0 deletions src/dolphin/workflows/wrapped_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ def create_ifgs(
written_ifgs = set(ifg_dir.glob("*.int*"))
for p in written_ifgs - requested_ifgs:
p.unlink()

if len(set(get_dates(ifg_file_list[0]))) == 1:
same_date_ifg = ifg_file_list.pop(0)
same_date_ifg.unlink()
return ifg_file_list


Expand Down
6 changes: 3 additions & 3 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pooch
pre-commit
pytest
pytest-cov
pytest-randomly # control random seed
pytest-xdist # parallel tests: https://pytest-xdist.readthedocs.io/en/latest/
pytest-randomly
pytest-xdist
shapely
xarray # For dolphin.atmosphere tests
xarray
6 changes: 2 additions & 4 deletions tests/test_workflows_displacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,18 @@ def test_displacement_run_extra_reference_date(opera_slc_files: list[Path], tmpd
# The "base phase" should be 20220103
assert slc_paths[0].name == "compressed_20220103_20220102_20220104.tif"

# The unwrappd files should have a changeover to the new reference
# The unwrapped/timeseries files should have a changeover to the new reference
assert paths.unwrapped_paths is not None
unw_names = [pp.name for pp in paths.unwrapped_paths]
assert unw_names == [
"20220101_20220102.unw.tif",
"20220101_20220103.unw.tif",
"20220103_20220104.unw.tif",
]

# But the timeseries will have inverted the results
assert paths.timeseries_paths is not None
ts_names = [pp.name for pp in paths.timeseries_paths]
assert ts_names == [
"20220101_20220102.tif",
"20220101_20220103.tif",
"20220101_20220104.tif",
"20220103_20220104.tif",
]

0 comments on commit 868d70b

Please sign in to comment.