{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example: RingMultiBunch" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from opal.opal import load_dataset\n", "\n", "ds = load_dataset('./RingMultiBunch/', fname='RingMultiBunch.h5')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print ( ds )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from opal.visualization.styles import load_style\n", "\n", "load_style('jupyter')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_phase_space('x', 'y', xsci=True, ysci=True, step=3, bins=[0, 1])\n", "\n", "plt.legend(['bin 0', 'bin 1'], markerscale=10)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_phase_space('x', 'z', xsci=True, ysci=True, step=3, bins=[0, 1])\n", "\n", "plt.legend(['bin 0', 'bin 1'], markerscale=10)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "try:\n", " print ( \"Central moment: \" + str(ds.moment('x', k=1, bunch=1, step=3)) )\n", " \n", " print ( \"Arithmetic mean: \" + str(ds.mean('x', bunch=1, step=3)) )\n", " \n", " print ( \"Skewness: \" + str(ds.skew('x', bunch=1, step=3)) )\n", " \n", " print ( \"Kurtosis: \" + str(ds.kurtosis('x', bunch=1, step=3)) )\n", " \n", " print ( \"Halo: \" + str(ds.halo_ellipsoidal_beam('x', bunch=1, step=3)) )\n", " \n", " print ( \"Halo (2D): \" + str(ds.halo_2d_ellipsoidal_beam('x', bunch=1, step=3)) )\n", " \n", " print ( \"Radial halo: \" + str(ds.radial_halo_ellipsoidal_beam(bunch=1, step=3)) )\n", " \n", " print ( \"Radial halo (2D): \" + str(ds.radial_halo_2d_ellipsoidal_beam(azimuth=110, bunch=1, step=3)) )\n", "except Exception as e:\n", " print ( e )" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "minima = ds.find_beams('x', step=3)[0]\n", "\n", "print ( minima )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "kde = ds.gaussian_kde('x', step=3)\n", "import numpy as np\n", "\n", "points = np.linspace(2.1, 2.3, 500)\n", "\n", "pdf = kde.pdf(points)\n", "\n", "plt.plot(points, pdf)\n", "plt.xlabel('x [m]')\n", "plt.ylabel('evaluated kde')\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_histogram('x', step=3, bins=600)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_joint(xvar='x', yvar='y', join='contour', step=3)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_joint(xvar='x', yvar='y', join='scatter', marginals='kde', step=3)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "help(ds.plot_joint)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_joint(xvar='x', yvar='y', join='all', marginals='kde+hist', step=3)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_density_scipy(xvar='x', yvar='y', step=3)\n", "\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt = ds.plot_density(xvar='x', yvar='y', step=3)\n", "\n", "plt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.5.2" } }, "nbformat": 4, "nbformat_minor": 2 }