Files
cristallina/acquisition/BS_acquisition.ipynb

891 lines
31 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "e03fa003-fac5-44f7-b42f-2b718f6b966a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b]0;⊚slic\u0007"
]
}
],
"source": [
"from slic.core.adjustable import Adjustable, PVAdjustable, DummyAdjustable\n",
"from slic.core.scanner import Scanner\n",
"\n",
"from slic.core.acquisition import BSAcquisition, PVAcquisition, SFAcquisition\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "cbd7faac-ff24-4e99-bb00-3536d868663f",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-10-03 at 11:58:38 | INFO | Loading started.\n",
"**** The executable \"caRepeater\" couldn't be located\n",
"**** because of errno = \"No such file or directory\".\n",
"**** You may need to modify your PATH environment variable.\n",
"**** Unable to start \"CA Repeater\" process.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b]0;⊚slic\u0007"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-10-03 at 11:58:41 | WARNING | Cannot connect to stand server on saresc-vcons-02.psi.ch. Caught HTTPConnectionPool(host='saresc-vcons-02.psi.ch', port=9090): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa618d15640>: Failed to establish a new connection: [Errno 111] Connection refused')).\n",
"2023-10-03 at 11:58:41 | WARNING | No transmission value reported from {attenuator.ID}\n",
"2023-10-03 at 11:58:42 | INFO | Using undulator (Aramis) offset to PSSS energy of 0 eV.\n",
"2023-10-03 at 11:58:42 | INFO | Running at cristallina with pgroup p19150.\n",
"2023-10-03 at 11:58:42 | INFO | Loading finished.\n",
"CA client library is unable to contact CA repeater after 50 tries.\n",
"Silence this message by starting a CA repeater daemon\n",
"or by calling ca_pend_event() and or ca_poll() more often.\n"
]
}
],
"source": [
"# %run /sf/cristallina/applications/slic/cristallina/cristallina.py"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1dae028f-116d-42ea-aead-298be9f01de3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"dummy at: 0\n"
]
}
],
"source": [
"# setup dummy axis\n",
"dummy = DummyAdjustable()\n",
"print(f\"dummy at: {dummy.get_current_value()}\")\n",
"\n",
"# setup scanner\n",
"scanner = Scanner(data_base_dir=\"/tmp/scan_data\", scan_info_dir=\"/tmp/scan_info\")"
]
},
{
"cell_type": "markdown",
"id": "207bcb99-d34f-47c5-a417-4de42dfc253e",
"metadata": {},
"source": [
"# BS acquisition"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7396532a-dd7b-4acf-8aa9-c12662405d00",
"metadata": {},
"outputs": [],
"source": [
"bs_example_channels = ['SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', \"SARFE10-PBIG050-EVR0:CALCI\", \"SARES30-CAMS156-XE:x_fit_amplitude\",] # \"SARES30-CAMS156-XE:FPICTURE\"]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "099cd6df-26d6-43e7-bf80-87eabc0a42b5",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Directory \"/tmp/scan_info\" does not exist, creating it...\n",
"Directory \"/tmp/scan_data/scan0000_test_bs\" does not exist, creating it...\n",
"\u001b[32mScan step 1 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 0.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n",
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0000.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 2 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 1.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0001.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 3 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 2.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0002.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 4 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 3.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0003.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 5 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 4.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0004.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 6 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 5.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0005.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 7 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 6.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0006.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 8 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 7.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0007.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 9 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 8.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0008.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 10 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 9.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0009.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 11 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 10.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n",
"[WARNING] bsread.data.helpers - 'type' channel field not found. Parse as 64-bit floating-point number float64 (default).\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data Header: {'htype': 'bsr_d-1.1', 'channels': [{'name': 'SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', 'encoding': '>'}, {'name': 'SARFE10-PBIG050-EVR0:CALCI', 'encoding': '>'}]}\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0000_test_bs/scan0000_test_bs_step0010.h5\n",
"Acquisition done\n",
"\u001b[32mAll scan steps done\n",
"\u001b[39m"
]
},
{
"data": {
"text/plain": [
"perform the following scan:\n",
"===========================\n",
"\n",
"A: DummyAdjustable \"Dummy\" at 10.0\n",
"\n",
" # A\n",
"-- ----\n",
" 0 0.0\n",
" 1 1.0\n",
" 2 2.0\n",
" 3 3.0\n",
" 4 4.0\n",
" 5 5.0\n",
" 6 6.0\n",
" 7 7.0\n",
" 8 8.0\n",
" 9 9.0\n",
"10 10.0\n",
"\n",
"record 10 pulses per step to \"scan0000_test_bs\" via:\n",
"----------------------------------------------------\n",
"- BSAcquisition: example_instrument/example_pgroup"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# setup acquisition \n",
"acq = BSAcquisition('example_instrument', 'example_pgroup', default_channels=bs_example_channels, default_data_base_dir='/tmp')\n",
"\n",
"scanner.scan1D(dummy, 0, 10, step_size=1, n_pulses=10, filename='test_bs', acquisitions=[acq], step_info=None, return_to_initial_values=False)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "8df87c3c-5870-4dc5-9990-3d57187b8f40",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from slic.core.scanner.scanbackend import is_only_sfdaq, is_sfdaq\n",
"is_sfdaq([acq])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "34bc4109-0de2-4a4f-9bb3-0f8ea03973d9",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "13bc2a3c-e3c1-4b14-8cec-d0d4f334987a",
"metadata": {},
"source": [
"is_sfdaq([acq])"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "5a455e3a-ae7a-4d3c-9e14-b42c24de8f36",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"CA.Client.Exception...............................................\n",
" Warning: \"Virtual circuit unresponsive\"\n",
" Context: \"SARES30-CPPM-MOBI2.psi.ch:5064\"\n",
" Source File: ../tcpiiu.cpp line 926\n",
" Current Time: Tue Oct 03 2023 17:51:00.456204338\n",
"..................................................................\n",
"CA.Client.Exception...............................................\n",
" Warning: \"Virtual circuit unresponsive\"\n",
" Context: \"SARES30-CPPM-MOBI1.psi.ch:5064\"\n",
" Source File: ../tcpiiu.cpp line 926\n",
" Current Time: Tue Oct 03 2023 17:54:13.473023696\n",
"..................................................................\n",
"Unexpected problem with CA circuit to server \"SARES30-CPPM-MOBI1.psi.ch:5064\" was \"Connection reset by peer\" - disconnecting\n",
"CA.Client.Exception...............................................\n",
" Warning: \"Virtual circuit disconnect\"\n",
" Context: \"SARES30-CPPM-MOBI1.psi.ch:5064\"\n",
" Source File: ../cac.cpp line 1237\n",
" Current Time: Tue Oct 03 2023 17:54:42.135508142\n",
"..................................................................\n",
"Unexpected problem with CA circuit to server \"SARES30-CPPM-MOBI2.psi.ch:5064\" was \"No route to host\" - disconnecting\n",
"CA.Client.Exception...............................................\n",
" Warning: \"Virtual circuit disconnect\"\n",
" Context: \"SARES30-CPPM-MOBI2.psi.ch:5064\"\n",
" Source File: ../cac.cpp line 1237\n",
" Current Time: Tue Oct 03 2023 18:06:26.581725132\n",
"..................................................................\n"
]
}
],
"source": [
"is_sfdaq([acq])"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "e2c866cd-4051-4a1c-b4c8-a4372e14a180",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Directory \"/tmp/scan_data/scan0008_test_pv\" does not exist, creating it...\n",
"\u001b[32mScan step 1 of 11\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 0.0\n",
"Moved adjustables, starting acquisition\n",
"No channels specified, using default channel list.\n",
"Stopping because of: TaskError: Exception in Task\n",
"caused by ConnectionError: connection to the following PVs timed out (1 sec): SARES30-MOBI1:MOT_1.RBV, SARES30-MOBI1:MOT_2.RBV, SARES30-MOBI1:MOT_3.RBV, SARES30-MOBI1:MOT_5.RBV, SARFE10-PBPS053:MOTOR_X2, SAROP31-OPPI151:MOTOR_X.RBV, SAROP31-OPPI151:MOTOR_Y.RBV\n",
"Stopping caused: TaskError: Exception in Task\n",
"caused by ConnectionError: connection to the following PVs timed out (1 sec): SARES30-MOBI1:MOT_1.RBV, SARES30-MOBI1:MOT_2.RBV, SARES30-MOBI1:MOT_3.RBV, SARES30-MOBI1:MOT_5.RBV, SARFE10-PBPS053:MOTOR_X2, SAROP31-OPPI151:MOTOR_X.RBV, SAROP31-OPPI151:MOTOR_Y.RBV\n",
"Stopped current DAQ tasks:\n",
"\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /tmp/scan_data/scan0008_test_pv/scan0008_test_pv_step0000.h5\n",
"\n"
]
},
{
"data": {
"text/plain": [
"perform the following scan:\n",
"===========================\n",
"\n",
"A: DummyAdjustable \"Dummy\" at 0.0\n",
"\n",
" # A\n",
"-- ----\n",
" 0 0.0\n",
" 1 1.0\n",
" 2 2.0\n",
" 3 3.0\n",
" 4 4.0\n",
" 5 5.0\n",
" 6 6.0\n",
" 7 7.0\n",
" 8 8.0\n",
" 9 9.0\n",
"10 10.0\n",
"\n",
"record 10 pulses per step to \"scan0008_test_pv\" via:\n",
"----------------------------------------------------\n",
"- PVAcquisition: cristallina/p19150"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scanner.scan1D(dummy, 0, 10, step_size=1, n_pulses=10, filename='test_pv', acquisitions=[acq], step_info=None, return_to_initial_values=False)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e35014f0-3e5d-49fb-bf7b-e8ffad4c92f2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d5816898-f66e-4504-90cb-8d0e54ba3c23",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'pvs' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[8], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m acq \u001b[38;5;241m=\u001b[39m PVAcquisition(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexample_instrument\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mexample_pgroup\u001b[39m\u001b[38;5;124m'\u001b[39m, default_channels\u001b[38;5;241m=\u001b[39m\u001b[43mpvs\u001b[49m, default_data_base_dir\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m/tmp\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
"\u001b[0;31mNameError\u001b[0m: name 'pvs' is not defined"
]
}
],
"source": [
"acq = PVAcquisition('example_instrument', 'example_pgroup', default_channels=pvs, default_data_base_dir='/tmp')"
]
},
{
"cell_type": "markdown",
"id": "e16c139f-3422-41fc-8557-5cbe39115535",
"metadata": {},
"source": [
"# SFAcquisition example\n",
"\n",
"This requires an existing `pgroup`. The `default_data_base_dir` cannot be used to specify arbitrary directories as a target, instead the data is located in `/sf/<instrument>/data/<pgroup>/raw/run<XXXX>/data/acq<YYYY>.*.h5`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e374115-4807-47cf-8a3e-034462011493",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 9,
"id": "3d465878-2118-4dea-a24a-219ff4252d88",
"metadata": {},
"outputs": [],
"source": [
"# TODO: requires the stand client, need small howto how to start and configure or let it run all the time\n",
"from slic.core.acquisition.spreadsheet import Spreadsheet\n",
"\n",
"import os\n",
"os.chdir(\"/sf/cristallina/applications/slic/cristallina\")\n",
"# %run /sf/cristallina/applications/slic/cristallina/cristallina.py\n",
"from devices.diffractometer import diffractometer\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "c4f812f4-b6fa-463f-a367-121e139b972b",
"metadata": {},
"outputs": [],
"source": [
"spreadsheet = Spreadsheet({\"TD\": diffractometer.td},\n",
" placeholders=('comment', 'sample'),\n",
" host='saresc-vcons-02.psi.ch',\n",
" port=9090,)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "2c6852f5-9aa5-4d4b-8c1c-7558720f3e2e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Motor \"SARES30-CPCL-ECMC02:TD\" at 115.00409000000013 mm"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"diffractometer.td"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "026350d2-a6bf-4b02-abcc-f560b22bbdfb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" a b c\n",
"0 2 3 4"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"spreadsheet.client.add_row(a=2, b=3, c=4)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "2dddb44b-689f-4cdb-858f-103610bef3c6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Advanced run number to 192 for SF DAQ on http://sf-daq:10002 (status: idle, last run: 192).\n",
" a b c run filename n_pulses comment sample scanned_adjs v_min v_max n_steps TD\n",
"0 2.0 3.0 4.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"1 NaN NaN NaN 192.0 test_bs 10.0 Dummy 0.0 2.0 3.0 115.004265\n",
"\u001b[32mScan step 1 of 3\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 0.0\n",
"Moved adjustables, starting acquisition\n",
"Continuing run number 192.\n",
"No detectors specified, using default detector list.\n",
"No PVs specified, using default PV list.\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 49.7 Hz]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"run number: 192\n",
"acq number: 1\n",
"total acq number: 687\n",
"\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0001.BSDATA.h5\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0001.CAMERAS.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 2 of 3\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 1.0\n",
"Moved adjustables, starting acquisition\n",
"Continuing run number 192.\n",
"No detectors specified, using default detector list.\n",
"No PVs specified, using default PV list.\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 49.7 Hz]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"run number: 192\n",
"acq number: 2\n",
"total acq number: 688\n",
"\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0002.BSDATA.h5\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0002.CAMERAS.h5\n",
"Acquisition done\n",
"\u001b[32mScan step 3 of 3\n",
"\u001b[39mDummyAdjustable \"Dummy\" at 2.0\n",
"Moved adjustables, starting acquisition\n",
"Continuing run number 192.\n",
"No detectors specified, using default detector list.\n",
"No PVs specified, using default PV list.\n",
"No channels specified, using default channel list.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 49.7 Hz]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"run number: 192\n",
"acq number: 3\n",
"total acq number: 689\n",
"\n",
"DAQTask: done\n",
"\n",
"Output files:\n",
"-------------\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0003.BSDATA.h5\n",
"- /sf/cristallina/data/p19150/raw/run0192/data/acq0003.CAMERAS.h5\n",
"Acquisition done\n",
"\u001b[32mAll scan steps done\n",
"\u001b[39m"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/plain": [
"perform the following scan:\n",
"===========================\n",
"\n",
"A: DummyAdjustable \"Dummy\" at 2.0\n",
"\n",
"# A\n",
"- ---\n",
"0 0.0\n",
"1 1.0\n",
"2 2.0\n",
"\n",
"record 10 pulses per step to \"test_bs\" via:\n",
"-------------------------------------------\n",
"- SF DAQ on http://sf-daq:10002 (status: idle, last run: 192)"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# setup acquisition \n",
"\n",
"bs_example_channels = ['SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-AVG', \"SARFE10-PBIG050-EVR0:CALCI\", \"SARES30-CAMS156-XE:x_fit_amplitude\", \"SARES30-CAMS156-XE:FPICTURE\"]\n",
"\n",
"# this requires an existing pgroup\n",
"acq = SFAcquisition('example_instrument', 'p19150', default_channels=bs_example_channels, default_data_base_dir='/tmp', spreadsheet=spreadsheet)\n",
"scanner.scan1D(dummy, 0, 2, step_size=1, n_pulses=10, filename='test_bs', acquisitions=[acq], step_info=None, return_to_initial_values=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d5c65482-4b5e-4baa-943f-e35cf384b67c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:conda-slic]",
"language": "python",
"name": "conda-env-conda-slic-py"
},
"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.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}