SEGYImport run on segy with format codes 3 and 8 creates wrong data
SEGYImport states to support the following data sample format codes:
3 = 2-byte, two's complement integer
8 = 1-byte, two's complement integer
Yet the conversion results seem wrong.
Attached are the synthetic files with 3 ilines and xlines 100_as_format_3.segy100_as_format_8.segy.
Formats are 3 and 8.
All the values in the files equal to 100. [One can see that data is stored as 00 64
(format 3) and 64
(format 8) which correspond to two's complement integer notation. Processing tools also read the data as 100
.]
Running
SEGYImport --vdsfile 100_as_format_8.vds 100_as_format_8.segy
SEGYImport --vdsfile 100_as_format_3.vds 100_as_format_3.segy
creates vds files with corresponding formats:
"format" : "Format_U16"
"format" : "Format_U8"
Running modified code from one of the examples
sliceDimension=2
sliceIndex=0
accessManager = openvds.getAccessManager(vds)
layout = openvds.getLayout(vds)
axisDescriptors = [layout.getAxisDescriptor(dim) for dim in range(layout.getDimensionality())]
min = tuple(sliceIndex + 0 if dim == sliceDimension else 0 for dim in range(6))
max = tuple(sliceIndex + 1 if dim == sliceDimension else layout.getDimensionNumSamples(dim) for dim in range(6))
req = accessManager.requestVolumeSubset(min, max, format = format)
height = max[0] if sliceDimension != 0 else max[1]
width = max[2] if sliceDimension != 2 else max[1]
data = req.data.reshape(width, height).transpose()
print(data)
with
vds=openvds.open("100_as_format_3.vds")
format = openvds.VolumeDataChannelDescriptor.Format.Format_U16
gives a slice of 32868
and with
vds=openvds.open("100_as_format_8.vds")
format = openvds.VolumeDataChannelDescriptor.Format.Format_U8
gives a slice of 228
which are not 100
.
This seems to be caused by code adding 32768 and 128 to the values respectively, but I fail to see why it was there in the first place. All other supported format codes in spot-tests returned the expected values (check was run on little-endian only system/files).
Is there something I misunderstand about these two codes?