Skip to content

Commit

Permalink
Enhance 1D unwrapping functions to return the original values when un…
Browse files Browse the repository at this point in the history
…wrapping is not possible at all
  • Loading branch information
AlexeyPechnikov committed Apr 11, 2024
1 parent 1d69265 commit 1c50f85
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pygmtsar/pygmtsar/Stack_unwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,19 @@ def unwrap_pairs(data : np.ndarray,
#print ()
#break

# return unwrapped and original values
return buffer

# # return unwrapped values only
# # validity mask
# mask = [idx in pairs_ok for idx in range(buffer.size)]
# #mask = np.isin(np.arange(buffer.size), pairs_ok)
# # output is the same size as input
# #out = np.nan * np.zeros(data.size)
# out = np.full(data.size, np.nan, dtype=np.float32)
# out[~nanmask] = np.where(mask, buffer, np.nan)
# #out[~nanmask] = np.where(mask[~nanmask], buffer[~nanmask], np.nan)
# return out
# return original values when unwrapping is not possible at all
if len(pairs_ok) == 0:
return buffer
# return unwrapped values
# validity mask
mask = [idx in pairs_ok for idx in range(buffer.size)]
#mask = np.isin(np.arange(buffer.size), pairs_ok)
# output is the same size as input
#out = np.nan * np.zeros(data.size)
out = np.full(data.size, np.nan, dtype=np.float32)
out[~nanmask] = np.where(mask, buffer, np.nan)
#out[~nanmask] = np.where(mask[~nanmask], buffer[~nanmask], np.nan)
return out

def unwrap1d(self, data, weight=None, tolerance=np.pi/2):
import xarray as xr
Expand Down

0 comments on commit 1c50f85

Please sign in to comment.