Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sample_type_to_save = self.DTYPES[self._sample_type[0] + self.dtype.kind]
self.label['IMAGE']['SAMPLE_TYPE'] = sample_type_to_save
if len(self.data.shape) == 3:
self.label['IMAGE']['BANDS'] = self.data.shape[0]
self.label['IMAGE']['LINES'] = self.data.shape[1]
self.label['IMAGE']['LINE_SAMPLES'] = self.data.shape[2]
else:
self.label['IMAGE']['BANDS'] = 1
self.label['IMAGE']['LINES'] = self.data.shape[0]
self.label['IMAGE']['LINE_SAMPLES'] = self.data.shape[1]
diff = 0
if len(pvl.dumps(self.label, cls=encoder)) != label_sz:
diff = abs(label_sz - len(pvl.dumps(self.label, cls=encoder)))
pvl.dump(self.label, file_to_write, cls=encoder)
offset = image_pointer * self.label['RECORD_BYTES'] - label_sz
stream = open(file_to_write, 'a')
for i in range(0, offset+diff):
stream.write(" ")
if (self._bands > 1 and self._format != 'BAND_SEQUENTIAL'):
raise NotImplementedError
else:
self.data.tofile(stream, format='%' + self.dtype.kind)
stream.close()