/ proof-of-concept / cymsim_old
Sign in
proof-of-concept / cymsim_old
cymsim_old / tests / test_plot.py
29 lines · 938 BCodeBlameHistory
3688ceacymsim: Python port of cymbalsim with a modal linear model and a PyTorch von Karman modelJeremy Magland 1"""The plot helpers draw without error (Agg backend)."""
3import matplotlib
5matplotlib.use("Agg")
7import numpy as np # noqa: E402
9from cymsim import Listener, Plate, Strike, compute_modes, make_grid, plot, presets, synthesize # noqa: E402
11from conftest import STEEL_LOSSY # noqa: E402
14def test_plots():
15 pl = Plate.uniform(make_grid(0.2, 0.15, 0.0125), STEEL_LOSSY, 1e-3)
16 ms = compute_modes(pl, 4000)
17 s = synthesize(ms, Strike(), Listener(), duration=0.1, movie=True)
18 plot.plate(pl, strike=Strike(), listener=Listener())
19 plot.plate(presets.crash_bell_16().evaluate(0.02))
20 plot.mode(ms, 0)
21 plot.frame(s, 3)
22 plot.signal(s, tmax=0.05)
23 plot.spectrogram(s, modes=ms, window=512, hop=128)
24 plot.spectrogram(s.spectrogram(512, 128), log_freq=False)
25 plot.decay_times(ms)
26 plot.force(s)
27 anim = plot.animate(s, stride=4)
28 assert anim is not None
29 assert np.isfinite(s.pressure).all()
↑↓ move↵openescclose