Skip to content

Commit 065e1e2

Browse files
sssanghayunjunz
andauthored
readfile: support float16 data type via gdal (#1483)
* Add support for float16 data type in `readfile.py`, because for GDAL >= 3.11 you will run into `Key 15` error when trying to read float16 format files * writefile.write(): add float16 in the supported data types --------- Co-authored-by: Zhang Yunjun <yunjunz@outlook.com>
1 parent 31a89af commit 065e1e2

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/mintpy/utils/readfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
12: 'uint64',
139139
13: 'int64',
140140
14: 'int8', # GDAL >= 3.7
141+
15: 'float16', # GDAL >= 3.11
141142
}
142143

143144
DATA_TYPE_NUMPY2GDAL = {
@@ -155,6 +156,7 @@
155156
"uint64" : 12, # GDT_UInt64 (GDAL >= 3.5)
156157
"int64" : 13, # GDT_Int64 (GDAL >= 3.5)
157158
"int8" : 14, # GDT_Int8 (GDAL >= 3.7)
159+
"float16" : 15, # GDT_Float16 (GDAL >= 3.11)
158160
}
159161

160162
# 3 - ISCE

src/mintpy/utils/writefile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ def write(datasetDict, out_file, metadata=None, ref_file=None, compression=None,
209209
elif fext == '.msk':
210210
meta['DATA_TYPE'] = 'int8'
211211

212-
data_types = ['bool', 'int8', 'uint8', 'int16', 'float32', 'float64', 'complex32', 'complex64', 'complex128']
212+
data_types = ['bool', 'int8', 'uint8', 'int16', 'float16', 'float32',
213+
'float64', 'complex32', 'complex64', 'complex128']
213214
if meta['DATA_TYPE'] not in data_types:
214215
msg = 'Un-supported file type "{}" with data type "{}"!'.format(fext, meta['DATA_TYPE'])
215216
msg += f'\nSupported data type list: {data_types}'

0 commit comments

Comments
 (0)