{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Rescale and shift waveform\n", "\n", "Objects from `thztools`: `scaleshift`, `timebase`, `wave`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib import pyplot as plt\n", "import numpy as np\n", "\n", "import thztools as thz" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set the simulation parameters" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "n = 256 # Number of samples\n", "dt = 0.05 # Sampling time [ps]\n", "a = 0.5 # Scale factor\n", "eta = 1.0 # Delay [ps]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate input and output waveforms\n", "\n", "Use `wave` to generate a terahertz time-domain waveform `mu` with `n = 256` samples, then use `scaleshift` to generate a second waveform `psi` that is rescaled by a factor `a` and delayed by `eta`. The `timebase` function returns the timebase for both waves." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t = thz.timebase(n, dt=dt)\n", "mu = thz.wave(n, dt=dt)\n", "psi = thz.scaleshift(mu, dt=dt, a=a, eta=eta)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Show the input and output waveforms" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "_, ax = plt.subplots()\n", "\n", "ax.plot(t, mu, label=r'$\\mu$')\n", "ax.plot(t, psi, label=r'$\\psi$')\n", "\n", "ax.legend()\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 }