Skip to content

Commit

Permalink
Merge pull request #274 from shorepine/piano-3d
Browse files Browse the repository at this point in the history
piano_heterodyne: Fix time axis (to true-log) on 3D plots.
  • Loading branch information
dpwe authored Jan 8, 2025
2 parents c98f780 + 159b1bf commit 5799277
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Binary file modified docs/3d-envelopes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions experiments/piano_heterodyne.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,14 @@
"source": [
"def time_mapper(t, boundary=0.25, magnification=8.0):\n",
" \"\"\"Convert time in secs to a nonlinear projection.\"\"\"\n",
" #return np.log10(0.01 + t)\n",
" t = np.asarray(t)\n",
" magnified = (t < boundary)\n",
" return magnified * t + (1 - magnified) * (boundary + (t - boundary) / magnification)\n",
" return np.log10(0.01 + t)\n",
" #t = np.asarray(t)\n",
" #magnified = (t < boundary)\n",
" #return magnified * t + (1 - magnified) * (boundary + (t - boundary) / magnification)\n",
"\n",
"def inv_time_mapper(mapped_t, boundary=0.25, magnification=8.0):\n",
" magnified = mapped_t < boundary\n",
" return magnified * mapped_t + (1 - magnified) * (boundary + magnification * (mapped_t - boundary))\n",
"\n",
"from matplotlib.collections import PolyCollection\n",
"\n",
Expand Down Expand Up @@ -1458,6 +1462,10 @@
" \n",
" plt.title(filename)\n",
" plt.xlabel('time / s')\n",
" #tick_times = np.array([0, 0.1, 0.2, 1.0, 2.0, 3.0, 4.0])\n",
" tick_times = np.array([0, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0])\n",
" plt.xticks(time_mapper(tick_times), tick_times)\n",
" #plt.xlim([-0.05, 0.8])\n",
" plt.ylabel('harm #')\n",
" plt.yticks(np.arange(2, 22, 2), np.arange(19, -1, -2))\n",
" #plt.zlabel('level / dB')\n",
Expand Down

0 comments on commit 5799277

Please sign in to comment.