Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view: convert integer to floating to enable masking with nan #1289

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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