Commit 9f2a5ecd by Ronan Hamon

### update notebook

parent 3cea0a2f
Pipeline #479 passed with stages
in 59 seconds
 ... ... @@ -514,10 +514,7 @@ "source": [ "### Clipping\n", "\n", "Two approaches are implemented to clip a *Waveform*:\n", "\n", "* using minimal and maximal values; this is the regular way to clip signals;\n", "* for int-valued waveform, using the bounds of a given int type; this is mainly used by method *astype* for conversion purposes." "Clipping a *Waveform* is done by using the `clip` method, taking as arguments the minimal and maximal values. Warnings are displayed to inform the user if any value has been clipped." ] }, { ... ... @@ -543,21 +540,7 @@ "metadata": {}, "outputs": [], "source": [ "# Generate a random sine wave\n", "t = np.linspace(0, 10, 10000)\n", "x = (2**16*np.cos(2*np.pi*t)).astype(np.int32) \n", "\n", "w_int = Waveform(x, fs=1)\n", "w_clipped = Waveform(x, fs=1)\n", "\n", "# Clip the signal\n", "w_clipped.astype(np.int16)\n", "\n", "# Plot signals\n", "plt.figure()\n", "w_int.plot('b', label='x')\n", "w_clipped.plot('y', label='y')\n", "plt.legend()" "np.real(w_int)" ] }, { ... ... @@ -594,6 +577,7 @@ "duration = 1\n", "t = np.linspace(0, duration, int(duration*fs))\n", "x_cos = 0.5 * np.cos(2*np.pi*f0*t)\n", "\n", "w_uint8 = Waveform((2**7*x_cos + 128).astype(np.uint8), fs=fs)\n", "w_int16 = Waveform((2**15*x_cos).astype(np.int16), fs=fs)\n", "w_int32 = Waveform((2**31*x_cos).astype(np.int32), fs=fs)\n", ... ... @@ -643,6 +627,7 @@ "f0 = 10\n", "duration = 1\n", "t = np.linspace(0, duration, int(duration*fs))\n", "\n", "w_float16 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float16) + 1, fs=fs)\n", "w_float32 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float32) + 1, fs=fs)\n", "w_float64 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float64) + 1, fs=fs)\n", ... ... @@ -663,7 +648,8 @@ "eps32=np.finfo(np.float32).eps * 4\n", "eps64=np.finfo(np.float64).eps * 4\n", "print(eps16, eps32, eps64)\n", "w_float16 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float16) * eps16 + 1, fs=fs)\n", "\n", "w_float16 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float16) * eps16 + 1 , fs=fs)\n", "w_float32 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float32) * eps32 + 1, fs=fs)\n", "w_float64 = Waveform(np.cos(2*np.pi*f0*t).astype(np.float64) * eps64 + 1, fs=fs)\n", "\n", ... ... @@ -771,7 +757,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.4" "version": "3.6.5" }, "latex_envs": { "LaTeX_envs_menu_present": true, ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!