Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use conncomp.tif for connected component rasters #181

Merged
merged 3 commits into from
Dec 21, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Split apart the `dolphin.workflows.stitch_and_unwrap` module into `stitching_bursts` and `unwrapping`
- Switched output filename from `tcorr` to `temporal_coherence` for the temporal coherence of phase linking.
- Also added the date span to the `temporal_coherence` output name
- The default extension for conncomps is now `.tif`. Use geotiffs instead of ENVI format for connected components.


# [v0.7.0](https://github.com/isce-framework/dolphin/compare/v0.6.1...v0.7.0)
Expand Down
15 changes: 7 additions & 8 deletions src/dolphin/unwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

gdal.UseExceptions()

CONNCOMP_SUFFIX = ".unw.conncomp"
CONNCOMP_SUFFIX = ".unw.conncomp.tif"


@log_runtime
Expand Down Expand Up @@ -283,15 +283,14 @@ def unwrap(
dtype=np.float32,
options=opts,
)
# Always use ENVI for conncomp
conncomp_filename = str(unw_filename).replace(unw_suffix, CONNCOMP_SUFFIX)
io.write_arr(
arr=None,
output_name=conncomp_filename,
driver="ENVI",
driver="GTiff",
dtype=np.uint32,
like_filename=ifg_filename,
options=io.DEFAULT_ENVI_OPTIONS,
options=io.DEFAULT_TIFF_OPTIONS,
)

if use_snaphu:
Expand Down Expand Up @@ -513,19 +512,19 @@ def _get_cb_and_nodata(unwrap_method, unwrap_callback, nodata):
conncomp_filename = str(unw_filename).replace(unw_suffix, CONNCOMP_SUFFIX)

# SUFFIX=ADD
envi_options = dict(opt.lower().split("=") for opt in io.DEFAULT_ENVI_OPTIONS)
# Convert to something rasterio understands
gtiff_options = dict(opt.lower().split("=") for opt in io.DEFAULT_TIFF_OPTIONS)
logger.debug(f"Saving conncomps to {conncomp_filename}")
conncomp_rb = tophu.RasterBand(
conncomp_filename,
height=height,
width=width,
dtype=np.uint16,
driver="ENVI",
driver="GTiff",
crs=crs,
transform=transform,
**envi_options,
**gtiff_options,
)
gtiff_options = dict(opt.lower().split("=") for opt in io.DEFAULT_TIFF_OPTIONS)
unw_rb = tophu.RasterBand(
unw_filename,
height=height,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_unwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def test_unwrap_snaphu(tmp_path, raster_100_by_200, corr_raster):
init_method="mst",
)
assert unw_path == unw_filename
assert str(conncomp_path) == str(unw_filename).replace(".unw.tif", ".unw.conncomp")
assert str(conncomp_path) == str(unw_filename).replace(
".unw.tif", ".unw.conncomp.tif"
)
assert io.get_raster_xysize(unw_filename) == io.get_raster_xysize(raster_100_by_200)

# test other init_method
Expand Down