{"id":34028678,"url":"https://github.com/isce-framework/snaphu-py","last_synced_at":"2026-04-01T19:18:14.011Z","repository":{"id":210820393,"uuid":"719773776","full_name":"isce-framework/snaphu-py","owner":"isce-framework","description":"A simple Python wrapper for SNAPHU","archived":false,"fork":false,"pushed_at":"2026-03-23T18:41:14.000Z","size":514,"stargazers_count":54,"open_issues_count":7,"forks_count":20,"subscribers_count":8,"default_branch":"main","last_synced_at":"2026-03-28T00:58:04.636Z","etag":null,"topics":["insar","phase-unwrapping","radar","remote-sensing","sar","synthetic-aperture-radar"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isce-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-Apache-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-11-16T21:48:58.000Z","updated_at":"2026-03-18T03:20:12.000Z","dependencies_parsed_at":"2023-12-08T02:27:29.032Z","dependency_job_id":"5726f5c8-e9a5-4b82-86a7-3541ca6dba44","html_url":"https://github.com/isce-framework/snaphu-py","commit_stats":{"total_commits":97,"total_committers":5,"mean_commits":19.4,"dds":0.6082474226804124,"last_synced_commit":"2d05645d99c9b84af047bd9e212219de7ece2816"},"previous_names":["isce-framework/snaphu-py"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/isce-framework/snaphu-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isce-framework%2Fsnaphu-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isce-framework%2Fsnaphu-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isce-framework%2Fsnaphu-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isce-framework%2Fsnaphu-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isce-framework","download_url":"https://codeload.github.com/isce-framework/snaphu-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isce-framework%2Fsnaphu-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31291117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["insar","phase-unwrapping","radar","remote-sensing","sar","synthetic-aperture-radar"],"created_at":"2025-12-13T17:15:41.919Z","updated_at":"2026-04-01T19:18:14.005Z","avatar_url":"https://github.com/isce-framework.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# snaphu-py\n\n[![CI](https://github.com/isce-framework/snaphu-py/actions/workflows/ci.yml/badge.svg)](https://github.com/isce-framework/snaphu-py/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/isce-framework/snaphu-py/graph/badge.svg?token=IV41TI56EA)](https://codecov.io/gh/isce-framework/snaphu-py)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/snaphu.svg)](https://anaconda.org/conda-forge/snaphu)\n[![PyPI - Version](https://img.shields.io/pypi/v/snaphu.svg)](https://pypi.org/project/snaphu)\n![OS](https://img.shields.io/badge/linux%20%7C%20macos-linux%20%7C%20macos?label=os\u0026color=blue)\n\nA simple Python wrapper for the Statistical-Cost, Network-Flow Algorithm for Phase\nUnwrapping (SNAPHU)\n\n## Installation\n\n### Install with conda\n\nYou can install snaphu-py with conda using\n\n```\n$ conda install -c conda-forge snaphu\n```\n\n### Install with pip\n\nYou can install snaphu-py with pip using\n\n```\n$ pip install snaphu\n```\n\n### Install from source\n\nTo install snaphu-py from source, you will need:\n\n- Python 3.9 or newer + pip\n- A C compiler\n\nThe latest source code can be installed using\n\n```\n$ pip install git+https://github.com/isce-framework/snaphu-py.git\n```\n\nAlternatively, clone the repository (be sure to use the `--recursive` flag to fetch the\nGit submodules) and install the local copy using\n\n```\n$ git clone --recursive https://github.com/isce-framework/snaphu-py.git\n$ cd snaphu-py\n$ pip install .\n```\n\n\u003e [!NOTE]\n\u003e [Editable installs] are experimentally supported, with some caveats and configuration.\n\u003e See [here] for details.\n\n[Editable installs]:\n  https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs\n[here]:\n  https://scikit-build-core.readthedocs.io/en/latest/configuration.html#editable-installs\n\n## Usage\n\n### Basic usage\n\nThe main interface is the `snaphu.unwrap` function, which takes input interferogram and\ncoherence arrays and returns the unwrapped phase and connected component labels.\n\nThe inputs may be NumPy arrays or any other type of object that supports a similar\ninterface (h5py Datasets, Zarr Arrays, etc).\n\nThe following example illustrates basic usage:\n\n```python\nimport numpy as np\nimport snaphu\n\n# Simulate a 512x512 interferogram containing a simple diagonal phase ramp with multiple\n# fringes.\ny, x = np.ogrid[-3:3:512j, -3:3:512j]\nigram = np.exp(1j * np.pi * (x + y))\n\n# Sample coherence for an interferogram with no noise.\ncorr = np.ones(igram.shape, dtype=np.float32)\n\n# Unwrap using the 'SMOOTH' cost mode and 'MCF' initialization method.\nunw, conncomp = snaphu.unwrap(igram, corr, nlooks=1.0, cost=\"smooth\", init=\"mcf\")\n```\n\nThe wrapped and unwrapped phase are shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" height=\"300\" src=\"docs/assets/basic-wrapped-unwrapped.png\"\u003e\n\u003c/p\u003e\n\n### Working with geospatial raster data\n\nOptional support for working with geospatial raster data is provided via the\n`snaphu.io.Raster` class, which implements a NumPy-like interface for accessing raster\ndata in [GDAL-compatible formats].\n\n*This functionality requires the [rasterio] package.*\n\n[GDAL-compatible formats]: https://gdal.org/drivers/raster/\n[rasterio]: https://rasterio.readthedocs.io/\n\n```python\nimport snaphu\n\n# Open the input interferogram and coherence rasters as well as a water mask.\nigram = snaphu.io.Raster(\"igram.tif\")\ncorr = snaphu.io.Raster(\"corr.tif\")\nmask = snaphu.io.Raster(\"mask.tif\")\n\n# Create output rasters to store the unwrapped phase \u0026 connected component labels with\n# the same shape, driver, CRS/geotransform, etc as the input interferogram raster.\nunw = snaphu.io.Raster.create(\"unw.tif\", like=igram, dtype=\"f4\")\nconncomp = snaphu.io.Raster.create(\"conncomp.tif\", like=igram, dtype=\"u4\")\n\n# Unwrap and store the results in the `unw` and `conncomp` rasters.\nsnaphu.unwrap(igram, corr, nlooks=50.0, mask=mask, unw=unw, conncomp=conncomp)\n```\n\nThe wrapped[^1] and unwrapped phase for an example case are shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" height=\"300\" src=\"docs/assets/raster-wrapped-unwrapped.png\"\u003e\n\u003c/p\u003e\n\n`snaphu.io.Raster` implements Python's [context manager protocol], so the above snippet\ncould also be written as:\n\n[context manager protocol]: https://peps.python.org/pep-0343/\n\n```python\nimport snaphu\n\n# Open the input rasters and create output rasters as context managers. The data will be\n# flushed and the files closed upon exiting the 'with' block. (Note that this syntax\n# requires Python 3.10 or newer -- see https://github.com/python/cpython/issues/56991.)\nwith (\n    snaphu.io.Raster(\"igram.tif\") as igram,\n    snaphu.io.Raster(\"corr.tif\") as corr,\n    snaphu.io.Raster(\"mask.tif\") as mask,\n    snaphu.io.Raster.create(\"unw.tif\", like=igram, dtype=\"f4\") as unw,\n    snaphu.io.Raster.create(\"conncomp.tif\", like=igram, dtype=\"u4\") as conncomp,\n):\n    # Unwrap and store the results in the `unw` and `conncomp` rasters.\n    snaphu.unwrap(igram, corr, nlooks=50.0, mask=mask, unw=unw, conncomp=conncomp)\n```\n\nThis has the advantage of ensuring that the raster datasets are flushed and closed upon\nexiting the `with` block.\n\n### Tiling and parallelism\n\nThe interferogram may be partitioned into multiple (possibly overlapping)\nregularly-sized rectangular blocks, each of which is unwrapped independently before\nbeing reassembled. This tiling strategy can significantly improve unwrapping runtime and\nreduce peak memory utilization, but may also introduce phase discontinuities between\ntiles. In order to mitigate such tiling artifacts, choosing a substantial overlap\nbetween tiles is recommended.\n\nMultiple tiles may be unwrapped simultaneously in parallel processes.\n\nThe following example demonstrates tiled unwrapping using multiple processes:\n\n```python\nimport numpy as np\nimport snaphu\n\n# Simulate a 2048x2048 interferogram containing a simple diagonal phase ramp with many\n# fringes.\ny, x = np.ogrid[-12:12:2048j, -12:12:2048j]\nigram = np.exp(1j * np.pi * (x + y))\n\n# Sample coherence for an interferogram with no noise.\ncorr = np.ones(igram.shape, dtype=np.float32)\n\n# Unwrap using a 4x4 grid of tiles in parallel using 8 processes.\nunw, conncomp = snaphu.unwrap(\n    igram, corr, nlooks=1.0, ntiles=(4, 4), tile_overlap=256, nproc=8\n)\n```\n\nThe wrapped and unwrapped phase are shown below.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"900\" height=\"300\" src=\"docs/assets/tiled-wrapped-unwrapped.png\"\u003e\n\u003c/p\u003e\n\n## FAQ\n\n### Why isn't [*some configuration parameter*] exposed?\n\nThe full set of SNAPHU parameters includes \u003e100 configurable options. This project takes\na pragmatic (and somewhat opinionated) approach to managing this complexity. Only the\nmost commonly manipulated parameters are exposed.\n\nIf there's an option that's not currently supported that you'd like to see added to the\ninterface, feel free to open an issue requesting the addition.\n\n### What version of SNAPHU is used?\n\nOur goal is to support the [latest available SNAPHU release]. The SNAPHU version used by\nthe library can be obtained using\n\n```python\n\u003e\u003e\u003e import snaphu\n\u003e\u003e\u003e print(snaphu.get_snaphu_version())\n```\n\n[latest available SNAPHU release]:\n  https://web.stanford.edu/group/radar/softwareandlinks/sw/snaphu/\n\n### What platforms are supported?\n\nUnix-like systems (e.g. Linux, macOS) are supported. Installation on Windows is not\ncurrently supported.\n\n## Copyright\n\nCopyright (c) 2023 California Institute of Technology (\"Caltech\"). U.S. Government\nsponsorship acknowledged.\n\nAll rights reserved.\n\n## License\n\nThis software is licensed under your choice of BSD-3-Clause or Apache-2.0 licenses. The\nexact terms of each license can be found in the accompanying [LICENSE-BSD-3-Clause] and\n[LICENSE-Apache-2.0] files, respectively.\n\n[LICENSE-BSD-3-Clause]: LICENSE-BSD-3-Clause\n[LICENSE-Apache-2.0]: LICENSE-Apache-2.0\n\nSPDX-License-Identifier: BSD-3-Clause OR Apache-2.0\n\n\u003e [!NOTE]\n\u003e The SNAPHU source code (which is included as a Git submodule) is subject to different\n\u003e license terms, the details of which can be found [here]. In particular, note that\n\u003e parts of the SNAPHU codebase are subject to terms that prohibit commercial use.\n\n[here]: https://github.com/gmgunter/snaphu/blob/main/README\n\n[^1]: InSAR product processed by ASF DAAC HyP3 2023 using GAMMA software. Contains\n  modified Copernicus Sentinel data 2023, processed by ESA.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisce-framework%2Fsnaphu-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisce-framework%2Fsnaphu-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisce-framework%2Fsnaphu-py/lists"}