AlexeyPechnikov / pygmtsar

PyGMTSAR (Python InSAR): Powerful and Accessible Satellite Interferometry
http://insar.dev/
BSD 3-Clause "New" or "Revised" License
430 stars 96 forks source link

Is the grid being interpolated before snaphu? #92

Open SteffanDavies opened 9 months ago

SteffanDavies commented 9 months ago

https://github.com/mobigroup/gmtsar/blob/b23580b9b6138752cc88bc5a63837c5197b1f036/pygmtsar/pygmtsar/Stack_unwrap_snaphu.py#L79

I can't seem to find any reference to interpolate_nearest in the code. Just filling nan with 0.

AlexeyPechnikov commented 9 months ago

The next line in the code also masks them using the SNAPHU mask, effectively excluding NaN pixels from unwrapping. This is a feature not present in GMTSAR processing. Additionally, like GMTSAR, we can use nearest-neighbor interpolation on the interferogram stack to fill NaN values:

sbas.interpolate_nearest(intf.where(...))
SteffanDavies commented 9 months ago

So is it preferred to use interpolation or 0 filling? How does it affect the results and speed?

AlexeyPechnikov commented 9 months ago

Masked values in the unwrapped phase lead to disconnected regions. Interpolation helps in connecting these regions for cases without phase jumps. In areas with high coherence, both masking and interpolation yield similar results. However, in low-coherence areas, the outcomes are unpredictable, and it's necessary to experiment to determine which method is more effective.

SteffanDavies commented 9 months ago

I was wondering because I am processing an area divided by a river. So maybe interpolation makes sense.

SteffanDavies commented 9 months ago

image Interpolation seems to be a lot faster.

AlexeyPechnikov commented 9 months ago

Interpolation works effectively when there are no significant phase jumps for the interpolated pixels. If your river area doesn't encompass vastly different topographies, interpolation should be a viable approach. Additionally, SNAPHU processes zero-gradient interpolated pixels quickly, as these do not necessitate complex change computations.