{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# APS Accelerator Information for Beamlines\n", "\n", "Show the basic information from the APS accelerator available to all beamlines. Includes:\n", "\n", "* storage ring current\n", "* machine status\n", "* lifetime\n", "* fill number\n", "* operating mode\n", "\n", "NOTE: This notebook only works while at the APS with access to storage ring parameters via EPICS." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "First, setup the Bluesky framework." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "I Thu-09:33:59 - ############################################################ startup\n", "I Thu-09:33:59 - logging started\n", "I Thu-09:33:59 - logging level = 10\n", "I Thu-09:33:59 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/collection.py\n", "I Thu-09:33:59 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/mpl/notebook.py\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Activating auto-logging. Current session state plus future input saved.\n", "Filename : /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/.logs/ipython_console.log\n", "Mode : rotate\n", "Output logging : True\n", "Raw input log : False\n", "Timestamping : True\n", "State : active\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "I Thu-09:34:00 - bluesky framework\n", "I Thu-09:34:00 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/framework/check_python.py\n", "I Thu-09:34:00 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/framework/check_bluesky.py\n", "I Thu-09:34:03 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/framework/initialize.py\n", "I Thu-09:34:07 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/framework/metadata.py\n", "I Thu-09:34:08 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/framework/callbacks.py\n", "I Thu-09:34:08 - writing to SPEC file: /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/20200903-093408.dat\n", "I Thu-09:34:08 - >>>> Using default SPEC file name <<<<\n", "I Thu-09:34:08 - file will be created when bluesky ends its next scan\n", "I Thu-09:34:08 - to change SPEC file, use command: newSpecFile('title')\n" ] } ], "source": [ "from instrument.collection import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, import the standard `aps` object that accesses the information from the APS." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "I Thu-09:34:08 - /home/beams1/JEMIAN/Documents/projects/bluesky_training/lessons/instrument/devices/ideas/aps_source.py\n" ] } ], "source": [ "from instrument.devices.ideas.aps_source import aps" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "The `aps` object is an instance of [apstools.devices.ApsMachineParametersDevice](https://bcda-aps.github.io/apstools/latest/api/_devices.html#apstools.devices.aps_machine.ApsMachineParametersDevice)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "==== ========================== ======== ========\n", "name ophyd structure EPICS PV label(s)\n", "==== ========================== ======== ========\n", "aps ApsMachineParametersDevice \n", "==== ========================== ======== ========\n", "\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "listobjects()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `.summary()` method shows the ophyd structure of the `aps` object. Note the difference in how the names are shown. We'll describe this later." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "data keys (* hints)\n", "-------------------\n", " aps_aps_cycle\n", " aps_current\n", " aps_fill_number\n", " aps_global_feedback\n", " aps_global_feedback_h\n", " aps_global_feedback_v\n", " aps_lifetime\n", " aps_machine_status\n", " aps_operating_mode\n", " aps_operator_messages_fill_pattern\n", " aps_operator_messages_floor_coordinator\n", " aps_operator_messages_last_problem_message\n", " aps_operator_messages_last_trip_message\n", " aps_operator_messages_message6\n", " aps_operator_messages_message7\n", " aps_operator_messages_message8\n", " aps_operator_messages_operators\n", " aps_orbit_correction\n", " aps_shutter_permit\n", "\n", "read attrs\n", "----------\n", "current EpicsSignalRO ('aps_current')\n", "lifetime EpicsSignalRO ('aps_lifetime')\n", "aps_cycle ApsCycleComputedRO ('aps_aps_cycle')\n", "machine_status EpicsSignalRO ('aps_machine_status')\n", "operating_mode EpicsSignalRO ('aps_operating_mode')\n", "shutter_permit EpicsSignalRO ('aps_shutter_permit')\n", "fill_number EpicsSignalRO ('aps_fill_number')\n", "orbit_correction EpicsSignalRO ('aps_orbit_correction')\n", "global_feedback EpicsSignalRO ('aps_global_feedback')\n", "global_feedback_h EpicsSignalRO ('aps_global_feedback_h')\n", "global_feedback_v EpicsSignalRO ('aps_global_feedback_v')\n", "operator_messages ApsOperatorMessagesDevice('aps_operator_messages')\n", "operator_messages.operators EpicsSignalRO ('aps_operator_messages_operators')\n", "operator_messages.floor_coordinator EpicsSignalRO ('aps_operator_messages_floor_coordinator')\n", "operator_messages.fill_pattern EpicsSignalRO ('aps_operator_messages_fill_pattern')\n", "operator_messages.last_problem_message EpicsSignalRO ('aps_operator_messages_last_problem_message')\n", "operator_messages.last_trip_message EpicsSignalRO ('aps_operator_messages_last_trip_message')\n", "operator_messages.message6 EpicsSignalRO ('aps_operator_messages_message6')\n", "operator_messages.message7 EpicsSignalRO ('aps_operator_messages_message7')\n", "operator_messages.message8 EpicsSignalRO ('aps_operator_messages_message8')\n", "\n", "config keys\n", "-----------\n", "\n", "configuration attrs\n", "-------------------\n", "operator_messages ApsOperatorMessagesDevice('aps_operator_messages')\n", "\n", "unused attrs\n", "------------\n", "\n" ] } ], "source": [ "aps.summary()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is the raw form of the data when the `aps` object is read. We can add this to any Bluesky run as a _baseline_ (recorded at both start and end of run) or _monitor_ (recorded when any content in `aps` changes). Either way, this would be recorded as additional streams of data, separate from the primary measurement." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OrderedDict([('aps_current',\n", " {'value': -0.0040169084286680035,\n", " 'timestamp': 1599143648.191037}),\n", " ('aps_lifetime', {'value': 0.0, 'timestamp': 631152000.0}),\n", " ('aps_aps_cycle',\n", " {'value': '2020-3', 'timestamp': 1599143648.4272747}),\n", " ('aps_machine_status',\n", " {'value': 'MAINTENANCE', 'timestamp': 1598374801.294999}),\n", " ('aps_operating_mode',\n", " {'value': 'MAINTENANCE', 'timestamp': 631152000.0}),\n", " ('aps_shutter_permit',\n", " {'value': 'PERMIT', 'timestamp': 1598966626.212694}),\n", " ('aps_fill_number', {'value': 1.0, 'timestamp': 631152000.0}),\n", " ('aps_orbit_correction',\n", " {'value': 0.0, 'timestamp': 631152000.0}),\n", " ('aps_global_feedback',\n", " {'value': 'Off', 'timestamp': 631152000.0}),\n", " ('aps_global_feedback_h',\n", " {'value': 'Off', 'timestamp': 631152000.0}),\n", " ('aps_global_feedback_v',\n", " {'value': 'Off', 'timestamp': 631152000.0}),\n", " ('aps_operator_messages_operators',\n", " {'value': 'Grodecki, Berg', 'timestamp': 1599134402.993963}),\n", " ('aps_operator_messages_floor_coordinator',\n", " {'value': '(2-0101)', 'timestamp': 1598961838.681323}),\n", " ('aps_operator_messages_fill_pattern',\n", " {'value': '', 'timestamp': 1598674048.855485}),\n", " ('aps_operator_messages_last_problem_message',\n", " {'value': '', 'timestamp': 1598674054.151803}),\n", " ('aps_operator_messages_last_trip_message',\n", " {'value': '', 'timestamp': 1598373601.725505}),\n", " ('aps_operator_messages_message6',\n", " {'value': '', 'timestamp': 1598381867.044532}),\n", " ('aps_operator_messages_message7',\n", " {'value': 'Linac/PAR: Locks off COB Wed. 9/02/20',\n", " 'timestamp': 1598877651.053522}),\n", " ('aps_operator_messages_message8',\n", " {'value': 'Booster: Locks off COB Wed. 9/02/20',\n", " 'timestamp': 1598877694.221879})])" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "aps.read()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load a library with some tools that are more descriptive than `.read()` and `/.summary()`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "import apstools.utils" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the result of `.read()` in a table. The timestamps have been converted to human readable date and time (ISO-8601 format).\n", "\n", "NOTE: The *name* column here is the name recorded in the data output. This is what you might use to access this information after the run is acquired, such as for data analysis. These are the *data keys* you would use to access these items for data analysis.\n", "\n", "Also note that some of the time stamps are from 1989. Actually, that is the default time used when the value has not been updated by the EPICS server since the server was last started. Just information, not a problem." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "========================================== ===================================== ==========================\n", "name value timestamp \n", "========================================== ===================================== ==========================\n", "aps_current -0.0040169084286680035 2020-09-03 09:34:08.191037\n", "aps_lifetime 0.0 1989-12-31 18:00:00 \n", "aps_aps_cycle 2020-3 2020-09-03 09:34:08.427275\n", "aps_machine_status MAINTENANCE 2020-08-25 12:00:01.294999\n", "aps_operating_mode MAINTENANCE 1989-12-31 18:00:00 \n", "aps_shutter_permit PERMIT 2020-09-01 08:23:46.212694\n", "aps_fill_number 1.0 1989-12-31 18:00:00 \n", "aps_orbit_correction 0.0 1989-12-31 18:00:00 \n", "aps_global_feedback Off 1989-12-31 18:00:00 \n", "aps_global_feedback_h Off 1989-12-31 18:00:00 \n", "aps_global_feedback_v Off 1989-12-31 18:00:00 \n", "aps_operator_messages_operators Grodecki, Berg 2020-09-03 07:00:02.993963\n", "aps_operator_messages_floor_coordinator (2-0101) 2020-09-01 07:03:58.681323\n", "aps_operator_messages_fill_pattern 2020-08-28 23:07:28.855485\n", "aps_operator_messages_last_problem_message 2020-08-28 23:07:34.151803\n", "aps_operator_messages_last_trip_message 2020-08-25 11:40:01.725505\n", "aps_operator_messages_message6 2020-08-25 13:57:47.044532\n", "aps_operator_messages_message7 Linac/PAR: Locks off COB Wed. 9/02/20 2020-08-31 07:40:51.053522\n", "aps_operator_messages_message8 Booster: Locks off COB Wed. 9/02/20 2020-08-31 07:41:34.221879\n", "========================================== ===================================== ==========================\n", "\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "apstools.utils.listdevice(aps)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the result of `.read()` in a table, showing EPICS PVs. Ignore the timestamps in this table.\n", "\n", "NOTE: The *name* column here is the *attribute* name of the python object. This is what you might use on the command line or when writing a plan. These are the *attribute* names you would use on the command line or write into a plan for execution by the Bluesky RunEngine." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "====================================== ====================== =====================================\n", "name PV reference value \n", "====================================== ====================== =====================================\n", "current S:SRcurrentAI -0.0040169084286680035 \n", "fill_number S:FillNumber 1.0 \n", "global_feedback SRFB:GBL:LoopStatusBI Off \n", "global_feedback_h SRFB:GBL:HLoopStatusBI Off \n", "global_feedback_v SRFB:GBL:VLoopStatusBI Off \n", "lifetime S:SRlifeTimeHrsCC 0.0 \n", "machine_status S:DesiredMode MAINTENANCE \n", "operating_mode S:ActualMode MAINTENANCE \n", "operator_messages.fill_pattern OPS:message3 \n", "operator_messages.floor_coordinator OPS:message2 (2-0101) \n", "operator_messages.last_problem_message OPS:message4 \n", "operator_messages.last_trip_message OPS:message5 \n", "operator_messages.message6 OPS:message6 \n", "operator_messages.message7 OPS:message7 Linac/PAR: Locks off COB Wed. 9/02/20\n", "operator_messages.message8 OPS:message8 Booster: Locks off COB Wed. 9/02/20 \n", "operator_messages.operators OPS:message1 Grodecki, Berg \n", "orbit_correction S:OrbitCorrection:CC 0.0 \n", "shutter_permit ACIS:ShutterPermit PERMIT \n", "====================================== ====================== =====================================\n", "\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "apstools.utils.object_explorer(aps)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.7.7 64-bit ('bluesky_2020_5': conda)", "language": "python", "name": "python37764bitbluesky20205conda345572b776d44f42a42f4cf0931cee5c" }, "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.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }