Gradient Unwarping in Python