{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Simulate waveform\n", "\n", "Objects from `thztools`: `timebase`, `wave`" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2024-05-27T07:16:00.044020Z", "start_time": "2024-05-27T07:15:57.378397Z" } }, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "import numpy as np\n", "\n", "import thztools as thz" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Set the simulation parameters" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2024-05-27T07:16:00.047513Z", "start_time": "2024-05-27T07:16:00.045089Z" } }, "outputs": [], "source": [ "n = 256 # Number of samples\n", "dt = 0.05 # Sampling time [ps]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate a waveform\n", "\n", "Use `wave` to generate a terahertz time-domain waveform `mu` with `n = 256` samples and `timebase` to generate the timebase." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2024-05-27T07:16:00.050335Z", "start_time": "2024-05-27T07:16:00.048158Z" } }, "outputs": [], "source": [ "t = thz.timebase(n, dt=dt)\n", "mu = thz.wave(n, dt=dt)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show the simulated waveform" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2024-05-27T07:16:00.209211Z", "start_time": "2024-05-27T07:16:00.051417Z" } }, "outputs": [], "source": [ "_, ax = plt.subplots()\n", "\n", "ax.plot(t, mu)\n", "\n", "ax.set_xlabel('Time (ps)')\n", "ax.set_ylabel(r'Amplitude (units of $\\mu_{p})$')\n", "\n", "ax.set_xticks(np.arange(0, 11, 5))\n", "ax.set_xlim(0, 10)\n", "\n", "plt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" } }, "nbformat": 4, "nbformat_minor": 1 }