MCPcopy Create free account
hub / github.com/cselab/aphros / ReadArray

Function ReadArray

deploy/scripts/aphros/plot.py:228–245  ·  view source on GitHub ↗
(p)

Source from the content-addressed store, hash-verified

226# array of shape (Nx, Ny, Nz) (reversed dimensions)
227# None if file not found
228def ReadArray(p):
229 if not os.path.isfile(p):
230 return None
231 with open(p) as f:
232 ll = f.readlines()
233 # shape x,y,z
234 s = np.array(ll[0].split(), dtype=int)
235 # shape z,y,x
236 ss = tuple(reversed(s))
237 # data flat
238 u = np.array(ll[1].split(), dtype=float)
239 # data z,y,x
240 u = u.reshape(ss)
241 # data x,y,z
242 u = np.transpose(u)
243 if len(u.shape) > 2 and u.shape[2] == 2:
244 u = u[:, :, :1]
245 return u
246
247
248# Converts field to image

Callers 4

ReadFieldFunction · 0.85
GetTrajFunction · 0.85
GetAvgFld0Function · 0.85
GetDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected