Commit 5c2dfceb authored by Thibaud Marie Eric Buffet's avatar Thibaud Marie Eric Buffet
Browse files

Merge branch 'SIGMON-224_QHDA_PM_list_update_notebook' into 'dev'

SIGMON-224: integrate the HWC_QHD_PM_LIST.ipynb

See merge request !49
parents fcbb1049 dd43f6af
Pipeline #3172929 failed with stages
in 2 minutes and 37 seconds
{
"cells": [
{
 
"cell_type": "markdown",
"metadata": {},
"source": [
"# Notebook to list QHD PMs by circuit type and time range"
"# Notebook to list QHD PM timestamps by circuit type and time range"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Import Functions"
]
"metadata": {},
"source": [
 
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os, sys, warnings\n",
"import pandas as pd\n",
"from IPython.display import display, HTML, Javascript, clear_output, Markdown\n",
"#\n",
"import lhcsmapi\n",
"from lhcsmapi.Time import Time\n",
"from lhcsmapi.Timer import Timer\n",
"from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
"from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery\n",
"from lhcsmapi.analysis.RqCircuitQuery import RqCircuitQuery\n",
"from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n",
"from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery\n",
"from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery\n",
"from lhcsmapi.analysis.ItCircuitQuery import ItCircuitQuery\n",
"from lhcsmapi.metadata.SignalMetadata import SignalMetadata\n",
"from lhcsmapi.analysis.report_template import apply_report_template\n",
"\n",
"analysis_start_time = Time.get_analysis_start_time()\n",
"lhcsmapi.get_lhcsmapi_version()\n",
"lhcsmapi.get_lhcsmhwc_version('../__init__.py')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1. User Input (circuit types: RB, RQ, IPQ, IPD, IT)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"lhcsmapi.get_lhcsmapi_version()\n",
"lhcsmapi.get_lhcsmhwc_version('../__init__.py')"
]
},
{
"cell_type": "markdown",
"parameters"
]
},
"outputs": [],
"source": [
"detailed_circuit_types = {\n",
" 'RB': ['RB'],\n",
" 'RQ': ['RQ'],\n",
" 'IPQ': ['IPQ2', 'IPQ4', 'IPQ8'],\n",
" 'IPD': ['IPD2', 'IPD2_B1B2'],\n",
" 'IT': ['IT']\n",
{
"}\n",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#\n",
"circuit_type = 'IPQ'\n",
"#\n",
"start_time = '2021-01-15 12:00:00'\n",
"stop_time = '2021-01-15 18:00:00'\n",
"#"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"source_timestamp_qds_df = pd.DataFrame()\n",
"#\n",
"\n",
" circuits = SignalMetadata.get_circuit_names(circuit_type='IPQ2')\n",
" circuits.extend(SignalMetadata.get_circuit_names(circuit_type='IPQ4'))\n",
"start_time = '2021-10-18 07:00:00'\n",
"stop_time = '2021-10-20 23:01:00'\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print('start_time = ', start_time)\n",
"print('stop_time = ', stop_time)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2. Search for PMs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"source_timestamp_qds_df = pd.DataFrame()\n",
"elif circuit_type == 'IT':\n",
" circuits = SignalMetadata.get_circuit_names(circuit_type='IT')\n",
"\n",
"for circuit_type in detailed_circuit_types:\n",
" print(f\"{circuit_type}\")\n",
" circuits = SignalMetadata.get_circuit_names(detailed_circuit_types[circuit_type])\n",
" if circuit_type == 'RQ':\n",
" circuits = circuits[0:7]\n",
"\n",
" for circuit_name in circuits:\n",
" meta_circuit_type = circuit_type\n",
" if circuit_type == 'IPQ' or circuit_type == 'IPD': \n",
" meta_circuit_type = SignalMetadata.get_circuit_type_for_circuit_name(circuit_name)\n",
" \n",
" source_timestamp_qds_df_i = QueryBuilder().with_pm() \\\n",
" .with_duration(t_start=start_time, t_end=stop_time) \\\n",
" .with_circuit_type(meta_circuit_type) \\\n",
" .with_metadata(circuit_name=circuit_name, system='QH', source='*') \\\n",
" .event_query() \\\n",
" .filter_source(circuit_name, 'QH') \\\n",
" .sort_values(by='timestamp').df\n",
"\n",
" if source_timestamp_qds_df_i.empty == False:\n",
" print(source_timestamp_qds_df_i)\n",
" source_timestamp_qds_df_i['circuit_type'] = source_timestamp_qds_df_i.apply(lambda row: circuit_type, axis=1)\n",
" source_timestamp_qds_df = pd.concat([source_timestamp_qds_df, source_timestamp_qds_df_i], ignore_index=True)\n",
"\n",
"if source_timestamp_qds_df.empty == False:\n",
" source_timestamp_qds_df['datetime'] = source_timestamp_qds_df.apply(lambda row: Time.to_string(row['timestamp']), axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3. The list of QHD PM Timestamps, if any"
]
},
......
This diff is collapsed.
......@@ -131,7 +131,7 @@ QH_SEARCH_NOTEBOOKS = [
]
QHD_PM_LIST = [
('qh', 'HWC_QHD_PM_LIST', 'IPQ', '2021-01-15 12:00:00', '2021-01-15 18:00:00'),
('qh', 'HWC_QHD_PM_LIST', '2021-10-18 07:00:00', '2021-10-20 23:01:00'),
]
......@@ -196,11 +196,10 @@ def test_qh_search_notebook(directory, notebook, circuit_name, discharge_level,
@pytest.mark.parametrize('directory,notebook,circuit_type,start_time,stop_time', QHD_PM_LIST)
def test_qh_list_notebook(directory, notebook, circuit_type, start_time, stop_time):
def test_qh_list_notebook(directory, notebook, start_time, stop_time):
_test_notebook(directory,
notebook,
{
'circuit_type': circuit_type,
'start_time': start_time,
'stop_time': stop_time
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment