Skip to content

Commit

Permalink
view: convert integer to floating to enable masking with nan (#1289)
Browse files Browse the repository at this point in the history
+ view.viewer.plot(): convert integer to floating to enable masking with nan for one subplot scenario
  • Loading branch information
yunjunz authored Nov 11, 2024
1 parent 0c1878d commit 718027c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mintpy/utils/readfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def read_binary_file(fname, datasetName=None, box=None, xstep=1, ystep=1):
cpx_band = 'magnitude'

elif fext in ['.mli', '.rmli']:
byte_order = 'little-endian'
byte_order = 'little-endian' # big-endian

# SNAP
# BEAM-DIMAP data format
Expand Down
6 changes: 6 additions & 0 deletions src/mintpy/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1652,9 +1652,15 @@ def plot(self):
no_data_val = readfile.get_no_data_value(self.file)
if self.no_data_value is not None:
vprint(f'masking pixels with NO_DATA_VALUE of {self.no_data_value}')
# convert integer to floating to enable masking with nan
if np.issubdtype(data.dtype, np.integer):
data = np.array(data, np.float32)
data[data == self.no_data_value] = np.nan
elif no_data_val is not None and not np.isnan(no_data_val):
vprint(f'masking pixels with NO_DATA_VALUE of {no_data_val}')
# convert integer to floating to enable masking with nan
if np.issubdtype(data.dtype, np.integer):
data = np.array(data, np.float32)
data[data == no_data_val] = np.nan

# update/save mask info
Expand Down

0 comments on commit 718027c

Please sign in to comment.