unwrap
raw JSON → 0.1.1 verified Sat May 09 auth: no python maintenance
A Python library for 2D and 3D phase unwrapping using a quality-guided algorithm. Version 0.1.1, released in 2014, with no recent updates.
pip install unwrap Common errors
error ImportError: cannot import name 'unwrap2d' from 'unwrap' ↓
cause Installation may have failed or the package version is very old. Also common when using pip with an outdated index or on Python 3.
fix
Run: pip install --upgrade unwrap. If still failing, check Python version compatibility (works best with Python 2.7). For Python 3, try using a virtual environment with Python 2.7.
error TypeError: unwrap2d() takes exactly 1 argument (2 given) ↓
cause The function signature expects only one positional argument (the array), but users sometimes pass additional parameters like mask.
fix
Use: unwrapped = unwrap2d(wrapped_phase) . No extra arguments supported.
error AttributeError: 'numpy.ndarray' object has no attribute 'flatten' ↓
cause Numpy version mismatch: older versions of the library called .flatten() which was removed in newer numpy. Occurs with numpy >=1.24.
fix
Downgrade numpy to 1.23.5: pip install numpy==1.23.5
Warnings
gotcha Functions expect input in radians (values between -pi and pi). Using degrees or other ranges will produce incorrect unwrapping without error. ↓
fix Ensure input is in radians, typically by converting degrees * np.pi / 180.
gotcha The library does not handle NaN or Inf values. Presence of such values may cause silent failures or incorrect results. ↓
fix Preprocess input to replace NaN/Inf with neighboring valid values or mask them before passing to unwrap.
deprecated Library is unmaintained since 2014. No support for Python 3.x beyond early versions, and no bug fixes. ↓
fix Consider using alternative libraries like 'skimage.restoration.unwrap_phase' or 'np.unwrap' for simpler cases.
Imports
- unwrap2d wrong
import unwrapcorrectfrom unwrap import unwrap2d - unwrap3d wrong
unwrapping.unwrap3dcorrectfrom unwrap import unwrap3d
Quickstart
import numpy as np
from unwrap import unwrap2d, unwrap3d
# 2D example: wrapped phase in [-pi, pi)
wrapped = np.random.uniform(-np.pi, np.pi, (10, 10))
unwrapped = unwrap2d(wrapped)
# 3D example
wrapped_3d = np.random.uniform(-np.pi, np.pi, (5, 10, 10))
unwrapped_3d = unwrap3d(wrapped_3d)