Beispiel #1
0
 def write_bin(shape, file_out, data, bintype=None, header_data=None):
     dtype = data.dtype
     if dtype.kind != 'i':
         if bintype is not None:
             if header_data is None:
                 header_data = BinaryHeader.create(bintype=bintype)
         if header_data is not None:
             header_data.tofile(file_out)
     data.tofile(file_out)
     return
Beispiel #2
0
 def load_bin(shape, file_in, dtype, bintype=None):
     nrow, ncol = shape
     if bintype is not None:
         if dtype not in [np.int]:
             header_dtype = BinaryHeader.set_dtype(bintype=bintype)
         header_data = np.fromfile(file_in, dtype=header_dtype, count=1)
     else:
         header_data = None
     data = np.fromfile(file_in, dtype=dtype, count=nrow * ncol)
     data.resize(nrow, ncol)
     return [header_data, data]