{ "cells": [ { "cell_type": "markdown", "id": "89051158", "metadata": {}, "source": [ "# XAMSL data access\n", "\n", "_S. Di Pede, last update: 30.3.2022_\n", "\n", "By the time of writing this documentation, you can have access to the data if you activate the ``amstrax_2021`` environment on Stoomboot.\n", "\n", "This documentation page uses the same structure idea of the [STRAXEN documentation](https://straxen.readthedocs.io/en/latest/index.html).\n", "\n", "As a first step, check that you have access to the MongoDB on the xams-daq PC. Have a look at the [AMSTRAX documentation](https://amstrax.readthedocs.io/en/latest/setup.html) and ask your colleagues for the credentials. " ] }, { "cell_type": "code", "execution_count": 1, "id": "a314ab7c", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "2022-03-30 14:40:05,669 - utilix - WARNING - Could not load a configuration file. You can create one at /user/serenap/.xenon_config, or set a custom path using\n", "\n", "export XENON_CONFIG=path/to/your/config\n", "\n" ] } ], "source": [ "import strax\n", "import straxen\n", "import amstrax" ] }, { "cell_type": "markdown", "id": "2f151841", "metadata": {}, "source": [ "If the imports do not succeed please check that the location of the **__init__.py** file is here: ``/data/xenon/xamsl/software/amstrax/amstrax/``" ] }, { "cell_type": "code", "execution_count": 2, "id": "351c508f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Amstrax location: /data/xenon/xamsl/software/amstrax/amstrax/__init__.py\n", "Strax location: /data/xenon/xamsl/software/strax/strax/__init__.py\n", "Straxen location: /data/xenon/xamsl/software/straxen/straxen/__init__.py\n" ] } ], "source": [ "import os.path\n", "print(f'Amstrax location: {os.path.abspath(amstrax.__file__)}')\n", "print(f'Strax location: {os.path.abspath(strax.__file__)}')\n", "print(f'Straxen location: {os.path.abspath(straxen.__file__)}')" ] }, { "cell_type": "markdown", "id": "153d1c44", "metadata": {}, "source": [ "In ``amstrax`` we have two contexts for the two different detectors operated in the setup:\n", "\n", " * [XAMSL detector](https://wiki.nikhef.nl/xenon/doku.php?id=xamsl) \n", " * [XAMS detector](https://wiki.nikhef.nl/xenon/doku.php?id=xams)\n", " \n", "and you can access the data just with the following commands:" ] }, { "cell_type": "code", "execution_count": 3, "id": "903d1506", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[amstrax.rundb.RunDB, readonly: True, strax.storage.files.DataDirectory, readonly: True, path: /data/xenon/xamsl/raw/, take_only: ('raw_records_v1724', 'raw_records_v1730', 'raw_records_aqmon'), strax.storage.files.DataDirectory, readonly: True, path: /data/xenon/xamsl/processed/, strax.storage.files.DataDirectory, path: ./amstrax_data]\n", "[amstrax.rundb.RunDB, readonly: True, strax.storage.files.DataDirectory, readonly: True, path: /data/xenon/xams/raw/, take_only: ('raw_records_v1724', 'raw_records_v1730', 'raw_records_aqmon'), strax.storage.files.DataDirectory, readonly: True, path: /data/xenon/xams/processed/, strax.storage.files.DataDirectory, path: ./amstrax_data]\n" ] } ], "source": [ "st = amstrax.contexts.xams_little()\n", "st_xams = amstrax.contexts.xams()" ] }, { "cell_type": "markdown", "id": "0e173589", "metadata": {}, "source": [ "The ``contexts`` method prints out the data storage directories:\n", "\n", " * the run DataBase: ``amstrax.rundb.RunDB``, storing the metadata\n", " * two strax storage DataDirectory: ``/data/xenon/xamsl/raw/`` and ``/data/xenon/xamsl/processed/``, storing, respectively, the raw data (raw_records) and all the other high-level processed data\n", " * a general path where the data are stored in case they have not been processed yet in the above strax storage folders: ``./amstrax_data``. " ] }, { "cell_type": "markdown", "id": "0f09aba8", "metadata": {}, "source": [ "### Run selection\n", "\n", "In this documentation, we focus only on accessing the XAMSL data. To select the measurement of your interest please have a look at the [details of XAMSL measurements](https://wiki.nikhef.nl/xenon/doku.php?id=xamsl:run1_lxe_measurements).\n", "\n", "To select _all_ the available runs in the runDB (not only XAMSL measurements) you can use the strax method:" ] }, { "cell_type": "code", "execution_count": 4, "id": "18603944", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Fetching run info from MongoDB: 100%|██████████████████████████████████████████████████████████| 2574/2574 [00:00<00:00, 7309.73it/s]\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "0150827047e94a5394ab34d76b92fc0e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Checking data availability: 0%| | 0/2 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "
| \n", " | name | \n", "number | \n", "mode | \n", "start | \n", "end | \n", "tags | \n", "livetime | \n", "processing_status | \n", "raw_records_v1730_available | \n", "raw_records_v1724_available | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "000000 | \n", "0 | \n", "V1724_Run0 | \n", "2020-11-23 08:36:02.740 | \n", "2020-11-23 08:36:50.846 | \n", "\n", " | 0 days 00:00:48.106000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 1 | \n", "000001 | \n", "1 | \n", "V1724_Run0 | \n", "2020-11-24 07:51:24.798 | \n", "2020-11-24 07:51:36.827 | \n", "\n", " | 0 days 00:00:12.029000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 2 | \n", "000002 | \n", "2 | \n", "V1724_Run0 | \n", "2020-11-24 12:55:19.577 | \n", "2020-11-24 12:55:28.594 | \n", "\n", " | 0 days 00:00:09.017000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 3 | \n", "000003 | \n", "3 | \n", "V1724_Run0 | \n", "2020-11-24 13:08:10.073 | \n", "2020-11-24 13:08:19.093 | \n", "\n", " | 0 days 00:00:09.020000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 4 | \n", "000004 | \n", "4 | \n", "V1730_Run3 | \n", "2020-11-24 13:54:39.023 | \n", "2020-11-24 13:55:00.072 | \n", "\n", " | 0 days 00:00:21.049000 | \n", "NaN | \n", "False | \n", "False | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 2569 | \n", "002569 | \n", "2569 | \n", "test_run_two_digitizers | \n", "2021-12-16 13:01:03.553 | \n", "2021-12-16 13:01:11.676 | \n", "\n", " | 0 days 00:00:08.123000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 2570 | \n", "002570 | \n", "2570 | \n", "test_run_two_digitizers | \n", "2021-12-16 13:02:03.861 | \n", "2021-12-16 13:02:11.974 | \n", "\n", " | 0 days 00:00:08.113000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 2571 | \n", "002571 | \n", "2571 | \n", "test_run_two_digitizers | \n", "2021-12-16 13:03:04.114 | \n", "2021-12-16 13:03:09.134 | \n", "\n", " | 0 days 00:00:05.020000 | \n", "NaN | \n", "False | \n", "False | \n", "
| 2572 | \n", "002572 | \n", "2572 | \n", "test_run_two_digitizers | \n", "2021-12-16 13:04:04.404 | \n", "2021-12-16 13:04:09.532 | \n", "\n", " | 0 days 00:00:05.128000 | \n", "pending | \n", "False | \n", "False | \n", "
| 2573 | \n", "002573 | \n", "2573 | \n", "test_run_two_digitizers | \n", "2021-12-16 13:05:04.660 | \n", "2021-12-16 13:05:09.685 | \n", "\n", " | 0 days 00:00:05.025000 | \n", "pending | \n", "False | \n", "False | \n", "
2574 rows × 10 columns
\n", "| \n", " | Field name | \n", "Data type | \n", "Comment | \n", "
|---|---|---|---|
| 0 | \n", "time | \n", "int64 | \n", "Start time since unix epoch [ns] | \n", "
| 1 | \n", "length | \n", "int32 | \n", "Length of the interval in samples | \n", "
| 2 | \n", "dt | \n", "int16 | \n", "Width of one sample [ns] | \n", "
| 3 | \n", "channel | \n", "int16 | \n", "Channel/PMT number | \n", "
| 4 | \n", "pulse_length | \n", "int32 | \n", "Length of pulse to which the record belongs (w... | \n", "
| 5 | \n", "record_i | \n", "int16 | \n", "Fragment number in the pulse | \n", "
| 6 | \n", "area | \n", "int32 | \n", "Integral in ADC counts x samples | \n", "
| 7 | \n", "reduction_level | \n", "uint8 | \n", "Level of data reduction applied (strax.Reducti... | \n", "
| 8 | \n", "baseline | \n", "float32 | \n", "Baseline in ADC counts. data = int(baseline) -... | \n", "
| 9 | \n", "baseline_rms | \n", "float32 | \n", "Baseline RMS in ADC counts. data = baseline - ... | \n", "
| 10 | \n", "amplitude_bit_shift | \n", "int16 | \n", "Multiply data by 2**(this number). Baseline is... | \n", "
| 11 | \n", "data | \n", "('<i2', (110,)) | \n", "Waveform data in raw counts above integer part... | \n", "
| \n", " | run | \n", "pmt_bottom_v | \n", "pmt_top_v | \n", "notes | \n", "
|---|---|---|---|---|
| 1219 | \n", "1588 | \n", "-560 | \n", "-590 | \n", "reci on/getter on-digi th 30ADC | \n", "
| 1220 | \n", "1589 | \n", "-560 | \n", "-590 | \n", "reci on/getter on-digi th 30ADC | \n", "
| 1221 | \n", "1590 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1222 | \n", "1591 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1223 | \n", "1592 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 1579 | \n", "1948 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1580 | \n", "1949 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1581 | \n", "1950 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1582 | \n", "1951 | \n", "-560 | \n", "-590 | \n", "reci on/getter off-digi th 30ADC | \n", "
| 1583 | \n", "1952 | \n", "-560 | \n", "-590 | \n", "reci on/getter on-digi th 30ADC | \n", "
365 rows × 4 columns
\n", "" ], "text/plain": [ " run pmt_bottom_v pmt_top_v notes\n", "1219 1588 -560 -590 reci on/getter on-digi th 30ADC\n", "1220 1589 -560 -590 reci on/getter on-digi th 30ADC\n", "1221 1590 -560 -590 reci on/getter off-digi th 30ADC\n", "1222 1591 -560 -590 reci on/getter off-digi th 30ADC\n", "1223 1592 -560 -590 reci on/getter off-digi th 30ADC\n", "... ... ... ... ...\n", "1579 1948 -560 -590 reci on/getter off-digi th 30ADC\n", "1580 1949 -560 -590 reci on/getter off-digi th 30ADC\n", "1581 1950 -560 -590 reci on/getter off-digi th 30ADC\n", "1582 1951 -560 -590 reci on/getter off-digi th 30ADC\n", "1583 1952 -560 -590 reci on/getter on-digi th 30ADC\n", "\n", "[365 rows x 4 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "moi = measurements.loc[(measurements['run'] >= 1588) & (measurements['run'] <= 1952)]\n", "moi" ] }, { "cell_type": "code", "execution_count": 17, "id": "6e22b92d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1219 reci on/getter on-digi th 30ADC\n", "1220 reci on/getter on-digi th 30ADC\n", "1221 reci on/getter off-digi th 30ADC\n", "1222 reci on/getter off-digi th 30ADC\n", "1223 reci on/getter off-digi th 30ADC\n", " ... \n", "1579 reci on/getter off-digi th 30ADC\n", "1580 reci on/getter off-digi th 30ADC\n", "1581 reci on/getter off-digi th 30ADC\n", "1582 reci on/getter off-digi th 30ADC\n", "1583 reci on/getter on-digi th 30ADC\n", "Name: notes, Length: 365, dtype: object" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "moi['notes']" ] }, { "cell_type": "markdown", "id": "8acc8051", "metadata": {}, "source": [ "### Data not available! -> You can process data by yourself! \n", " \n", "If, for some reason, you receive a message that data are not available, you can try to make the data by yourself.\n", "\n", "Specify the run number you want to make data of." ] }, { "cell_type": "code", "execution_count": null, "id": "1cb58c82", "metadata": {}, "outputs": [], "source": [ "run_list = ['','',...]" ] }, { "cell_type": "markdown", "id": "e1f7834d", "metadata": {}, "source": [ "And the target data-kind you need" ] }, { "cell_type": "code", "execution_count": null, "id": "c1a43466", "metadata": {}, "outputs": [], "source": [ "target = '...'" ] }, { "cell_type": "markdown", "id": "922946f8", "metadata": {}, "source": [ "Then just look over and use the strax function ``st.make``. " ] }, { "cell_type": "code", "execution_count": null, "id": "f073433f", "metadata": {}, "outputs": [], "source": [ "from strax.utils import tqdm\n", "\n", "for r in tqdm(run_list):\n", " print(r)\n", " st.make(r,target,progress_bar=True)" ] }, { "cell_type": "markdown", "id": "794962b5", "metadata": {}, "source": [ "As we said before, these new processed data will be saved in the storage directory ``./amstrax_data``. You don't need to remake the data every time as strax will know now where to find them." ] }, { "cell_type": "markdown", "id": "b864da45", "metadata": {}, "source": [ "### Veel plezier met XAMSL data!" ] } ], "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.8.0" } }, "nbformat": 4, "nbformat_minor": 5 }