{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Supplemental Data\n", "\n", "In this notebook you will:\n", "\n", "* Run some simulated experiments including supplemental baseline readings and an asynchronously monitored signal.\n", "* Access the saved data.\n", "\n", "## Configuration\n", "Below, we will connect to EPICS IOC(s) controlling simulated hardware in lieu of actual motors, detectors. The IOCs should already be running in the background. Run this command to verify that they are running: it should produce output with RUNNING on each line. In the event of a problem, edit this command to replace `status` with `restart all` and run again." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!supervisorctl -c supervisor/supervisord.conf status" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%run scripts/beamline_configuration.py" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Baseline Readings\n", "\n", "Now, at the beginning and end of every run, record the positions of these motors." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sd.baseline = [mtr_spotx, mtr_spoty]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# run a similar scan as other exercises\n", "plt.figure('ph_det vs motor_ph')\n", "RE(scan([ph], motor_ph, -1, 1, 5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice\n", "\n", "``New stream: 'baseline'``\n", "\n", "as well as the boxes of readings. How can we access that data later? It doesn't show up in the table!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Let's show the plot again so you can refer back to it when looking at the tables.\n", "plt.gcf()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "db[-1].table()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "db[-1].table('primary') # the default" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "db[-1].table('baseline')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the table gets too wide, it's handy to know how to take the transpose of a `DataFrame`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "db[-1].table('baseline').T" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Asynchronous Monitoring" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sd.monitors = [I]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "RE(scan([ph], motor_ph, -1, 1, 10))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice\n", "\n", "``New stream: 'I_monitor'``\n", "\n", "and a new figure. But the Best-Effort Callback doesn't show us the numbers from monitor readings. (There's just not enough room.)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "h = db[-1]\n", "h.table('I_monitor')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What streams do we have? Another good `Header` method to know:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "h.stream_names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercises\n", "\n", "1. Add `mtr_slit` to the list of things to be recorded as baseline readings." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load solutions/add_baseline_device.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Remove `mtr_slit` from the list of things to be recorded as baseline readings." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load solutions/remove_baseline_device.py" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Empty the list of things to be monitored." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load solutions/clear_supplemental_monitors.py" ] } ], "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }