Skip to content

Commit

Permalink
Add usage example to docs (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie authored Oct 10, 2023
1 parent 36f87d8 commit b041f8e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ interferometric synthetic aperture radar (InSAR).
:hidden:

installation
usage
reference
changelog
54 changes: 54 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Usage
#####

Basic usage with raster files
=============================

.. code-block:: python
from tophu import RasterBand, SnaphuUnwrap, multiscale_unwrap
import rasterio as rio
# Create `RasterBand`s from the input interferogram and coherence.
igram = RasterBand(ifg_filename)
coherence = RasterBand(corr_filename)
# Create the output raster bands.
# Start by copying the input geographic metadata.
with rio.open(ifg_filename) as src:
profile = src.profile
# The unwrapped phase will be float32.
profile["dtype"] = np.float32
profile["driver"] = "GTiff"
unw = RasterBand("unwrapped_phase.unw.tif", **profile)
# Create the connected component labels raster.
profile["dtype"] = np.uint16
conncomp = RasterBand("connected_components.tif", **profile)
# Choose which unwrapper we will use.
# Here we pick SNAPHU.
unwrap_callback = SnaphuUnwrap(
cost="smooth",
init_method="mst",
)
# Set the number of looks used to form the coherence.
nlooks = 40
# Choose the tiling scheme and the downsample factor for the coarse unwrap.
ntiles = (2, 2)
downsample_factor = (3, 3)
# Run the multiscale unwrapping function.
multiscale_unwrap(
unw,
conncomp,
igram,
coherence,
nlooks=nlooks,
unwrap_func=unwrap_callback,
downsample_factor=downsample_factor,
ntiles=ntiles,
)

0 comments on commit b041f8e

Please sign in to comment.