Commit 8ba64d21 authored by Michal Maciejewski's avatar Michal Maciejewski
Browse files

Corrected missing import in IT, IPD, IPQ QHDA, corrected query cell in AN_RQ_PLIx.b3

parent 18f4ed3b
Pipeline #2228299 passed with stage
in 26 seconds
......@@ -82,6 +82,22 @@ deploy_production_eos_ipd:
before_script: []
after_script: []
deploy_production_eos_ipq:
stage: deploy
tags:
- docker
variables:
"EOS_PATH": "/eos/project/l/lhcsm/hwc/lhc-sm-hwc/ipq"
"CI_OUTPUT_DIR": "ipq"
# Only when the pushed with tags
only:
- tags
image: gitlab-registry.cern.ch/ci-tools/ci-web-deployer
script:
- deploy-eos
before_script: []
after_script: []
deploy_production_eos_qh:
stage: deploy
tags:
......
__version__ = "1.5.6"
__version__ = "1.5.7"
......@@ -17,7 +17,8 @@
"from lhcsmapi.Timer import Timer\n",
"from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
"from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery\n",
"from lhcsmapi.analysis.IpdCircuitAnalysis import IpdCircuitAnalysis"
"from lhcsmapi.analysis.IpdCircuitAnalysis import IpdCircuitAnalysis\n",
"from lhcsmapi.analysis.report_template import apply_report_template"
]
},
{
......
%% Cell type:markdown id: tags:
# Import Functions
%% Cell type:code id: tags:
``` python
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery
from lhcsmapi.analysis.IpdCircuitAnalysis import IpdCircuitAnalysis
from lhcsmapi.analysis.report_template import apply_report_template
```
%% Cell type:markdown id: tags:
# User Input
%% Cell type:code id: tags:
``` python
circuit_type = 'IPD'
circuit_name = 'RD3.R4'
discharge_level = 900.0
start_time = '2018-12-03 13:06:53'
stop_time = '2018-12-03 15:06:53'
ipd_query = IpdCircuitQuery(circuit_type, circuit_name)
ipd_analysis = IpdCircuitAnalysis(ipd_query.circuit_type, results_table=None)
```
%% Cell type:markdown id: tags:
# Execute a Parallel Query
- Find PM QH events
%% Cell type:code id: tags:
``` python
source_timestamp_qds_df = QueryBuilder().with_pm() \
.with_duration(t_start=start_time, t_end=stop_time) \
.with_circuit_type(ipd_query.circuit_type) \
.with_metadata(circuit_name=circuit_name, system='QH', source='*') \
.event_query().df
source_timestamp_qds_df
```
%% Cell type:markdown id: tags:
- Query in parallel several QH events
%% Cell type:markdown id: tags:
# Query QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_dfss = ipd_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'])
u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else []
```
%% Cell type:markdown id: tags:
# Query Reference QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_ref_dfss = ipd_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'], is_ref=True)
u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else []
```
%% Cell type:markdown id: tags:
# Calculate Features and Plot Signals
%% Cell type:code id: tags:
``` python
if u_hds_dfs:
ipd_analysis.analyze_qh(circuit_name, source_timestamp_qds_df.loc[0, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
else:
print('No Quench Heater discharges!')
```
%% Cell type:code id: tags:
``` python
apply_report_template()
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -17,7 +17,8 @@
"from lhcsmapi.Timer import Timer\n",
"from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
"from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n",
"from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis"
"from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis\n",
"from lhcsmapi.analysis.report_template import apply_report_template"
]
},
{
......
%% Cell type:markdown id: tags:
# Import Functions
%% Cell type:code id: tags:
``` python
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery
from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis
from lhcsmapi.analysis.report_template import apply_report_template
```
%% Cell type:markdown id: tags:
# User Input
%% Cell type:code id: tags:
``` python
circuit_type = 'IPQ'
circuit_name = 'RQ4.L2'
discharge_level = 900.0
start_time = '2018-12-10 15:22:00'
stop_time = '2018-12-10 17:22:00'
ipq_query = IpqCircuitQuery(circuit_type, circuit_name)
ipq_analysis = IpqCircuitAnalysis(ipq_query.circuit_type, None, circuit_name=circuit_name)
```
%% Cell type:markdown id: tags:
# Execute a Parallel Query
- Find PM QH events
%% Cell type:code id: tags:
``` python
source_timestamp_qds_df = QueryBuilder().with_pm() \
.with_duration(t_start=start_time, t_end=stop_time) \
.with_circuit_type(ipq_query.circuit_type) \
.with_metadata(circuit_name=circuit_name, system='QH', source='*') \
.event_query().df
source_timestamp_qds_df
```
%% Cell type:markdown id: tags:
- Query in parallel several QH events
%% Cell type:markdown id: tags:
# Query QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'])
u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else []
```
%% Cell type:markdown id: tags:
# Query Reference QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_ref_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'], is_ref=True)
u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else []
```
%% Cell type:markdown id: tags:
# Calculate Features and Plot Signals
%% Cell type:code id: tags:
``` python
if u_hds_dfs:
ipq_analysis.analyze_qh(circuit_name, source_timestamp_qds_df.loc[0, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
else:
print('No Quench Heater discharges!')
```
%% Cell type:code id: tags:
``` python
apply_report_template()
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -17,7 +17,8 @@
"from lhcsmapi.Timer import Timer\n",
"from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
"from lhcsmapi.analysis.ItCircuitQuery import ItCircuitQuery\n",
"from lhcsmapi.analysis.ItCircuitAnalysis import ItCircuitAnalysis"
"from lhcsmapi.analysis.ItCircuitAnalysis import ItCircuitAnalysis\n",
"from lhcsmapi.analysis.report_template import apply_report_template"
]
},
{
......
%% Cell type:markdown id: tags:
# Import Functions
%% Cell type:code id: tags:
``` python
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.ItCircuitQuery import ItCircuitQuery
from lhcsmapi.analysis.ItCircuitAnalysis import ItCircuitAnalysis
from lhcsmapi.analysis.report_template import apply_report_template
```
%% Cell type:markdown id: tags:
# User Input
%% Cell type:code id: tags:
``` python
circuit_type = 'IT'
circuit_name = 'RQX.R1'
#
discharge_level = 900.0
start_time = '2018-08-29 16:59:34'
stop_time = '2018-08-29 18:59:34'
it_query = ItCircuitQuery(circuit_type, circuit_name)
it_analysis = ItCircuitAnalysis(circuit_type, results_table=None)
```
%% Cell type:markdown id: tags:
# Execute a Parallel Query
- Find PM QH events
%% Cell type:code id: tags:
``` python
source_timestamp_qds_df = QueryBuilder().with_pm() \
.with_duration(t_start=start_time, t_end=stop_time) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name = circuit_name, system='QH', source='*') \
.event_query().df
source_timestamp_qds_df
```
%% Cell type:markdown id: tags:
- Query in parallel several QH events
%% Cell type:markdown id: tags:
# Query QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_dfss = it_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'])
u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else []
```
%% Cell type:markdown id: tags:
# Query Reference QH Discharges
%% Cell type:code id: tags:
``` python
u_hds_ref_dfss = it_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'], is_ref=True)
u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else []
```
%% Cell type:markdown id: tags:
# Calculate Features and Plot Signals
%% Cell type:code id: tags:
``` python
if u_hds_dfs:
it_analysis.analyze_qh(circuit_name, source_timestamp_qds_df.loc[0, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
else:
print('No Quench Heater discharges!')
```
%% Cell type:code id: tags:
``` python
apply_report_template()
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -1020,7 +1020,7 @@
"print('Compact notebook report saved to (Windows): ' + '\\\\\\\\cernbox-smb' + full_path.replace('/', '\\\\'))\n",
"display(Javascript('IPython.notebook.save_notebook();'))\n",
"Time.sleep(5)\n",
"!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI2.f1.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/FPA/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='[\"skip_output\"]' --TagRemovePreprocessor.remove_cell_tags='[\"skip_cell\"]'"
"!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI2.f1.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/$hwc_test/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='[\"skip_output\"]' --TagRemovePreprocessor.remove_cell_tags='[\"skip_cell\"]'"
]
},
{
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI2.f1 HWC Test in an RB Circuit</center></h1>
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/RB.png" width=75%>
source: Powering Procedure and Acceptance Criteria for the 13 kA Dipole Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874713/5.1">https://edms.cern.ch/document/874713/5.1</a>
%% Cell type:markdown id: tags:
# Analysis Assumptions
- We consider standard analysis scenarios, i.e., all signals can be queried. If a signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- It is recommended to execute each cell one after another. However, since the signals are queried prior to analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present).
# Plot Convention
- Scales are labeled with signal name followed by a comma and a unit in square brackets, e.g., I_MEAS, [A].
- If a reference signal is present, it is represented with a dashed line.
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively.
- The grid comes from the left axis.
- The title contains timestamp, circuit name, and signal name allowing to re-access the signal.
- The plots assigned to the left scale have colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3).
- Each plot has an individual time-synchronization mentioned explicitly in the description.
- If an axis has a single signal, then the color of the label matches the signal's color. Otherwise, the label color is black.
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/12)'); import sys
print('Loading (2/12)'); from IPython.display import display, Javascript, HTML, clear_output
print('Loading (3/12)'); import pandas as pd
# Internal libraries
print('Loading (4/12)'); import lhcsmapi
print('Loading (5/12)'); from lhcsmapi.Time import Time
print('Loading (6/12)'); from lhcsmapi.Timer import Timer
print('Loading (7/12)'); from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
print('Loading (8/12)'); from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
print('Loading (9/12)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (10/12)'); from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
print('Loading (11/12)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (12/12)'); from lhcsmapi.analysis.expert_input import get_expert_decision
analysis_start_time = Time.get_analysis_start_time()
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())
```
%% Cell type:markdown id: tags:
# 1. User Input
1. Copy code from AccTesting and paste into an empty cell below
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/swan-manual-acctesting-integration.png">
- If you only want to test the notebook only for the copy&paste feature (without opening the AccTesting), please copy and execute the code below
```
hwc_test = 'PLI2.f1'
circuit_name = 'RB.A12'
campaign = 'HWC_2014'
t_start = '2014-12-11 21:35:48.943'
t_end = '2014-12-11 21:59:44.442'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'RB'
hwc_test = 'PLI2.f1'
hwcb = HwcSearchModuleMediator(circuit_type=circuit_type, hwc_test=hwc_test, hwc_summary_path='/eos/project/l/lhcsm/hwc/HWC_Summary.csv')
```
- After opening the browser GUI, choose a circuit name in order to display HWC test with, campaign name as well as start and end time
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:skip_output
``` python
circuit_type = 'RB'
if 'hwcb' in locals():
circuit_name = hwcb.get_circuit_name()
t_start = Time.to_unix_timestamp(hwcb.get_start_time())
t_end = Time.to_unix_timestamp(hwcb.get_end_time())
is_automatic = hwcb.is_automatic_mode()
else:
t_start = Time.to_unix_timestamp(t_start)
t_end = Time.to_unix_timestamp(t_end)
is_automatic = False
rb_query = RbCircuitQuery(circuit_type, circuit_name, max_executions=46)
with Timer():
source_timestamp_pc = rb_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc = source_timestamp_pc.at[0, 'timestamp']
# PIC
timestamp_pic = rb_query.find_timestamp_pic(timestamp_fgc, spark=spark)
# PC Current
i_meas_df, i_a_df, i_earth_df, i_earth_pcnt_df, i_ref_df = rb_query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_EARTH', 'I_EARTH_PCNT', 'I_REF'])
timestamp_fgc_ref = rb_query.get_timestamp_ref(col='fgcPm')
i_meas_ref_df, i_earth_ref_df, i_earth_pcnt_ref_df = rb_query.query_pc_pm(timestamp_fgc_ref, timestamp_fgc_ref, signal_names=['I_MEAS', 'I_EARTH', 'I_EARTH_PCNT'])
# EE Voltage
source_timestamp_ee_odd_df = rb_query.find_source_timestamp_ee(timestamp_fgc, system='EE_ODD')
timestamp_ee_odd = source_timestamp_ee_odd_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_odd_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(timestamp_ee_odd, timestamp_fgc, system='EE_ODD', signal_names=['U_DUMP_RES'])[0]
source_timestamp_ee_even_df = rb_query.find_source_timestamp_ee(timestamp_fgc, system='EE_EVEN')
timestamp_ee_even = source_timestamp_ee_even_df.loc[0, 'timestamp']
source_ee_even = source_timestamp_ee_even_df.loc[0, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(timestamp_ee_even, timestamp_fgc, system='EE_EVEN', signal_names=['U_DUMP_RES'])[0]
# EE TEMPERATURE
t_res_odd_0_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_df.loc[0, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_odd_1_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_df.loc[1, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_even_0_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_df.loc[0, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
t_res_even_1_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_df.loc[1, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
# EE TEMPERATURE REF
source_timestamp_ee_odd_ref_df = rb_query.find_source_timestamp_ee(timestamp_fgc_ref, system='EE_ODD')
source_timestamp_ee_even_ref_df = rb_query.find_source_timestamp_ee(timestamp_fgc_ref, system='EE_EVEN')
t_res_odd_0_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_odd_1_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_even_0_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
t_res_even_1_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
# U_DIODE - CALS
# u_diode_rb_dfs = rb_query.query_voltage_nxcals('DIODE_RB', 'U_DIODE_RB', timestamp_fgc, spark=spark, duration=[(50, 's'), (350, 's')])
# iQPS, nQPS - PM
source_timestamp_qds_df = rb_query.find_source_timestamp_qds(timestamp_fgc)
source_timestamp_nqps_df = rb_query.find_source_timestamp_nqps(timestamp_fgc)
iqps_board_type_df = rb_query.query_pm_iqps_board_type(source_timestamp_qds_df)
results_table = rb_query.create_report_analysis_template(source_timestamp_qds_df, source_timestamp_nqps_df, iqps_board_type_df, timestamp_fgc, '../__init__.py', i_meas_df, HwcSearchModuleMediator.get_user())
# QDS
u_qds_dfs = rb_query.query_voltage_logic_iqps(source_timestamp_qds_df, signal_names=['U_QS0', 'U_1', 'U_2', 'ST_NQD0', 'ST_MAGNET_OK'])
if not source_timestamp_nqps_df.empty:
u_nqps_dfs = rb_query.query_voltage_nqps(source_timestamp_nqps_df, source_timestamp_qds_df, timestamp_fgc, spark=spark)
else:
u_nqps_dfs = []
# QH
source_timestamp_qh_df = rb_query.find_source_timestamp_qh(timestamp_fgc, duration=[(10, 's'), (500, 's')])
i_hds_dfs = rb_query.query_qh_pm(source_timestamp_qh_df, signal_names='I_HDS')
u_hds_dfs = rb_query.query_qh_pm(source_timestamp_qh_df, signal_names='U_HDS')
# QH REF
i_hds_ref_dfs = rb_query.query_qh_pm(source_timestamp_qds_df, signal_names='I_HDS', is_ref=True)
u_hds_ref_dfs = rb_query.query_qh_pm(source_timestamp_qds_df, signal_names='U_HDS', is_ref=True)
# DIODE LEADS
i_a_u_diode_u_ref_pm_dfs = rb_query.query_current_voltage_diode_leads_pm(timestamp_fgc, source_timestamp_qds_df)
i_meas_u_diode_nxcals_dfs = rb_query.query_current_voltage_diode_leads_nxcals(source_timestamp_qds_df, spark=spark, duration=[(50, 's'), (350, 's')])
# U_EARTH
# u_earth_rb_dfs = rb_query.query_voltage_cals('VF', 'U_EARTH_RB', timestamp_fgc, ldb=ldb, duration=[(50, 's'), (350, 's')])
# DFB
source_timestamp_leads_odd_df = rb_query.find_timestamp_leads(timestamp_fgc, 'LEADS_ODD')
u_hts_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signal_names=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signal_names=['U_RES'], spark=spark)
source_timestamp_leads_even_df = rb_query.find_timestamp_leads(timestamp_fgc, 'LEADS_EVEN')
u_hts_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signal_names=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signal_names=['U_RES'], spark=spark)
# EE after 3 hours
unix_time_now = Time.to_unix_timestamp(Time.now())
time_diff = (unix_time_now - timestamp_fgc)*1e-9
if time_diff > 3 * 3600:
t_res_body_long_dfs = rb_query.query_ee_nxcals(timestamp_fgc, system='EE_ODD', signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], spark=spark) \
+ rb_query.query_ee_nxcals(timestamp_fgc, system='EE_EVEN', signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], spark=spark)
st_res_overtemp_long_dfs = rb_query.query_ee_nxcals(timestamp_fgc, system='EE_ODD', signal_names='ST_RES_OVERTEMP', spark=spark, t_thr=0) \
+ rb_query.query_ee_nxcals(timestamp_fgc, system='EE_EVEN', signal_names='ST_RES_OVERTEMP', spark=spark, t_thr=0)
else:
t_res_body_long_dfs = []
st_res_overtemp_long_dfs = []
print('Wait {} seconds to query EE temperature and status signals'.format(time_diff))
rb_analysis = RbCircuitAnalysis(circuit_type, results_table, is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
## 3.1. FPA
Table below provides timestamps ordered achronologically and represents the sequence of events that occurred in the analyzed circuit. Only the first PIC timestamp is reported. Note that for iQPS and nQPS only the first timestamp is reported. Tables with all iQPS and NQPS timestamps are presented in the section dedicated to magnet and quench protection analysis. The table also contains time difference in milliseconds from the first event and from the FGC event.
In short, the following criteria should be kept:
- The PC timestamp (51_self) is QPS time stamp +/-20 ms.
- Time stamp difference between FGC and EE at an odd (RR or UJ) point: 250±50 ms
After YETS 2017/8 the EE timestamp odd has been reduced and should now be 100+-50 ms after the FGC time stamp
- Time stamp difference between FGC and EE at an even (UA) point: 600±50 ms
%% Cell type:code id: tags:
``` python
timestamp_dct = {'FGC': timestamp_fgc, 'PIC': min(timestamp_pic), 'EE_EVEN': timestamp_ee_even, 'EE_ODD': timestamp_ee_odd,
'iQPS': source_timestamp_qds_df, 'nQPS': source_timestamp_nqps_df,
'LEADS_ODD': source_timestamp_leads_odd_df, 'LEADS_EVEN': source_timestamp_leads_even_df}
rb_analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
## 3.2. Reference
Table below contains reference timestamps of signals used for comparison to the analyzed FPA. The reference comes as the last PNO.b2 HWC test with activation of EE systems and no magnets quenching.
%% Cell type:code id: tags:
``` python
timestamp_ref_dct = {'FGC': timestamp_fgc_ref,
'EE_ODD_first': source_timestamp_ee_odd_ref_df.loc[0, 'timestamp'], 'EE_ODD_second': source_timestamp_ee_odd_ref_df.loc[1, 'timestamp'],
'EE_EVEN_first': source_timestamp_ee_even_ref_df.loc[0, 'timestamp'], 'EE_EVEN_second': source_timestamp_ee_even_ref_df.loc[1, 'timestamp']}
rb_analysis.create_ref_timestamp_table(timestamp_ref_dct)
```
%% Cell type:markdown id: tags:
# 4. Schematic
The interactive schematic represents the analyzed circuit and contains:
- All magnets (the quenched ones are in red and the order of quenching is displayed)
- All nQPS crates in blue (the ones with the quenched magnets in red)
- Power converter with FGC timestamp
- Energy extraction systems (even and odd) with corresponding timestamps
- Current leads with PM timestamps (if applicable)
**Note that the drawing may take about 5 minutes**. The most of the time is spent on initializing the plotting library.
%% Cell type:code id: tags:
``` python
if len(results_table) > 1:
print('Loading RbCircuitSchematic...');
from lhcsmapi.analysis.RbCircuitSchematic import show_schematic
show_schematic(circuit_type, circuit_name, results_table, source_timestamp_nqps_df, source_timestamp_leads_odd_df, source_timestamp_leads_even_df,
timestamp_fgc, source_ee_odd, timestamp_ee_odd, source_ee_even, timestamp_ee_even, show_magnet_name=False)
```
%% Cell type:markdown id: tags:
# 5. PIC
## 5.1. Analysis of the PIC Timestamp
*ANALYSIS*:
- Show warning if the two PIC timestamps differ by more than a 1 ms.
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_pic(timestamp_pic)
```
%% Cell type:markdown id: tags:
# 6. Power Converter
## 6.1. Analysis of the Power Converter Main Current
This analysis module displays the main current of the power converter (I_MEAS) compared to the one obtained from the reference FPA (HWC PNO.b2 test with opening of EE systems and without magnet quench).
*ANALYSIS*:
- The evolution of the characteristic time $\tau$ of an exponential decay $f(t)$ is obtained as
\begin{equation}
-\frac{f(t)}{\partial_t f(t)} = -\frac{f_0 e^{-t/\tilde{\tau}}}{\partial_t (f_0 e^{-t/\tilde{\tau}})} = -\frac{f_0 e^{-t/\tilde{\tau}}}{-f_0/\tilde{\tau} e^{-t/\tilde{\tau}}}=-\frac{1}{-1/\tau}=\tau
\end{equation}
Naturally, this formula only applies to exponential decayed characterised by a time constant. Nonetheless, for pseudo-exponential decays, this formula gives a notion of the change of the characteristic time $\tilde{\tau}$. For a circuit we compute the time-varying characteristic time as
\begin{equation}
\tilde{\tau} = \frac{\partial \text{I_MEAS}}{\partial_t}
\end{equation}
*CRITERIA*
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 90 s< Tau <110 s
*PLOT*:
- The main power converter current (analyzed and reference) on the left axis, I_MEAS
- The characteristic time calculated for the main current (reference and actual) on the right axis, -I_MEAS/dI_MEAS_dt
The actual characteristic time contains steps, which indicate a quenching magnet (decrease of circuit inductance); note that for the reference one the steps are not present. Timing of PIC abort, FGC timestamp, and the maximum current are reported next to the graph.
- t = 0 s corresponds to the respective (analyzed and reference) FGC timestamps.
%% Cell type:code id: tags:
``` python
%matplotlib notebook
rb_analysis.analyze_i_meas_pc(circuit_name, timestamp_fgc, timestamp_fgc_ref, min(timestamp_pic), i_meas_df, i_meas_ref_df)
rb_analysis.calculate_current_miits(i_meas_df, t_quench=0, col_name='MIITS_circ')
rb_analysis.calculate_quench_current(i_meas_df, t_quench=0, col_name='I_Q_circ')
rb_analysis.calculate_current_slope(i_meas_df, col_name=['Ramp rate', 'Plateau duration'])
```
%% Cell type:markdown id: tags:
## 6.2. Analysis of the Power Converter Earth Current
*CRITERIA*:
- Checks whether for t > 3 s, I_EARTH_PCNT is within +/-3 % w.r.t. the reference
*PLOT*:
t = 0 s corresponds to respective (actual and reference) FGC PM timestamps
First plot (absolute scale)
- The main power converter current on the left axis, I_A
- Actual and reference earth current on the right axis, IEARTH
Second plot (percentage scale)
- The main power converter current on the left axis, I_MEAS
- Actual and reference earth current on the right axis, I_EARTH_PCNT; I_EARTH_PCNT scaled according to the peak value of the main reference current
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_i_earth_pc(circuit_name, timestamp_fgc, i_a_df, i_earth_df, i_earth_ref_df, xlim=(-1, 5))
rb_analysis.calculate_max_i_earth_pc(i_earth_df, col_name='I_Earth_max')
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_i_earth_pcnt_pc(circuit_type, circuit_name, timestamp_fgc, i_meas_df, i_meas_ref_df, i_earth_pcnt_df, i_earth_pcnt_ref_df, xlim=(-50, 350))
```
%% Cell type:markdown id: tags:
# 7. Energy Extraction System
## 7.1. Analysis of the Energy Extraction Voltage
*ANALYSIS*:
- Calculate U_dump_res (t=0)
- Calculate the characteristic time of pseudo-exponential current decay with the charge approach
*CRITERIA*:
- Check if U_dump_res (t=0) = 0.075*I V (±10%).
- Check if the characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s is 110 s<-Tau <130 s
- Check if the timestamp difference between FGC and EE an odd point is 100±50 ms
The opening delay was 300±50 ms prior to YETS 2017/8
- Check if the time stamp difference between FGC and EE an even point: 600±50 ms
*GRAPHS*:
t = 0 s corresponds to the PM timestamp of the FGC
First plot (global view):
- the power converter converter current on the left axis, I_MEAS
- the two energy extraction voltages on the right, U_DUMP_RES, U_DUMP_RES
Second plot (triggering view):
- the power converter current on the left axis, I_MEAS
- the power converter reference current on the left axis, STATUS.I_REF (should stop at the moment of the FGC PM timestamp)
- the two energy extraction voltages on the right axis, U_DUMP_RES, U_DUMP_RES
- the green dashed line denotes the PIC timestamp
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_char_time_u_dump_res_ee(circuit_name, timestamp_fgc, [u_dump_res_odd_df, u_dump_res_even_df], i_meas_df)
rb_analysis.results_table['U_EE_max_ODD'] = u_dump_res_odd_df.max()[0]
rb_analysis.results_table['U_EE_max_EVEN'] = u_dump_res_even_df.max()[0]
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_delay_time_u_dump_res_ee(circuit_name, timestamp_fgc, min(timestamp_pic), [timestamp_ee_odd, timestamp_ee_even],
i_a_df, i_ref_df, [u_dump_res_odd_df, u_dump_res_even_df])
```
%% Cell type:markdown id: tags:
## 7.2. Analysis of the Energy Extraction Temperature
*CRITERIA*
- Checks whether temperature profile is +/-25 K w.r.t. the reference temperature profile
- Checks whether maximum temperatures are within [100, 200] K range
*PLOT*:
- Temperature signals on the left axis, T
- A reference signal with an acceptable signal range is also provided on the left axis
- t = 0 s corresponds to PM timestamps of each temperature PM entry
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_ee_temp(circuit_name + '_EE_ODD', timestamp_ee_odd, t_res_odd_0_df + t_res_odd_1_df, t_res_odd_0_ref_df + t_res_odd_1_ref_df, abs_margin=25, scaling=1)
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_ee_temp(circuit_name + '_EE_EVEN', timestamp_ee_even, t_res_even_0_df + t_res_even_1_df, t_res_even_0_ref_df + t_res_even_1_ref_df, abs_margin=25, scaling=1)
```
%% Cell type:markdown id: tags:
# 8. Quench Protection System
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/RB_QPS_Signals.png" width=75%>
The table below shows the sign of the resistive voltages and inductive voltages (for positive ramp rate) of U1 and U2. U_QS0=-U1-U2.
|Circuit |Resistive voltage U1 |Resistive voltage U2 |Inductive voltage U1 |Inductive voltage U2|
|-----------|-----------------------|-----------------------|-----------------------|--------------------|
|RB.A12 |Pos |Neg |Pos |Neg|
|RB.A23 |Neg |Pos |Neg |Pos|
|RB.A34 |Neg |Pos |Neg |Pos|
|RB.A45 |Neg |Pos |Neg |Pos|
|RB.A56 |Pos |Neg |Pos |Neg|
|RB.A67 |Pos |Neg |Pos |Neg|
|RB.A78 |Pos |Neg |Pos |Neg|
|RB.A81 |Neg |Pos |Neg |Pos|
The thresholds and evaluation times for the QPS on the RB circuits are given in the following table:
|Class |System |Threshold |Evaluation time |Signal |Comment|
|-------|-------|-----------|-------------------|-------|:------|
|DQAMCNMB_PMSTD |iQPS, DQQDL |100 mV |10 ms discrimination |U_QS0 |Old QPS. Detection of quench in one aperture based upon voltage difference between both apertures in same magnet U_QS0 >10 ms above threshold, otherwise discriminator is reset|
|DQAMCNMB_PMHSU |iQPS, nQPS |-|-|-|Firing of quench heaters by quench protection. Generation of PM buffers sometimes happens even if there is no heater firing.|
|DQAMGNSRB (slow sampling rate), DQAMGNSRB_PMREL (fast sampling rate) |nQPS, DQQDS |500 mV * |>20 ms moving average +1 ms discrimination |U_DIODE |New QPS. Detection of quench in both apertures based upon comparing voltage across the magnet (bypass diode) from 3 magnets in same half-cell and one reference from adjacent half-cell. 50Hz notch moving average filter (20ms worst case). The signals in the 2 classes are identical, only the sampling rate differs. The data with the slow sampling rate is no longer generated as they can be found in the logging database. The recording of data is usually triggered during a FPA, depending on current in circuit, and always when a symmetric quench occurs. The PM buffers are only sent if the DQAMGNS crate trips (what ever the reason).|
|DQAMGNSRB |nQPS, DQQBS| 4 mV | >10 s moving average | U_RES |New QPS. Busbar protection. The signal is not compensated for inductive voltage during ramp.|
|DQAMGNDRB_EVEN, DQAMGNDRB_ODD |iQPS, DQQDC |1 mV, 100 mV |1 s |U_HTS, U_RES |Old QPS. Leads protection. U_HTS is for the high temperature superconducting leads, and U_RES is for the room temperature leads.|
|DQAMGNDRB_EVEN, DQAMGNDRB_ODD |iQPS, DQQDB |+200 V | -50 V | U_BB1, U_BB2 |Old QPS. U_BB1 is the total voltage across the sector. U_BB2 is the voltage across the energy extraction (EE)|
|DQAMSNRB |-|-|-|-|Opening of energy extraction (EE) switches during fast power abort (FPA). 2 EE switches per sector. One for "even" points (EE2). One for "odd" points (EE1).|
*: It was 800 mV before LS1. After LS1 we changed it to 300 or 400 mV. During the training after LS1 we increased it to 500 mV.
%% Cell type:markdown id: tags:
## 8.1. Plot of Voltage Across All Magnets (U_DIODE_RB)
*PLOT*:
t = 0 s corresponds to the PM timestamp of the FGC
First plot (global)
- the power converter current on the left axis, I_MEAS
- diode voltage on the right axis, U_DIODE_RB
Second plot (zoom)
- the power converter current on the left axis, I_MEAS
- diode voltage on the right axis, U_DIODE_RB
%% Cell type:code id: tags:
``` python
# rb_analysis.analyze_u_diode_nqps(circuit_name, timestamp_fgc, i_meas_df, u_diode_rb_dfs, 'U_DIODE_RB', 'DIODE_RB', xlim=(-5, 350))
```
%% Cell type:code id: tags:
``` python
# rb_analysis.analyze_u_diode_nqps(circuit_name, timestamp_fgc, i_meas_df, u_diode_rb_dfs, 'U_DIODE_RB', 'DIODE_RB', xlim=(-2, 3))
```
%% Cell type:code id: tags:
``` python
# u_diode_with_quench_rb_dfs = rb_analysis.filter_quenched_magnets(u_diode_rb_dfs)
# rb_analysis.analyze_u_diode_nqps(circuit_name, timestamp_fgc, i_meas_df, u_diode_with_quench_rb_dfs, 'U_DIODE_RB', 'DIODE_RB', legend=True, xlim=(-5, 350))
# rb_analysis.analyze_u_diode_nqps(circuit_name, timestamp_fgc, i_meas_df, u_diode_with_quench_rb_dfs, 'U_DIODE_RB', 'DIODE_RB', legend=True, xlim=(-2, 3))
```
%% Cell type:markdown id: tags:
## 8.2. Analysis of Quenched Magnets by QDS - PM
*ANALYSIS*:
- calculates the current at which a quench occured by finding the timestamp of the current dataframe (i_meas_df) closest to the quench time and the curresponding value of current - I_MEAS_quench
- determines the type of the QPS board that generated the PM entry (a board could fail to write to PM) - i_qps_board_type
- compute the time difference (in seconds) from the first quench - dt_quench
%% Cell type:code id: tags:
``` python
rb_analysis.results_table[['Circuit Name', 'Position', 'Delta_t(iQPS-PIC)','I_Q_circ', 'Delta_t(nQPS-PIC)']]
```
%% Cell type:markdown id: tags:
## 8.3. Analysis of Quench Detection Voltage and Logic Signals for Quenched Magnets
%% Cell type:markdown id: tags:
*ANALYSIS*:
- finds the first timestamp, t_st_magnet_ok, for which the ST_MAGNET_OK signal is False indicating that the quench detection signal U_QS0 is outside of the +/- 100 mV threshold.
- for t > t_st_magnet_ok, finds the first timestamp, t_st_nqd0 for which the ST_NQD0 signal is Fals indicating that the U_QS0 signal is outside of the +/- 100 mV threshold for more than the 10 ms discrimination time. This signifies quench detection and results in triggering quench heaters.
- finds U_QS0 value at the moment of quench detection, u_ST_NQD0 = U_QS0(t=t_st_nqd0)
- if the minimum value of the absolute value of U_QS0 is above greater than 100 ms, then find the start time of a quench, t_start_quench, as a moment at which U_QS0 value is 10 mV greater than its initial value. Otherwise, the start time of a quench is set to 0 s.
- finds U_QS0 value, u_start_quench, at the moment of quench start as u_start_quench = U_QS0(t=t_start_quench)
- the slope of the quench detection signals is calculated as du_dt = (u_ST_NQD0 - u_start_quench) / (t_st_nqd0 - t_start_quench)
- the quench detection signal polarity is taken as the sign of its slope
- the delay of the quench heaters triggering, t_delay_qh_trigger, is assumed to be the negative value of t_st_magnet_ok, t_delay_qh_trigger = -t_st_magnet_ok
Determine source of QH trigger for nQPS signals in PM:
- calculates nQPS differences for the symmetric quench detection
- selects only the differences that involve the quenched magnet and exclude already quenched magnets in the cell
- for t in [-0.2 s, t_st_magnet_ok] take the maximum value of voltage difference
- if the maximum is above 1V (considering sun glasses active from t = 0 s) and the time of maximum is less than t_st_magnet_ok, than the QH system was triggered by nQPS, otherwise iQPS
- it is assumed that the first training quench was detected by iQPS
*PLOT*:
t = 0 s corresponds to the PM timestamp of the QDS
Upper left (iQPS analog signals)
- the quench detection voltage on the left axis, U_QS0
- voltage across the first and the second aperture on the right axis, respectively, U_1 and U_2
- the green box denotes an envelope of the +/- 100 mV quench detection threshold
- the orange box denotes an envelope of the rise of the quench signal from its start until reaching the threshold
Lower left (iQPS digital signals)
- the quench detection voltage on the left axis, U_QS0
- voltage across the first and the second aperture on the right axis, respectively, U_1 and U_2
- ST_MAGNET_OK, ST_NQD0
- the green box denotes an envelope of the +/- 100 mV quench detection threshold
- the orange box denotes an envelope of the rise of the quench signal from its start until reaching the threshold
Upper right (nQPS analog signals)
For PM signals (global view)
- the diode voltages used by the nQPS crate for quench detection on the left axis, U_DIODE_RB and U_REF_N1
- the green box denotes an envelope of 1 V quench detection threshold (assuming active 'sun glasses') before the iQPS quench detection. If the nQPS difference goes outside of the envelope, it means that the quench was detected by nQPS.
For CALS signals (global view)
- the diode voltages used by the nQPS crate for quench detection on the left axis, U_DIODE_RB and U_REF_N1
Lower right (nQPS analog signals)
For PM signals (difference view)
- the differences of diode voltages (containing the quenched magnet; in case the signals are missing, the plot is not displayed) used by the nQPS crate for quench detection on the left axis, U (Calculated diode differences)
For CALS signals (zoomed view)
- the diode voltages used by the nQPS crate for quench detection on the left axis, U_DIODE_RB and U_REF_N1
%% Cell type:code id: tags:
``` python
%matplotlib inline
if u_nqps_dfs:
rb_analysis.analyze_qds(timestamp_fgc, min(timestamp_pic), u_qds_dfs, u_nqps_dfs, i_meas_df)
rb_analysis.results_table[['Circuit Name', 'Position', 'Delta_t(iQPS-PIC)','I_Q_circ', 'Delta_t(nQPS-PIC)', 'QDS trigger origin', 'dU_iQPS/dt']]
```
%% Cell type:markdown id: tags:
## 8.4. Analysis of Quench Heater Discharges
*CRITERIA*:
- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage and current are +/- 3 ms from the reference ones
- all initial resistances are +/- 0.5 Ohm from the reference ones
- all initial voltages are between 780 and 980 V
- all final voltages are between 15 and 70 V
*PLOT*:
t = 0 s corresponds to the start of the pseudo-exponential decay.
Line for actual signal is continuous and dashed for the reference.
Left plot (Voltage view)
- the querried and filtered quench heater voltage on the left axis, U_HDS
Middle plot (Current view)
- the querried and filtered quench heater current on the left axis, I_HDS
Right plot (Resistance view)
- the calculated quench heater resistance on the left axis, R_HDS
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_qh(source_timestamp_qh_df, u_hds_dfs, i_hds_dfs, u_hds_ref_dfs, i_hds_ref_dfs)
rb_analysis.results_table[['Circuit Name', 'Position', 'Delta_t(iQPS-PIC)','I_Q_circ', 'Delta_t(nQPS-PIC)', 'QDS trigger origin', 'QH analysis']]
```
%% Cell type:markdown id: tags:
## 8.5. Analysis of Diode Lead Resistance
*ANALYSIS*:
- calculates diode lead resistance from voltage (board A and B) and current
*CRITERIA*
- if the maximum resistance is above 50 uOhm, then raise a warning
- if the maximum resistance is above 150 uOhm, then raise an alarm
*PLOT*:
Upper PM (Input view)
- the main power converter current on the left axis, IAB.I_A
- quenched magnet voltage from two boards, U_DIODE_A, U_DIODE_B. The difference between both signals is the diode lead voltage.
- reference nQPS board voltage on the right axis, U_REF
- diplayed on the left only if a quench occured no later than 2 seconds after the FGC PM timestamp
- t = 0 s corresponds to the PM timestamp of the QPS
Lower PM (Output view)
- the main power converter current on the left axis, IAB.I_A
- the calculated diode lead resistance on the right axis, R_DIODE_LEADS
- diplayed on the left only if a quench occured no later than 2 seconds after the FGC PM timestamp
- t = 0 s corresponds to the PM timestamp of the QPS
Upper CALS (Input view)
- the main power converter current on the left axis, I_MEAS
- quenched magnet voltage from two boards is saved as a single signal, U_DIODE_RB. The two signals are stored by means of value toggling between board A and board B. The difference between both sub-signals is the diode lead voltage.
- t = 0 s corresponds to the PM timestamp of the FGC
Lower CALS (Output view)
- the main power converter current on the left axis, I_MEAS
- the calculated diode lead resistance on the right axis, R_DIODE_LEADS
- t = 0 s corresponds to the PM timestamp of the FGC
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_diode_leads(source_timestamp_qds_df, timestamp_fgc, results_table['I_Q_M'], circuit_name, i_a_u_diode_u_ref_pm_dfs, i_meas_u_diode_nxcals_dfs)
rb_analysis.results_table[['Circuit Name', 'Date (FGC)', 'Time (FGC)', 'R_DL_max', 'I at R_DL_max']]
```
%% Cell type:markdown id: tags:
## 8.6. Plot of Voltage Feelers
*ANALYSIS*:
- if the voltage of a voltage feeler is equal to 0 V, then it means that the corresponding card is disabled
- if the voltage of a voltage feeler is equal to -2000 V, then it means that the corresponding card is not communicating
*PLOT*:
t = 0 s corresponds to the PM timestamp of the FGC
First plot (global)
- the power converter current on the left axis, I_MEAS
- earth voltage on the right axis, U_EARTH_RB
Second plot (zoom)
- the power converter current on the left axis, I_MEAS
- earth voltage on the right axis, U_EARTH_RB
%% Cell type:code id: tags:
``` python
# rb_analysis.analyze_voltage_feelers(circuit_name, timestamp_fgc, i_meas_df, u_earth_rb_dfs, 'U_EARTH_RB', 'VF')
```
%% Cell type:markdown id: tags:
## 8.7. Plot of Current Leads
*CRITERIA*:
- Check if the quench detection signal for U_HTS is below the threshold (3 mV)
- Check if the quench detection signal for U_RES is below the threshold (100 mV)
*PLOT*:
- t = 0 s corresponds to the FGC timestamp
Global view (for odd and even leads)
- voltage of the HTS leads on the left axis, U_HTS
- voltage of the normal conducting leads on the left axis, U_RES
- blue horizontal dashed line denotes the QPS timestamp
Zoom view (for odd and even leads)
- voltage of the HTS leads on the left axis, U_HTS
- blue horizontal dashed line denotes the QPS timestamp
- cyan horizontal dashed line denotes the EE odd timestamp
- green horizontal dashed line denotes the EE even timestamp
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_leads_voltage(u_hts_odd_dfs+u_hts_even_dfs, circuit_name, timestamp_fgc, timestamp_qps=source_timestamp_qds_df.loc[0, 'timestamp'], signal='U_HTS', value_min=-0.003, value_max=0.003)
```
%% Cell type:code id: tags:
``` python
rb_analysis.plot_leads_voltage_zoom(u_hts_odd_dfs+u_hts_even_dfs, circuit_name, timestamp_fgc, source_timestamp_qds_df.loc[0, 'timestamp'], timestamp_ee_odd, timestamp_ee_even, signal='U_HTS')
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_leads_voltage(u_res_odd_dfs+u_res_even_dfs, circuit_name, timestamp_fgc, timestamp_qps=source_timestamp_qds_df.loc[0, 'timestamp'], signal='U_RES', value_min=-0.1, value_max=0.1)
```
%% Cell type:markdown id: tags:
# 9. Plot of Energy Extraction after 3 h from an FPA
*ANALYSIS*:
- Checks if all 6 temperature signals are below 70 degC after 2 hours from the FPA
*PLOT*:
- Temperature signals on the left axis, T_RES_BODY
- Temperature status on the right axis (1 - temperature exceeds the safe limit, 0 - temperature in the safe limit), ST_RES_OVERTEMP
- t = 0 s corresponds to FGC PM timestamp
- Green box denotes range of temperature check. The temperature should be below 70 degC after 2 hours from the FPA
%% Cell type:code id: tags:
``` python
unix_time_now = Time.to_unix_timestamp(Time.now())
time_diff = (unix_time_now - timestamp_fgc)*1e-9
if t_res_body_long_dfs and st_res_overtemp_long_dfs:
rb_analysis.analyze_ee_temp_and_cooling(t_res_body_long_dfs, st_res_overtemp_long_dfs, t_greater=2*3600, value_max=70)
elif time_diff > 3*3600:
t_res_body_long_dfs = rb_query.query_ee_cals(timestamp_fgc, system='EE_ODD', signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], ldb=ldb) \
+ rb_query.query_ee_cals(timestamp_fgc, system='EE_EVEN', signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], ldb=ldb)
st_res_overtemp_long_dfs = rb_query.query_ee_cals(timestamp_fgc, system='EE_ODD', signal_names='ST_RES_OVERTEMP', ldb=ldb, t_thr=0) \
+ rb_query.query_ee_cals(timestamp_fgc, system='EE_EVEN', signal_names='ST_RES_OVERTEMP', ldb=ldb, t_thr=0)
rb_analysis.analyze_ee_temp_and_cooling(t_res_body_long_dfs, st_res_overtemp_long_dfs, t_greater=2*3600, value_max=70)
else:
print('Wait {} seconds to query EE temperature and status signals'.format(time_diff))
```
%% Cell type:markdown id: tags:
# 10. Signature Decision
%% Cell type:code id: tags:
``` python
signature = get_expert_decision('Expert Signature Decision: ', ['PASSED', 'FAILED'])
```
%% Cell type:markdown id: tags:
# 11. Final Report
%% Cell type:code id: tags:
``` python
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
date_time_fgc = Time.to_datetime(timestamp_fgc).strftime("%Y-%m-%d-%Hh%M")
!mkdir -p /eos/project/m/mp3/RB/$circuit_name/$hwc_test
file_name = "{}_FPA-{}-{}".format(circuit_name, date_time_fgc, analysis_start_time)
full_path = '/eos/project/m/mp3/RB/{}/{}/{}.csv'.format(circuit_name, hwc_test, file_name)
mp3_results_table = rb_analysis.create_mp3_results_table(min(timestamp_pic), timestamp_fgc)
display(HTML(mp3_results_table.T.to_html()))
mp3_results_table.to_csv(full_path, index=False, sep='\t')
print('MP3 results table saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
apply_report_template()
file_name_html = file_name + '.html'
full_path = '/eos/project/m/mp3/RB/{}/{}/{}'.format(circuit_name, hwc_test, file_name_html)
print('Compact notebook report saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
display(Javascript('IPython.notebook.save_notebook();'))
Time.sleep(5)
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI2.f1.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/FPA/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='["skip_output"]' --TagRemovePreprocessor.remove_cell_tags='["skip_cell"]'
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI2.f1.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/$hwc_test/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='["skip_output"]' --TagRemovePreprocessor.remove_cell_tags='["skip_cell"]'
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -343,7 +343,7 @@
"source": [
"## 4.4. Power Converter Voltage Analysis\n",
"*CRITERIA*\n",
"- Check if the V_MEAS voltage is within -1.5 +/- 0.5 V range 1 s after the EE timestamp\n",
"- Check if the V_MEAS voltage is within -1.5 +/- 1 V range 1 s after the EE timestamp\n",
"\n",
"*GRAPHS*\n",
"- t = 0 s corresponds to the PM timestamp of the FGC"
......@@ -356,7 +356,7 @@
"outputs": [],
"source": [
"title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test, t_start=t_start, t_end=t_end, signal='V_MEAS')\n",
"rb_analysis.assert_v_meas(timestamp_ee_even, min(timestamp_pic), t_after_ee=1, v_meas_df=v_meas_df, value_min=-2.0, value_max=-1.0, title=title, xmax=25)"
"rb_analysis.assert_v_meas(timestamp_ee_even, min(timestamp_pic), t_after_ee=1, v_meas_df=v_meas_df, value_min=-2.5, value_max=-0.5, title=title, xmax=25)"
]
},
{
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLIM.b2 HWC Test in an RB Circuit</center></h1>
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/RB.png" width=75%>
This test was added in 2011 HWC campaign after the installation of the snubber capacitors on the EE system. Some additional data acquisition equipment may be required for this test (ask EE expert). The aim of this test is to check the functionality of the snubber with enough energy in the circuit.
The current is then ramped up to I_SM_INT_4. From the plateau a quench simulation from a current lead is provoked.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/PLIM_current.png" width=50%>
The required analysis and signatures are listed below.
|Responsible|Type of analysis|Criterion|
|-----------|----------------|---------|
|PC|PC voltage check|PC voltage ~ -1.5 V ± 0.5 V, 1 s after the EE activation. The current decay time constant should be within 20% of Decay_Time_const. Smooth exponential waveform on the PC voltage and current during the whole decay|
|PC|Earth Current Analysis|The maximum earth current <50 mA during EE activation disregarding the peak at the opening of the EE system.|
|EE|Energy discharge|Maximum voltage on EE resistance ($R*I$±10%) and maximum temperature of the EE resistance (±10% from theoretical value)|
|EE|Energy discharge|Time delay on switch opening (300±50ms at odd point and 600±50ms at even point)|
|MP3|Detection of symmetric quench (if SymQ buffer is triggered at the discharge)|Voltage difference between magnets <80% × high threshold value of sunglass filter × current ratio|
source: Powering Procedure and Acceptance Criteria for the 13 kA Dipole Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874713/5.1">https://edms.cern.ch/document/874713/5.1</a>
%% Cell type:markdown id: tags:
# Analysis Assumptions
- We consider standard analysis scenarios, i.e., all signals can be queried. If a signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- It is recommended to execute each cell one after another. However, since the signals are queried prior to analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present).
# Plot Convention
- Scales are labeled with signal name followed by a comma and a unit in square brackets, e.g., I_MEAS, [A].
- If a reference signal is present, it is represented with a dashed line.
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively.
- The grid comes from the left axis.
- The title contains timestamp, circuit name, and signal name allowing to re-access the signal.
- The plots assigned to the left scale have colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3).
- Each plot has an individual time-synchronization mentioned explicitly in the description.
- If an axis has a single signal, then the color of the label matches the signal's color. Otherwise, the label color is black.
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/11)'); import sys
print('Loading (2/11)'); from IPython.display import display, Javascript, clear_output
# Internal libraries
print('Loading (3/11)'); import lhcsmapi
print('Loading (4/11)'); from lhcsmapi.Time import Time
print('Loading (5/11)'); from lhcsmapi.Timer import Timer
print('Loading (6/11)'); from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
print('Loading (7/11)'); from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
print('Loading (8/11)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (9/11)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (10/11)'); from lhcsmapi.pyedsl.PlotBuilder import create_hwc_plot_title_with_circuit_name
print('Loading (11/11)'); from lhcsmapi.analysis.expert_input import get_expert_decision
analysis_start_time = Time.get_analysis_start_time()
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())
```
%% Cell type:markdown id: tags:
# 1. User Input
1. Copy code from AccTesting and paste into an empty cell below
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/swan-manual-acctesting-integration.png">
- If you only want to test the notebook only for the copy&paste feature (without opening the AccTesting), please copy and execute the code below
```
hwc_test = 'PLIM.b2'
circuit_name = 'RB.A12'
campaign = 'HWC_2018_1'
t_start = '2017-04-22 04:34:15.401'
t_end = '2017-04-22 04:56:43.323'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'RB'
hwc_test = 'PLIM.b2'
hwcb = HwcSearchModuleMediator(circuit_type=circuit_type, hwc_test=hwc_test, hwc_summary_path='/eos/project/l/lhcsm/hwc/HWC_Summary.csv')
```
- After opening the browser GUI, choose a circuit name in order to display HWC test with, campaign name as well as start and end time
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:skip_output
``` python
circuit_type = 'RB'
if 'hwcb' in locals():
circuit_name = hwcb.get_circuit_name()
t_start = Time.to_unix_timestamp(hwcb.get_start_time())
t_end = Time.to_unix_timestamp(hwcb.get_end_time())
t_start_ref = Time.to_unix_timestamp(hwcb.get_ref_start_time())
t_end_ref = Time.to_unix_timestamp(hwcb.get_ref_end_time())
is_automatic = hwcb.is_automatic_mode()
else:
t_start = Time.to_unix_timestamp(t_start)
t_end = Time.to_unix_timestamp(t_end)
t_start_ref, t_end_ref = HwcSearchModuleMediator.get_last_ref_start_end_time('/eos/project/l/lhcsm/hwc/HWC_Summary.csv', circuit_name, hwc_test, Time.to_string_short(t_start))
t_start_ref, t_end_ref = Time.to_unix_timestamp(t_start_ref), Time.to_unix_timestamp(t_end_ref)
is_automatic = False
rb_query = RbCircuitQuery(circuit_type, circuit_name, max_executions=30)
rb_analysis = RbCircuitAnalysis(circuit_type, results_table=None, is_automatic=is_automatic)
with Timer():
# PC
i_meas_nxcals_df = rb_query.query_signal_nxcals(t_start, t_end, t0=t_start, system='PC', signal_names='I_MEAS', spark=spark)[0]
source_timestamp_pc = rb_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc = source_timestamp_pc.at[0, 'timestamp']
i_meas_df, i_a_df, i_ref_df, i_earth_df, i_earth_pcnt_df, v_meas_df = rb_query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF', 'I_EARTH', 'I_EARTH_PCNT', 'V_MEAS'])
# PC Reference
if isinstance(t_start_ref, int):
source_timestamp_pc_ref = rb_query.find_source_timestamp_pc(t_start_ref, t_end_ref)
timestamp_fgc_ref = source_timestamp_pc_ref.at[0, 'timestamp']
else:
timestamp_fgc_ref = float('nan')
i_meas_ref_df = rb_query.query_pc_pm(timestamp_fgc_ref, timestamp_fgc_ref, signal_names=['I_MEAS'])[0]
# PIC
timestamp_pic = rb_query.find_timestamp_pic(timestamp_fgc, spark=spark)
# EE Voltage
source_timestamp_ee_odd_df = rb_query.find_source_timestamp_ee(timestamp_fgc, system='EE_ODD')
timestamp_ee_odd = source_timestamp_ee_odd_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_odd_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(timestamp_ee_odd, timestamp_fgc, system='EE_ODD', signal_names=['U_DUMP_RES'])[0]
source_timestamp_ee_even_df = rb_query.find_source_timestamp_ee(timestamp_fgc, system='EE_EVEN')
timestamp_ee_even = source_timestamp_ee_even_df.loc[0, 'timestamp']
source_ee_even = source_timestamp_ee_even_df.loc[0, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(timestamp_ee_even, timestamp_fgc, system='EE_EVEN', signal_names=['U_DUMP_RES'])[0]
# EE Temperature
t_res_odd_0_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_df.loc[0, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_odd_1_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_df.loc[1, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_even_0_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_df.loc[0, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
t_res_even_1_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_df.loc[1, 'timestamp'], timestamp_fgc, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
# EE Voltage Reference
if isinstance(t_start_ref, int):
source_timestamp_ee_odd_ref_df = rb_query.find_source_timestamp_ee(timestamp_fgc_ref, system='EE_ODD')
source_timestamp_ee_even_ref_df = rb_query.find_source_timestamp_ee(timestamp_fgc_ref, system='EE_EVEN')
u_dump_res_odd_ref_df = rb_query.query_ee_u_dump_res_pm(source_timestamp_ee_odd_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, system='EE_ODD', signal_names=['U_DUMP_RES'])[0]
u_dump_res_even_ref_df = rb_query.query_ee_u_dump_res_pm(source_timestamp_ee_even_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, system='EE_EVEN', signal_names=['U_DUMP_RES'])[0]
# EE Temperature Reference
t_res_odd_0_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_odd_1_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_odd_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_ODD')
t_res_even_0_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_ref_df.loc[0, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
t_res_even_1_ref_df = rb_query.query_ee_t_res_pm(source_timestamp_ee_even_ref_df.loc[1, 'timestamp'], timestamp_fgc_ref, signal_names=['T_RES_BODY_1', 'T_RES_BODY_2', 'T_RES_BODY_3'], system='EE_EVEN')
# nQPS
source_timestamp_nqps_df = rb_query.find_source_timestamp_nqps(timestamp_fgc)
u_nqps_dfs = rb_query.query_voltage_nqps_pm(source_timestamp_nqps_df)
# DFB
source_timestamp_leads_odd_df = rb_query.find_timestamp_leads(timestamp_fgc, 'LEADS_ODD')
t0 = t_start if source_timestamp_leads_odd_df.empty else timestamp_fgc
u_hts_odd_dfs = rb_query.query_leads(t0, source_timestamp_leads_odd_df, system='LEADS_ODD', signal_names=['U_HTS'], spark=spark, duration=[(t_end-t_start, 'ns')])
u_res_odd_dfs = rb_query.query_leads(t0, source_timestamp_leads_odd_df, system='LEADS_ODD', signal_names=['U_RES'], spark=spark, duration=[(t_end-t_start, 'ns')])
source_timestamp_leads_even_df = rb_query.find_timestamp_leads(timestamp_fgc, 'LEADS_EVEN')
t0 = t_start if source_timestamp_leads_even_df.empty else timestamp_fgc
u_hts_even_dfs = rb_query.query_leads(t_start, source_timestamp_leads_even_df, system='LEADS_EVEN', signal_names=['U_HTS'], spark=spark, duration=[(t_end-t_start, 'ns')])
u_res_even_dfs = rb_query.query_leads(t_start, source_timestamp_leads_even_df, system='LEADS_EVEN', signal_names=['U_RES'], spark=spark, duration=[(t_end-t_start, 'ns')])
timestamp_dct = {'FGC': timestamp_fgc, 'PIC': min(timestamp_pic), 'EE_EVEN': timestamp_ee_even,
'EE_ODD': timestamp_ee_odd, 'LEADS_ODD': source_timestamp_leads_odd_df,
'LEADS_EVEN': source_timestamp_leads_even_df}
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% Cell type:code id: tags:
``` python
rb_analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*GRAPHS*:
- t = 0 s corresponds to the start of the test
%% Cell type:code id: tags:
``` python
import matplotlib as mpl
mpl.rcParams['savefig.dpi'] = 80
mpl.rcParams['figure.dpi'] = 80
%matplotlib notebook
title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test, t_start=t_start, t_end=t_end, signal='I_MEAS')
rb_analysis.plot_i_meas(i_meas_nxcals_df, title=title)
```
%% Cell type:markdown id: tags:
## 4.2. Analysis of the Power Converter Main Current
This analysis module displays the main current of the power converter (I_MEAS) compared to the one obtained from the reference FPA (HWC PNO.b2 test with opening of EE systems and without magnet quench).
*ANALYSIS*:
- The evolution of the characteristic time $\tau$ of an exponential decay $f(t)$ is obtained as
\begin{equation}
-\frac{f(t)}{\partial_t f(t)} = -\frac{f_0 e^{-t/\tilde{\tau}}}{\partial_t (f_0 e^{-t/\tilde{\tau}})} = -\frac{f_0 e^{-t/\tilde{\tau}}}{-f_0/\tilde{\tau} e^{-t/\tilde{\tau}}}=-\frac{1}{-1/\tau}=\tau
\end{equation}
Naturally, this formula only applies to exponential decayed characterised by a time constant. Nonetheless, for pseudo-exponential decays, this formula gives a notion of the change of the characteristic time $\tilde{\tau}$. For a circuit we compute the time-varying characteristic time as
\begin{equation}
\tilde{\tau} = - \frac{\text{I_MEAS}}{\partial_t \text{I_MEAS}}
\end{equation}
*CRITERIA*
- Check if the characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s is 90 s< Tau <110 s
*PLOT*:
- The main power converter current (analyzed and reference) on the left axis, I_MEAS
- The characteristic time calculated for the main current (reference and actual) on the right axis, -I_MEAS/dI_MEAS_dt
The actual characteristic time contains steps, which indicate a quenching magnet (decrease of circuit inductance); note that for the reference one the steps are not present. Timing of PIC abort, FGC timestamp, and the maximum current are reported next to the graph.
- t = 0 s corresponds to the respective (analyzed and reference) FGC timestamps.
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_i_meas_pc(circuit_name, timestamp_fgc, timestamp_fgc_ref, min(timestamp_pic), i_meas_df, i_meas_ref_df)
```
%% Cell type:markdown id: tags:
## 4.3. Analysis of the Power Converter Main Current Smoothness
*ANALYSIS*:
- The current smoothness is evaluated on the basis of its second derivative. The derivative is calculated as a rolling division of current and time differences. The rolling window is fixed and equal to 10 points; with the sampling time equal to 0.1 s the time difference is equal to $dt=1 s$.
\begin{equation}
\frac{d i(t)}{dt} = \frac{i(t+dt)-i(t)}{dt}
\end{equation}
To obtain the second derivative of the current decay, the formula above is applied twice to the current profile from PM after the second EE opening (for t > 1 s).
*CRITERIA*
- Check if the second derivative of the current decay of I_MEAS from t = 1 s is -10 A/s^2< dI_MEAS/dt^2 < 10 A/s^2
*PLOT*:
- The second derivative of the main power converter current on the left axis, dI_MEAS/dt^2
- Green bar denotes the acceptance threshold for the second derivative of the main power converter current
- The main power converter current on the right axis, I_MEAS
%% Cell type:code id: tags:
``` python
title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test, t_start=t_start, t_end=t_end, signal='I_MEAS smoothness')
rb_analysis.plot_i_meas_smoothness(i_meas_df, title=title)
```
%% Cell type:markdown id: tags:
## 4.4. Power Converter Voltage Analysis
*CRITERIA*
- Check if the V_MEAS voltage is within -1.5 +/- 0.5 V range 1 s after the EE timestamp
- Check if the V_MEAS voltage is within -1.5 +/- 1 V range 1 s after the EE timestamp
*GRAPHS*
- t = 0 s corresponds to the PM timestamp of the FGC
%% Cell type:code id: tags:
``` python
title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test, t_start=t_start, t_end=t_end, signal='V_MEAS')
rb_analysis.assert_v_meas(timestamp_ee_even, min(timestamp_pic), t_after_ee=1, v_meas_df=v_meas_df, value_min=-2.0, value_max=-1.0, title=title, xmax=25)
rb_analysis.assert_v_meas(timestamp_ee_even, min(timestamp_pic), t_after_ee=1, v_meas_df=v_meas_df, value_min=-2.5, value_max=-0.5, title=title, xmax=25)
```
%% Cell type:markdown id: tags:
## 4.5. Power Converter Earth Current
*CRITERIA*
- Check if the maximum absolute earth current is below 50 mA
*GRAPHS*:
- t = 0 s corresponds to the PM timestamp of the FGC
%% Cell type:code id: tags:
``` python
rb_analysis.plot_i_earth_pc(circuit_name, timestamp_fgc, i_earth_df)
rb_analysis.calculate_max_i_earth_pc(i_earth_df, col_name='Earth Current')
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*ANALYSIS*:
- Calculate U_dump_res (t=0)
- Calculate the characteristic time of pseudo-exponential current decay with the charge approach
*CRITERIA*:
- Check if U_DUMP_RES (t=0) = (±10%) U_DUMP_RES reference.
- Check if the timestamp difference between FGC and EE an odd point is 100±50 ms
The opening delay was 300±50 ms prior to YETS 2017/8
- Check if the time stamp difference between FGC and EE an even point: 600±50 ms
*WARNING*:
- Check if the characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s is 110 s<-Tau <130 s
*GRAPHS*:
- t = 0 s corresponds to the PM timestamp of the FGC
First plot (global view):
- the power converter converter current on the left axis, I_MEAS
- the two energy extraction voltages on the right, U_DUMP_RES, U_DUMP_RES
Second plot (triggering view):
- the power converter current on the left axis, I_MEAS
- the power converter reference current on the left axis, STATUS.I_REF (should stop at the moment of the FGC PM timestamp)
- the two energy extraction voltages on the right axis, U_DUMP_RES, U_DUMP_RES
- the green dashed line denotes the PIC timestamp
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_char_time_u_dump_res_ee(circuit_name, timestamp_fgc, [u_dump_res_odd_df, u_dump_res_even_df], i_meas_df)
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_delay_time_u_dump_res_ee(circuit_name, timestamp_fgc, min(timestamp_pic), [timestamp_ee_odd, timestamp_ee_even],
i_a_df, i_ref_df, [u_dump_res_odd_df, u_dump_res_even_df])
```
%% Cell type:code id: tags:
``` python
rb_analysis.compare_max_u_res_dump_to_reference(u_dump_res_odd_df, u_dump_res_odd_ref_df, 'U_DUMP_RES_ODD')
rb_analysis.compare_max_u_res_dump_to_reference(u_dump_res_even_df, u_dump_res_even_ref_df, 'U_DUMP_RES_EVEN')
```
%% Cell type:markdown id: tags:
## 5.2. Analysis of the Energy Extraction Temperature
*WARNING*
- Check if temperature profile is +/-25 K w.r.t. the reference temperature profile
*PLOT*:
- Temperature signals on the left axis, T
- A reference signal with an acceptable signal range is also provided on the left axis
- t = 0 s corresponds to PM timestamps of each temperature PM entry
%% Cell type:code id: tags:
``` python
rb_analysis.plot_ee_temp(circuit_name + '_EE_ODD', timestamp_ee_odd, t_res_odd_0_df + t_res_odd_1_df, t_res_odd_0_ref_df + t_res_odd_1_ref_df)
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_ee_temp(circuit_name + '_EE_ODD', timestamp_ee_odd, t_res_odd_0_df + t_res_odd_1_df, t_res_odd_0_ref_df + t_res_odd_1_ref_df, abs_margin=25, scaling=1)
```
%% Cell type:code id: tags:
``` python
rb_analysis.plot_ee_temp(circuit_name + '_EE_EVEN', timestamp_ee_even, t_res_even_0_df + t_res_even_1_df, t_res_even_0_ref_df + t_res_even_1_ref_df)
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_ee_temp(circuit_name + '_EE_EVEN', timestamp_ee_even, t_res_even_0_df + t_res_even_1_df, t_res_even_0_ref_df + t_res_even_1_ref_df, abs_margin=25, scaling=1)
```
%% Cell type:markdown id: tags:
# 6. Quench Protection System
## 6.1. nQPS Sunglasses Threshold
*CRITERIA*:
- Check if the max/min nQPS (filtered) is below +/- 80%
**Note that this analysis generates 54 plots that will consume a lot of space. This analysis is typically done once. Please adjust the i_pno current to obtain proper scaling of the threshold.**
%% Cell type:code id: tags:
``` python
%matplotlib inline
i_plim_b2 = i_meas_df.max().values[0]
i_pno = 11850
source_timestamp_nqps_df.rename(columns={'source': 'nqps_crate'}, inplace=True)
rb_analysis.calc_plot_nqps_sunglass(source_timestamp_nqps_df, u_nqps_dfs, threshold=0.7, scaling=i_plim_b2/i_pno)
```
%% Cell type:code id: tags:
``` python
import pandas as pd
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
source_timestamp_nqps_df['datetime_nqps'] = source_timestamp_nqps_df['timestamp'].apply(lambda row: Time.to_string_short(row))
source_timestamp_nqps_df
```
%% Cell type:markdown id: tags:
# 7. Current Leads
## 7.1. Plot of Current Leads
*CRITERIA*:
- Check if the quench detection signal for U_HTS is below the threshold (3 mV)
- Check if the quench detection signal for U_RES is below the threshold (100 mV)
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
%% Cell type:code id: tags:
``` python
%matplotlib inline
rb_analysis.analyze_leads_voltage(u_hts_odd_dfs+u_hts_even_dfs, circuit_name, timestamp_fgc, signal='U_HTS', value_min=-0.003, value_max=0.003)
```
%% Cell type:code id: tags:
``` python
rb_analysis.plot_leads_voltage_zoom(u_hts_odd_dfs+u_hts_even_dfs, circuit_name, timestamp_fgc, timestamp_fgc, timestamp_ee_odd, timestamp_ee_even, signal='U_HTS')
```
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_leads_voltage(u_res_odd_dfs+u_res_even_dfs, circuit_name, timestamp_fgc, signal='U_RES', value_min=-0.1, value_max=0.1)
```
%% Cell type:markdown id: tags:
# 8. Signature Decision
%% Cell type:code id: tags:
``` python
signature = get_expert_decision('Expert Signature Decision: ', ['PASSED', 'FAILED'])
```
%% Cell type:markdown id: tags:
# 9. Final Report
%% Cell type:code id: tags:
``` python
apply_report_template()
file_name_html = '{}_{}-{}-{}_{}.html'.format(circuit_name, hwc_test, Time.to_datetime(t_start).strftime("%Y-%m-%d-%Hh%M"), analysis_start_time, signature)
full_path = '/eos/project/m/mp3/RB/{}/{}/{}'.format(circuit_name, hwc_test, file_name_html)
!mkdir -p /eos/project/m/mp3/RB/$circuit_name/$hwc_test
print('Compact notebook report saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
display(Javascript('IPython.notebook.save_notebook();'))
Time.sleep(5)
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLIM.b2.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/$hwc_test/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='["skip_output"]'
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -124,7 +124,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"skip_output"
]
},
"outputs": [],
"source": [
"circuit_type = 'RQ'\n",
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI1.b3 HWC Test in an RQ Circuit</center></h1>
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/RQ.png" width=75%>
The current in the circuit is increased to I_INJECTION and maintained constant. A quench simulation from one current lead is performed provoking a discharge of the energy through the EE system. The aim of the test is to check at a low current level the performance of the QPS and EE systems.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/PLI1_current.png" width=75%>
The required analysis and signatures are listed below.
|Responsible|Type of analysis|Criterion|
|-----------|----------------|---------|
|PC|Free-Wheel Diode Check|Smooth exponential waveform on the PC voltage and current during the whole decay See EDMS 910092 for current and voltage criteria|
|PC|Automatic analysis on earth current and error current|I_EARTH_PLI1_B3 < I_EARTH_MAX and I_ERR_PLI1_B3 < I_ERR_MAX|
|EE|Energy discharge|Maximum voltage on EE resistance ($R*I$±10%) and maximum temperature of the EE resistance (±10% from theoretical value)|
source: Powering Procedure and Acceptance Criteria for the 13 kA Quadrupole (RQD-RQF) Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874714/5.1">https://edms.cern.ch/document/874714/5.1</a> (Please follow this link for the latest version)
%% Cell type:markdown id: tags:
# Analysis Assumptions
- We consider standard analysis scenarios, i.e., all signals can be queried. Depending on what signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- It is recommended to execute each cell one after another. However, since the signals are queried prior to an analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present).
# Plot Convention
- Scales are labeled with signal name followed by a comma and a unit in the square bracket, e.g., I_MEAS, [A]
- If a reference signal is present, it is represented with a dashed line
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively.
- The grid comes from the left axis
- Title contains timestamp, circuit name, signal name allowing for re-access the signal.
- The plots assigned to the left scale got colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3).
- Each plot has an individual time-synchronization mentioned explicitly in the description.
- If an axis has a single signal, change color of the label to match the signal's color. Otherwise, the label color is black.
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/11)'); import sys
print('Loading (2/11)'); from IPython.display import display, Javascript, clear_output
# Internal libraries
print('Loading (3/11)'); import lhcsmapi
print('Loading (4/11)'); from lhcsmapi.Time import Time
print('Loading (5/11)'); from lhcsmapi.Timer import Timer
print('Loading (6/11)'); from lhcsmapi.analysis.RqCircuitQuery import RqCircuitQuery
print('Loading (7/11)'); from lhcsmapi.analysis.RqCircuitAnalysis import RqCircuitAnalysis
print('Loading (8/11)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (9/11)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (10/11)'); from lhcsmapi.pyedsl.PlotBuilder import create_hwc_plot_title_with_circuit_name
print('Loading (11/11)'); from lhcsmapi.analysis.expert_input import get_expert_decision
analysis_start_time = Time.get_analysis_start_time()
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())
```
%% Cell type:markdown id: tags:
# 1. User Input
1. Copy code from AccTesting and paste into an empty cell below
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/swan-manual-acctesting-integration.png">
- If you only want to test the notebook only for the copy&paste feature (without opening the AccTesting), please copy and execute the code below
```
hwc_test = 'PLI1.b3'
circuit_name = 'RQD.A12'
campaign = 'HWC_2018_1'
t_start = '2018-03-16 14:34:54.267'
t_end = '2018-03-16 14:54:23.962'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'RQ'
hwc_test = 'PLI1.b3'
hwcb = HwcSearchModuleMediator(circuit_type=circuit_type, hwc_test=hwc_test, hwc_summary_path='/eos/project/l/lhcsm/hwc/HWC_Summary.csv')
```
- After opening the browser GUI, choose a circuit name in order to display HWC test with, campaign name as well as start and end time
%% Cell type:code id: tags:
``` python
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
%% Cell type:code id: tags:skip_output
``` python
circuit_type = 'RQ'
if 'hwcb' in locals():
circuit_name = hwcb.get_circuit_name()
t_start = Time.to_unix_timestamp(hwcb.get_start_time())
t_end = Time.to_unix_timestamp(hwcb.get_end_time())
t_start_ref = Time.to_unix_timestamp(hwcb.get_ref_start_time())
t_end_ref = Time.to_unix_timestamp(hwcb.get_ref_end_time())
is_automatic = hwcb.is_automatic_mode()
else:
t_start = Time.to_unix_timestamp(t_start)
t_end = Time.to_unix_timestamp(t_end)
t_start_ref, t_end_ref = HwcSearchModuleMediator.get_last_ref_start_end_time('/eos/project/l/lhcsm/hwc/HWC_Summary.csv', circuit_name, hwc_test, Time.to_string_short(t_start))
t_start_ref, t_end_ref = Time.to_unix_timestamp(t_start_ref), Time.to_unix_timestamp(t_end_ref)
is_automatic = False
circuit_names = [circuit_name if 'RQD' in circuit_name else circuit_name.replace('F', 'D'),
circuit_name if 'RQF' in circuit_name else circuit_name.replace('D', 'F')]
rq_query = RqCircuitQuery(circuit_type, circuit_name, max_executions=16)
rq_analysis = RqCircuitAnalysis(circuit_type, results_table=None, is_automatic=is_automatic)
with Timer():
# PC
i_meas_rqd_nxcals_df = RqCircuitQuery(circuit_type, circuit_names[0]).query_signal_nxcals(t_start, t_end, t0=t_start, system='PC', signal_names='I_MEAS', spark=spark)[0]
i_meas_rqf_nxcals_df = RqCircuitQuery(circuit_type, circuit_names[1]).query_signal_nxcals(t_start, t_end, t0=t_start, system='PC', signal_names='I_MEAS', spark=spark)[0]
source_timestamp_df = rq_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc_rq = source_timestamp_df.at[0, 'timestamp']
i_meas_rq_df, i_a_rq_df, i_ref_rq_df, i_earth_rq_df, i_earth_pcnt_rq_df = rq_query.query_pc_pm(timestamp_fgc_rq, timestamp_fgc_rq, signal_names=['I_MEAS', 'I_A', 'I_REF', 'IEARTH', 'I_EARTH_PCNT'])
# PC Reference
if t_start_ref:
source_timestamp_pc_ref = rq_query.find_source_timestamp_pc(t_start_ref, t_end_ref)
timestamp_fgc_rq_ref = source_timestamp_pc_ref.at[0, 'timestamp']
else:
timestamp_fgc_rq_ref = float('nan')
i_meas_rq_ref_df = rq_query.query_pc_pm(timestamp_fgc_rq_ref, timestamp_fgc_rq_ref, signal_names=['I_MEAS'])[0]
# PIC
timestamp_pic_rq = rq_query.find_timestamp_pic(timestamp_fgc_rq, spark=spark)
# EE Voltage
source_timestamp_ee_rq_df = rq_query.find_source_timestamp_ee(timestamp_fgc_rq)
timestamp_ee_rq = source_timestamp_ee_rq_df.loc[0, 'timestamp']
source_ee_rq = source_timestamp_ee_rq_df.loc[0, 'source']
u_dump_res_rq_df = rq_query.query_ee_u_dump_res_pm(timestamp_ee_rq, timestamp_fgc_rq, signal_names=['U_DUMP_RES'])[0]
# EE Temperature
t_res_rq_0_df = rq_query.query_ee_t_res_pm(source_timestamp_ee_rq_df.loc[0, 'timestamp'], timestamp_fgc_rq, signal_names=['T_RES'])[0]
t_res_rq_1_df = rq_query.query_ee_t_res_pm(source_timestamp_ee_rq_df.loc[1, 'timestamp'], timestamp_fgc_rq, signal_names=['T_RES'])[0]
# EE Voltage Reference
if t_start_ref:
source_timestamp_ee_rq_ref_df = rq_query.find_source_timestamp_ee(timestamp_fgc_rq_ref)
u_dump_res_rq_ref_df = rq_query.query_ee_u_dump_res_pm(source_timestamp_ee_rq_ref_df.loc[0, 'timestamp'], timestamp_fgc_rq_ref, signal_names=['U_DUMP_RES'])[0]
# EE Temperature Reference
t_res_rq_0_ref_df = rq_query.query_ee_t_res_pm(source_timestamp_ee_rq_ref_df.loc[0, 'timestamp'], timestamp_fgc_rq_ref, signal_names=['T_RES'])[0]
t_res_rq_1_ref_df = rq_query.query_ee_t_res_pm(source_timestamp_ee_rq_ref_df.loc[1, 'timestamp'], timestamp_fgc_rq_ref, signal_names=['T_RES'])[0]
# DFB
source_timestamp_leads_rq_df = rq_query.find_timestamp_leads(timestamp_fgc_rq)
t0 = t_start if source_timestamp_leads_rq_df.empty else timestamp_fgc_rq
u_hts_rq_dfs = rq_query.query_leads(t0, source_timestamp_leads_rq_df, signal_names=['U_HTS'], spark=spark, duration=[(t_end-t_start, 'ns')])
u_res_rq_dfs = rq_query.query_leads(t0, source_timestamp_leads_rq_df, signal_names=['U_RES'], spark=spark, duration=[(t_end-t_start, 'ns')])
timestamp_dct = {'FGC': timestamp_fgc_rq, 'PIC': timestamp_pic_rq, 'EE_RQD': timestamp_ee_rq, 'LEADS_RQ': source_timestamp_leads_rq_df}
rq_analysis = RqCircuitAnalysis(circuit_type, None, is_automatic=True)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% Cell type:code id: tags:
``` python
rq_analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*GRAPHS*:
- t = 0 s corresponds to the start of the test
%% Cell type:code id: tags:
``` python
import matplotlib as mpl
mpl.rcParams['savefig.dpi'] = 80
mpl.rcParams['figure.dpi'] = 80
%matplotlib notebook
title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test,
t_start=t_start, t_end=t_end, signal='I_MEAS')
rq_analysis.plot_i_meas([i_meas_rqd_nxcals_df, i_meas_rqf_nxcals_df], title=title)
```
%% Cell type:markdown id: tags:
## 4.2. Analysis of the Power Converter Main Current
This analysis module displays the main current of the power converter (I_MEAS) compared to the one obtained from the reference FPA (HWC PNO.b2 test with opening of EE systems and without magnet quench).
*ANALYSIS*:
- The evolution of the characteristic time $\tau$ of an exponential decay $f(t)$ is obtained as
\begin{equation}
-\frac{f(t)}{\partial_t f(t)} = -\frac{f_0 e^{-t/\tilde{\tau}}}{\partial_t (f_0 e^{-t/\tilde{\tau}})} = -\frac{f_0 e^{-t/\tilde{\tau}}}{-f_0/\tilde{\tau} e^{-t/\tilde{\tau}}}=-\frac{1}{-1/\tau}=\tau
\end{equation}
Naturally, this formula only applies to exponential decayed characterised by a time constant. Nonetheless, for pseudo-exponential decays, this formula gives a notion of the change of the characteristic time $\tilde{\tau}$. For a circuit we compute the time-varying characteristic time as
\begin{equation}
\tilde{\tau} = - \frac{\text{I_MEAS}}{\partial_t \text{I_MEAS}}
\end{equation}
*CRITERIA*
- Check if the characteristic time of the pseudo-exponential I_MEAS decay from t=1 to 100 s is 25 s< Tau < 35 s
*PLOT*:
- The main power converter current (analyzed and reference) on the left axis, I_MEAS
- The characteristic time calculated for the main current (reference and actual) on the right axis, -I_MEAS/dI_MEAS_dt
The actual characteristic time contains steps, which indicate a quenching magnet (decrease of circuit inductance); note that for the reference one the steps are not present. Timing of PIC abort, FGC timestamp, and the maximum current are reported next to the graph.
- t = 0 s corresponds to the respective (analyzed and reference) FGC timestamps.
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_i_meas_pc(circuit_name, timestamp_fgc_rq, timestamp_fgc_rq_ref, timestamp_pic_rq, i_meas_rq_df, i_meas_rq_ref_df)
```
%% Cell type:markdown id: tags:
## 4.3. Analysis of the Power Converter Main Current Smoothness
*ANALYSIS*:
- The current smoothness is evaluated on the basis of its second derivative. The derivative is calculated as a rolling division of current and time differences. The rolling window is fixed and equal to 10 points; with the sampling time equal to 0.1 s the time difference is equal to $dt=1 s$.
\begin{equation}
\frac{d i(t)}{dt} = \frac{i(t+dt)-i(t)}{dt}
\end{equation}
To obtain the second derivative of the current decay, the formula above is applied twice to the current profile from PM after the second EE opening (for t > 1 s).
*CRITERIA*
- Check if the second derivative of the current decay of I_MEAS from t = 1 s is -10 A/s^2< dI_MEAS/dt^2 < 10 A/s^2
*PLOT*:
- The second derivative of the main power converter current on the left axis, dI_MEAS/dt^2
- Green bar denotes the acceptance threshold for the second derivative of the main power converter current
- The main power converter current on the right axis, I_MEAS
%% Cell type:code id: tags:
``` python
title = create_hwc_plot_title_with_circuit_name(circuit_name=circuit_name, hwc_test=hwc_test, t_start=t_start, t_end=t_end, signal='I_MEAS smoothness')
rq_analysis.plot_i_meas_smoothness(i_meas_rq_df, title=title)
```
%% Cell type:markdown id: tags:
## 4.4. Power Converter Earth Current
*CRITERIA*
- Check if the maximum absolute earth current is below 50 mA
*GRAPHS*:
- t = 0 s corresponds to the PM timestamp of the FGC
%% Cell type:code id: tags:
``` python
rq_analysis.plot_i_earth_pc(circuit_name, timestamp_fgc_rq, i_earth_rq_df)
rq_analysis.calculate_max_i_earth_pc(i_earth_rq_df, col_name='Earth Current')
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*CRITERIA*:
- Check if U_DUMP_RES (t=0) = (±10%) U_DUMP_RES reference.
- Check if the characteristic time of the pseudo-exponential U_DUMP_RES decay from t=2 to 100 s is 25 s< Tau < 35 s
- Check if the timestamp difference between FGC and EE is 100±15 ms
*GRAPHS* (one for each circuit):
- t = 0 s corresponds to the PM timestamp of the FGC
First plot (global view):
- the power converter converter current on the left axis, I_MEAS
- the two energy extraction voltages on the right, U_DUMP_RES
Second plot (triggering view):
- the power converter current on the left axis, I_MEAS
- the power converter reference current on the left axis, STATUS.I_REF (should stop at the moment of the FGC PM timestamp)
- the energy extraction voltage on the right axis, U_DUMP_RES
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_char_time_u_dump_res_ee(circuit_name, timestamp_fgc_rq, u_dump_res_rq_df, i_meas_rq_df)
```
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_delay_time_u_dump_res_ee(circuit_name, timestamp_fgc_rq, timestamp_pic_rq, timestamp_ee_rq, i_a_rq_df, i_ref_rq_df, u_dump_res_rq_df)
```
%% Cell type:code id: tags:
``` python
rq_analysis.compare_max_u_res_dump_to_reference(u_dump_res_rq_df, u_dump_res_rq_ref_df, 'U_DUMP_RES')
```
%% Cell type:markdown id: tags:
## 5.2. Analysis of the Energy Extraction Temperature
*CRITERIA*:
- Check if each temperature profile is +/-25 K w.r.t. the reference temperature profile
*GRAPHS*:
- Temperature signals on the left axis, T
- A reference signal with an acceptable signal range is also presented on the left axis
- t = 0 s corresponds to PM timestamps of each temperature PM entry
%% Cell type:code id: tags:
``` python
rq_analysis.plot_ee_temp(circuit_name, timestamp_ee_rq, [t_res_rq_0_df, t_res_rq_1_df], [t_res_rq_0_ref_df, t_res_rq_1_ref_df])
```
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_ee_temp(circuit_name, timestamp_ee_rq, [t_res_rq_0_df, t_res_rq_1_df], [t_res_rq_0_ref_df, t_res_rq_1_ref_df], abs_margin=25, scaling=1)
```
%% Cell type:markdown id: tags:
# 6. Current Leads
## 6.1. Plot of Current Leads
*CRITERIA*:
- Check if the quench detection signal for U_HTS is below the threshold (3 mV)
- Check if the quench detection signal for U_RES is below the threshold (100 mV)
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_leads_voltage(u_hts_rq_dfs, circuit_name, timestamp_fgc_rq, signal='U_HTS', value_min=-0.003, value_max=0.003)
```
%% Cell type:code id: tags:
``` python
rq_analysis.analyze_leads_voltage(u_res_rq_dfs, circuit_name, timestamp_fgc_rq, signal='U_RES', value_min=-0.1, value_max=0.1)
```
%% Cell type:markdown id: tags:
# 7. Signature Decision
%% Cell type:code id: tags:
``` python
signature = get_expert_decision('Expert Signature Decision: ', ['PASSED', 'FAILED'])
```
%% Cell type:markdown id: tags:
# 8. Final Report
%% Cell type:code id: tags:
``` python
circuit_name = circuit_names[0].replace('D', '')
apply_report_template()
file_name_html = '{}_{}-{}-{}_{}.html'.format(circuit_name, hwc_test, Time.to_datetime(t_start).strftime("%Y-%m-%d-%Hh%M"), analysis_start_time, signature)
full_path = '/eos/project/m/mp3/RQ/{}/{}/{}'.format(circuit_name, hwc_test, file_name_html)
!mkdir -p /eos/project/m/mp3/RQ/$circuit_name/$hwc_test
print('Compact notebook report saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
display(Javascript('IPython.notebook.save_notebook();'))
Time.sleep(5)
!{sys.executable} -m jupyter nbconvert --to html $'AN_RQ_PLI1.b3.ipynb' --output /eos/project/m/mp3/RQ/$circuit_name/$hwc_test/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='["skip_output"]'
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -126,7 +126,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": [
"skip_output"
]
},
"outputs": [],
"source": [
"circuit_type = 'RQ'\n",
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI3.b3 HWC Test in an RQ Circuit</center></h1>
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/RQ.png" width=75%>
The circuit is powered up to I_INTERM_2. After a short plateau the EE system is activated by a quench simulation in a current lead.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rq/PLI3_current.png" width=75%>
The aim of this test is to check the performance of the QPS and EE systems and the correct current sharing in the different FWD. The current to earth and the current error from the PC are checked during the sequence.
The required analysis and signatures are listed below.
|Responsible|Type of analysis|Criterion|
|-----------|----------------|---------|
|PC|Free-Wheel Diode Check|Smooth exponential waveform on the PC voltage and current during the whole decay See EDMS <a href="https://edms.cern.ch/ui/#!master/navigator/document?D:1901098320:1901098320:subDocs">910092</a> for current and voltage criteria|
|PC|Automatic analysis on earth current and error current|I_EARTH_PLI3_B3 < I_EARTH_MAX and I_ERR_PLI3_B3 < I_ERR_MAX|
|EE|Energy discharge|Maximum voltage on EE resistance ($R*I$±10%) and maximum temperature of the EE resistance (±10% from theoretical value)|
source: Powering Procedure and Acceptance Criteria for the 13 kA Quadrupole (RQD-RQF) Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874714/5.1">https://edms.cern.ch/document/874714/5.1</a> (Please follow this link for the latest version)
%% Cell type:markdown id: tags:
# Analysis Assumptions
- We consider standard analysis scenarios, i.e., all signals can be queried. Depending on what signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- It is recommended to execute each cell one after another. However, since the signals are queried prior to an analysis, any order of execution is allowed. In case an analysis cell is aborted, the following ones may not be executed (e.g. I\_MEAS not present).
# Plot Convention
- Scales are labeled with signal name followed by a comma and a unit in the square bracket, e.g., I_MEAS, [A]
- If a reference signal is present, it is represented with a dashed line
- If the main current is present, its axis is on the left. Remaining signals are attached to the axis on the right. The legend of these signals is located on the lower left and upper right, respectively.
- The grid comes from the left axis
- Title contains timestamp, circuit name, signal name allowing for re-access the signal.
- The plots assigned to the left scale got colors: blue (C0) and orange (C1). Plots presented on the right have colors red (C2) and green (C3).
- Each plot has an individual time-synchronization mentioned explicitly in the description.
- If an axis has a single signal, change color of the label to match the signal's color. Otherwise, the label color is black.
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/11)'); import sys
print('Loading (2/11)'); from IPython.display import display, Javascript, clear_output
# Internal libraries
print('Loading (3/11)'); import lhcsmapi
print('Loading (4/11)'); from lhcsmapi.Time import Time
print('Loading (5/11)'); from lhcsmapi.Timer import Timer
print('Loading (6/11)'); from lhcsmapi.analysis.RqCircuitQuery import RqCircuitQuery
print('Loading (7/11)'); from lhcsmapi.analysis.RqCircuitAnalysis import RqCircuitAnalysis
print('Loading (8/11)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (9/11)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (10/11)'); from lhcsmapi.pyedsl.PlotBuilder import create_hwc_plot_title_with_circuit_name
print('Loading (11/11)'); from lhcsmapi.analysis.expert_input import get_expert_decision
analysis_start_time = Time.get_analysis_start_time()
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())
```
%% Cell type:markdown id: tags:
# 1. User Input
1. Copy code from AccTesting and paste into an empty cell below
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/swan-manual-acctesting-integration.png">
- If you only want to test the notebook only for the copy&paste feature (without opening the AccTesting), please copy and execute the code below
```
hwc_test = 'PLI3.b3'
circuit_name = 'RQD.A12'
campaign = 'HWC_2017'
t_start = '2017-04-24 19:29:45.679'
t_end = '2017-04-24 19:51:14.809'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'RQ'
hwc_test = 'PLI3.b3'
hwcb = HwcSearchModuleMediator(circuit_type=circuit_type, hwc_test=hwc_test, hwc_summary_path='/eos/project/l/lhcsm/hwc/HWC_Summary.csv')
```
- After opening the browser GUI, choose a circuit name in order to display HWC test with, campaign name as well as start and end time
%% Cell type:code id: tags:
``` python
```