MCPcopy Create free account
hub / github.com/MaureenZOU/TSAM / read

Function read

src/utils/visual_helper.py:13–28  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

11TAG_FLOAT = 202021.25
12
13def 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
31def makeColorwheel():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected