(file)
| 11 | TAG_FLOAT = 202021.25 |
| 12 | |
| 13 | def read(file): |
| 14 | assert type(file) is str, "file is not str %r" % str(file) |
| 15 | assert os.path.isfile(file) is True, "file does not exist %r" % str(file) |
| 16 | assert file[-4:] == '.flo', "file ending is not .flo %r" % file[-4:] |
| 17 | f = open(file,'rb') |
| 18 | flo_number = np.fromfile(f, np.float32, count=1)[0] |
| 19 | assert flo_number == TAG_FLOAT, 'Flow number %r incorrect. Invalid .flo file' % flo_number |
| 20 | w = np.fromfile(f, np.int32, count=1) |
| 21 | h = np.fromfile(f, np.int32, count=1) |
| 22 | #if error try: data = np.fromfile(f, np.float32, count=2*w[0]*h[0]) |
| 23 | # data = np.fromfile(f, np.float32, count=2*w*h) |
| 24 | data = np.fromfile(f, np.float32, count=2*w[0]*h[0]) |
| 25 | # Reshape data into 3D array (columns, rows, bands) |
| 26 | flow = np.resize(data, (int(h), int(w), 2)) |
| 27 | f.close() |
| 28 | return flow |
| 29 | |
| 30 | |
| 31 | def makeColorwheel(): |
nothing calls this directly
no outgoing calls
no test coverage detected