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

Function PlotPart

deploy/scripts/aphros/plot.py:406–454  ·  view source on GitHub ↗
(ax, p, sk=1)

Source from the content-addressed store, hash-verified

404# Output:
405# plots particles on ax with color c
406def PlotPart(ax, p, sk=1):
407 d = np.loadtxt(p, skiprows=1, delimiter=',')
408 if d.size == 0:
409 return None
410 x, y, z, c = (d.T)[0:4, :]
411 c = c.astype(int)
412
413 # separate particles strings by cell
414 tt = dict() # lists of indices in x, cell is key
415 for i in range(len(c)):
416 ci = c[i]
417 if not ci in tt:
418 tt[ci] = []
419 tt[ci].append(i)
420
421 # map cell index to [0:nc]
422 nc = 16
423 #c = (c * (2 ** 31 - 1) % nc).astype(float) / (nc - 1)
424 cu = np.unique(c)
425 np.random.seed(0)
426 rnd = np.random.choice(np.arange(nc), len(cu))
427 mcl = dict(zip(cu, rnd))
428
429 cmap = plt.get_cmap("Set1")
430
431 # plot strings
432 for i in tt:
433 if np.random.randint(sk) == 0:
434 ti = np.array(tt[i])
435 cl = cmap(mcl[i])
436 if kThin:
437 ax.plot(x[ti], y[ti], c=cl, zorder=10, lw=0.5, alpha=0.5)
438 ax.scatter(x[ti],
439 y[ti],
440 c=cl,
441 s=0.5,
442 lw=0.2,
443 zorder=11,
444 alpha=0.8,
445 edgecolor='black')
446 else:
447 ax.plot(x[ti], y[ti], c=cl, zorder=10, lw=1, alpha=0.5)
448 ax.scatter(x[ti],
449 y[ti],
450 c=cl,
451 s=2,
452 lw=0.3,
453 zorder=11,
454 edgecolor='black')
455
456
457def IsGerris(s):

Callers 1

FigVfFunction · 0.70

Calls 1

plotMethod · 0.80

Tested by

no test coverage detected