(p)
| 226 | # array of shape (Nx, Ny, Nz) (reversed dimensions) |
| 227 | # None if file not found |
| 228 | def 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 |
no outgoing calls
no test coverage detected