Commit c974919b authored by Michal Maciejewski's avatar Michal Maciejewski
Browse files

Added figures to IT

parent b676588b
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
%% Cell type:markdown id: tags:
<h1><center>Analysis of PIC2 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%>
The current for PIC2 is equal to I_MIN_OP.
The required analysis and signatures are listed below.
|Responsible|Test|Type of analysis|
|-----------|----|----------------|
|PIC - No signature|Test software link (PIC- Cryo)|Test the correct communication of CRYO_START between the CRYO supervision and the PIC supervision|
|PIC - No signature|Tests software link (PIC- QPS)|Test the correct communication of QPS_OK between the QPS supervision and the PIC supervision|
|PIC - No signature|PC Permit|Test the correct communication of QPS_OK between the QPS supervision and the PIC supervision|
|PIC|Powering Failure|Powering failure is received by the PIC and circuit is switched off with a slow abort.|
|PIC, MP3|Powering Failure Circuit Quench via QPS|Quench signal is received by the PIC and circuit is switched off with a fast power abort. EE switches open.|
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> (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.
- In case an analyzed signal can't be queried, a particular analysis is skipped. In other words, all signals have to be available in order to perform an 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
In order to update the lhcsmapi, please execute the following command in the SWAN terminal <a href="https://github.com/swan-cern/help/blob/master/swan/open_terminal.md">[?]</a>:
`pip install --user --upgrade lhcsmapi`
## 0.1. Import Necessary Packages
%% Cell type:code id: tags:
``` python
import io
import re
from IPython.display import display, HTML
from datetime import datetime
import warnings
import sys
import pandas as pd
from copy import deepcopy
# NXCALS libraries
from cern.nxcals.pyquery.builders import *
# lhc-sm-api
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
# GUI
from lhcsmapi.gui.hwc.HwcBrowser import HwcBrowser
# Analysis modules
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
from lhcsmapi.pyedsl.AssertionBuilder import AssertionBuilder
```
%% Cell type:markdown id: tags:
## 0.2. LHCSMAPI Version
%% Cell type:code id: tags:
``` python
import lhcsmapi
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__))
```
%% Output
Analysis executed with lhcsmapi version: 1.3.225
%% Cell type:markdown id: tags:
## 0.3. Notebook Version
%% Cell type:code id: tags:
``` python
with io.open("../__init__.py", "rt", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version))
```
%% Output
Analysis executed with lhc-sm-hwc notebooks version: 1.0.3
%% Cell type:markdown id: tags:
## 0.4. Papermill Parameters
%% Cell type:code id: tags:parameters
``` python
notebook_execution_mode = 'manual'
circuit_name = ''
start_time = ''
end_time = ''
```
%% Cell type:markdown id: tags:
## 0.5. Configuration for Execution Outside of SWAN
%% Cell type:code id: tags:
``` python
if notebook_execution_mode == 'automatic':
try:
spark.stop()
except NameError:
pass
# Manual spark configuration to execute notebook outside of SWAN service
import os
import random
from pyspark import SparkContext, SparkConf
from pyspark.sql import SparkSession
if "SPARK_PORTS" in os.environ:
ports = os.getenv("SPARK_PORTS").split(",")
else:
ports = [random.randrange(5001,5300),random.randrange(5001,5300),random.randrange(5001,5300)]
# change to SPARK_MASTER_IP
nxcals_jars=os.environ.get('NXCALS_JARS')
conf = SparkConf()
conf.set('spark.master', 'yarn')
conf.set('spark.authenticate', True)
conf.set('spark.network.crypto.enabled', True)
conf.set('spark.authenticate.enableSaslEncryption', True)
conf.set("spark.logConf", True)
conf.set("spark.driver.host", "spark-runner.cern.ch")
conf.set("spark.driver.port", ports[0])
conf.set("spark.blockManager.port", ports[1])
conf.set("spark.ui.port", ports[2])
conf.set('spark.executorEnv.PYTHONPATH', os.environ.get('PYTHONPATH'))
conf.set('spark.executorEnv.LD_LIBRARY_PATH', os.environ.get('LD_LIBRARY_PATH'))
conf.set('spark.executorEnv.JAVA_HOME', os.environ.get('JAVA_HOME'))
conf.set('spark.executorEnv.SPARK_HOME', os.environ.get('SPARK_HOME'))
conf.set('spark.executorEnv.SPARK_EXTRA_CLASSPATH', os.environ.get('SPARK_DIST_CLASSPATH'))
conf.set('spark.driver.extraClassPath', nxcals_jars)
conf.set('spark.executor.extraClassPath', nxcals_jars)
conf.set('spark.driver.extraJavaOptions',"-Dlog4j.configuration=file:log4j_conf -Dservice.url=https://cs-ccr-nxcals6.cern.ch:19093,https://cs-ccr-nxcals7.cern.ch:19093,https://cs-ccr-nxcals8.cern.ch:19093 -Djavax.net.ssl.trustStore=/tmp/truststore.jks -Djavax.net.ssl.trustStorePassword=password")
sc = SparkContext(conf=conf)
spark = SparkSession(sc)
```
%% Cell type:markdown id: tags:
# 1. Select HWC PIC2 Test
- 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
if notebook_execution_mode == 'manual':
circuit_type = 'RB'
hwc_test = 'PIC2'
hwc_test_history_df = pd.read_csv('/eos/project/l/lhcsm/hwc/RB/hwc_test_history.csv')
hwcb = HwcBrowser(hwc_test_history_df, circuit_type, hwc_test)
display(hwcb.widget)
else:
circuit_type = 'RB'
hwc_test = 'PIC2'
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
if notebook_execution_mode == 'manual':
circuit_name = hwcb.get_circuit_name()
t_start = hwcb.get_start_time()
t_end = hwcb.get_end_time()
author = hwcb.get_author()
is_automatic = hwcb.is_automatic_mode()
else:
author = 'AccTesting'
is_automatic = True
t_start = start_time
t_end = end_time
rb_query = RbCircuitQuery(circuit_type, circuit_name)
with Timer():
# PC
i_meas_nxcals_df = QueryBuilder().with_nxcals(spark) \
.with_duration(t_start=t_start, t_end=t_end) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name=circuit_name, system='PC', signal='I_MEAS') \
.signal_query() \
.synchronize_time() \
.convert_index_to_sec().dfs[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 = rb_query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF'])
# PIC
timestamp_pic = rb_query.find_timestamp_pic(timestamp_fgc, spark=spark)
# EE Voltage
source_timestamp_ee_df = rb_query.find_source_timestamp_ee(timestamp_fgc)
timestamp_ee_odd = source_timestamp_ee_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(source_ee_odd, timestamp_ee_odd, timestamp_fgc, system='EE_ODD')[0]
timestamp_ee_even = source_timestamp_ee_df.loc[2, 'timestamp']
source_ee_even = source_timestamp_ee_df.loc[2, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(source_ee_even, timestamp_ee_even, timestamp_fgc, system='EE_EVEN')[0]
# 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', signals=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signals=['U_RES'], spark=spark)
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', signals=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signals=['U_RES'], spark=spark)
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)
rb_analysis = RbCircuitAnalysis(circuit_type, pd.DataFrame(), is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% 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,
'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:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*QUERY*:
- NXCALS for the main power converter current, I_MEAS
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|i_meas_nxcals_df | DataFrame | A | Main power converter current, I_MEAS|
*ANALYSIS*:
- Calculation of the duration of current plateaus
*PLOT*:
- The main power converter current on the left axis, I_MEAS
- t = 0 s corresponds to the start of the test
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
ax = i_meas_nxcals_df.plot(figsize=(30, 10), grid=True)
ax.set_xlabel("time, [s]", fontsize=15)
ax.set_ylabel("I_MEAS, [A]", fontsize=15)
ax.tick_params(labelsize=15)
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*QUERY*:
- PM for the reference power converter current (STATUS.I_REF)
- PM for two energy extraction voltages (U_DUMP_RES_1, U_DUMP_RES_2)
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|timestamp_ee |int |ns |Timestamp of an EE PM entry being analyzed|
|timestamp_pic |int |ns |Timestamp of a PIC trigger, 0 ns if can't be queried|
|i_a_df |DataFrame |A |I_A is the raw power converter current logged around the FPA with high sampling frequench|
|i_meas_df |DataFrame |A |I_MEAS is filtered I_A with lower sampling frequency and longer duration|
|i_ref_df | DataFrame | A | Reference power converter current, STATUS.I_REF|
|u_dump_res_1_sync_df | DataFrame | V | First energy extraction voltage U_DUMP_RES_1|
|u_dump_res_2_sync_df | DataFrame | V | Second energy extraction voltage U_DUMP_RES_2|
|is_automatic |bool |- |Flag denoting whether each analysis step is automatically approved (True) or requires an expert approval (False)|
*ANALYSIS*:
- Check if all signals are present:
- If the reference power converter current is missing, there is a warning and the analysis continues
- If any of the energy extraction voltages is not present, raise an error and abort analysis
- U_dump_res (t=0) = 0.075*I V (±10%).
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 110 s<-Tau <130 s
- Time stamp difference between FGC and EE an odd point: 290±30 ms (to be checked with Reiner)
After YETS 2017/8 the EE timestamp odd(RR or UJ) has been reduced and should now be 100+-30 ms after the FGC time stamp
- Time stamp difference between FGC and EE an even point: 560±40 ms (to be checked with Reiner)
*PLOT*:
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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
Second plot (triggering view):
- the power converter current on the left axix, 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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
*OUTPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|is_ee_correct |str |- |Result of an automatic analysis|
|report_analysis |DataFrame |- |A dataframe containing the analysis results and comments (expert comments if executed in the automatic mode); each row corresponds to a quenched magnet|
%% 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.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:
# 6. Current Leads
## 6.1. Plot of Current Leads
*QUERY*:
- PM for voltage of even leads, U_HTS, U_RES
- PM for voltage of odd leads, U_HTS, U_RES
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_type |str |- |Type of the analyzed circuit, e.g., 'RB'|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|u_leads_odd_df |DataFrame |V |Voltage of even leads, U_HTS, U_RES|
|u_leads_even_df | DataFrame |V |Voltage of even leads, U_HTS, U_RES|
*ANALYSIS*:
- quench detection for U_HTS for 2 consecutive datapoints above the threshold (3 mV)
- detection for U_RES for 2 consecutive datapoints above the threshold (100 mV)
*PLOT*:
For odd and even leads
- voltage of the normal conducting leads on the left axis, U_RES
- voltage of the HTS leads on the left axis, U_HTS
- t = 0 s corresponds to the respective (EVEN and ODD) LEADS timestamps.
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
rb_analysis.analyze_leads_voltage(u_hts_odd_dfs+u_hts_even_dfs, signal='U_HTS', value_min=-0.003, value_max=0.003)
rb_analysis.analyze_leads_voltage(u_res_odd_dfs+u_res_even_dfs, signal='U_RES', value_min=-0.1, value_max=0.1)
```
%% Cell type:markdown id: tags:
# 7. Final Report
%% Cell type:code id: tags:
``` python
campaign = hwcb.get_campaign()
file_name_html = '{}-{}_report.html'.format(Time.to_datetime(t_start).strftime("%Y.%m.%d_%H%M%S.%f"), Time.to_datetime(t_end).strftime("%Y.%m.%d_%H%M%S.%f"))
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PIC2.ipynb' --output /eos/project/l/lhcsm/hwc/RB/$circuit_name/$hwc_test/$campaign/$file_name_html
```
%% Cell type:markdown id: tags:
# 8. AccTesting Signature
%% Cell type:code id: tags:
``` python
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI1.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%>
The current in the circuit is increased to I_INJECTION and shortly 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.
From 2010 on, a time delay is implemented between the switch opening and the FPA signal received (300 ms at the odd point, 600 ms at the even point).
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/PLI1_current.png" width=75%>
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)|
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> (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.
- In case an analyzed signal can't be queried, a particular analysis is skipped. In other words, all signals have to be available in order to perform an 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
In order to update the lhcsmapi, please execute the following command in the SWAN terminal <a href="https://github.com/swan-cern/help/blob/master/swan/open_terminal.md">[?]</a>:
`pip install --user --upgrade lhcsmapi`
## 0.1. Import Necessary Packages
%% Cell type:code id: tags:
``` python
import io
import re
import sys
import pandas as pd
# NXCALS libraries
from cern.nxcals.pyquery.builders import *
# lhc-sm-api
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
# GUI
from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
from lhcsmapi.gui.pc.FgcPmSearchBaseModule import FgcPmSearchBaseModule
from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator
from lhcsmapi.gui.hwc.HwcBrowser import HwcBrowser
# Query
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
# Analysis
from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
```
%% Cell type:markdown id: tags:
## 0.2. LHCSMAPI Version
%% Cell type:code id: tags:
``` python
import lhcsmapi
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__))
```
%% Output
Analysis executed with lhcsmapi version: 1.3.225
%% Cell type:markdown id: tags:
## 0.3. Notebook Version
%% Cell type:code id: tags:
``` python
with io.open("../__init__.py", "rt", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version))
```
%% Output
Analysis executed with lhc-sm-hwc notebooks version: 1.0.3
%% Cell type:markdown id: tags:
# 1. Select PLI1.b2 HWC Test
- 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
circuit_type = 'RB'
hwc_test = 'PLI1.b2'
hwc_test_history_df = pd.read_csv('/eos/project/l/lhcsm/hwc/RB/hwc_test_history.csv')
hwcb = HwcBrowser(hwc_test_history_df, circuit_type, hwc_test)
display(hwcb.widget)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
circuit_name = hwcb.get_circuit_name()
t_start = hwcb.get_start_time()
t_end = hwcb.get_end_time()
author = hwcb.get_author()
is_automatic = hwcb.is_automatic_mode()
rb_query = RbCircuitQuery(circuit_type, circuit_name)
with Timer():
# PC
i_meas_nxcals_df = QueryBuilder().with_nxcals(spark) \
.with_duration(t_start=t_start, t_end=t_end) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name=circuit_name, system='PC', signal='I_MEAS') \
.signal_query() \
.synchronize_time() \
.convert_index_to_sec().dfs[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 = rb_query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF'])
# PIC
timestamp_pic = rb_query.find_timestamp_pic(timestamp_fgc, spark=spark)
# EE Voltage
source_timestamp_ee_df = rb_query.find_source_timestamp_ee(timestamp_fgc)
timestamp_ee_odd = source_timestamp_ee_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(source_ee_odd, timestamp_ee_odd, timestamp_fgc, system='EE_ODD')[0]
timestamp_ee_even = source_timestamp_ee_df.loc[2, 'timestamp']
source_ee_even = source_timestamp_ee_df.loc[2, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(source_ee_even, timestamp_ee_even, timestamp_fgc, system='EE_EVEN')[0]
# 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', signals=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signals=['U_RES'], spark=spark)
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', signals=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signals=['U_RES'], spark=spark)
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)
rb_analysis = RbCircuitAnalysis(circuit_type, pd.DataFrame(), is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% 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,
'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:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*QUERY*:
- NXCALS for the main power converter current, I_MEAS
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|i_meas_df | DataFrame | A | Main power converter current, I_MEAS|
*ANALYSIS*:
- Calculation of the duration of current plateaus
*PLOT*:
- The main power converter current (reference and actual) on the left axis, I_MEAS
- t = 0 s corresponds to the respective (actual and reference) FGC timestamps.
- Orange box(es) represent period(s) of time with constant current used for calculation of busbar resistance and DFB thresholds
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
ax = i_meas_nxcals_df.plot(figsize=(30, 10), grid=True)
ax.set_xlabel("time, [s]", fontsize=15)
ax.set_ylabel("I_MEAS, [A]", fontsize=15)
ax.tick_params(labelsize=15)
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*QUERY*:
- PM for the reference power converter current (STATUS.I_REF)
- PM for two energy extraction voltages (U_DUMP_RES_1, U_DUMP_RES_2)
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|timestamp_ee |int |ns |Timestamp of an EE PM entry being analyzed|
|timestamp_pic |int |ns |Timestamp of a PIC trigger, 0 ns if can't be queried|
|i_a_df |DataFrame |A |I_A is the raw power converter current logged around the FPA with high sampling frequench|
|i_meas_df |DataFrame |A |I_MEAS is filtered I_A with lower sampling frequency and longer duration|
|i_ref_df | DataFrame | A | Reference power converter current, STATUS.I_REF|
|u_dump_res_1_sync_df | DataFrame | V | First energy extraction voltage U_DUMP_RES_1|
|u_dump_res_2_sync_df | DataFrame | V | Second energy extraction voltage U_DUMP_RES_2|
|is_automatic |bool |- |Flag denoting whether each analysis step is automatically approved (True) or requires an expert approval (False)|
*ANALYSIS*:
- Check if all signals are present:
- If the reference power converter current is missing, there is a warning and the analysis continues
- If any of the energy extraction voltages is not present, raise an error and abort analysis
- U_dump_res (t=0) = 0.075*I V (±10%).
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 110 s<-Tau <130 s
- Time stamp difference between FGC and EE an odd point: 290±30 ms (to be checked with Reiner)
After YETS 2017/8 the EE timestamp odd(RR or UJ) has been reduced and should now be 100+-30 ms after the FGC time stamp
- Time stamp difference between FGC and EE an even point: 560±40 ms (to be checked with Reiner)
*PLOT*:
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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
Second plot (triggering view):
- the power converter current on the left axix, 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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
*OUTPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|is_ee_correct |str |- |Result of an automatic analysis|
|report_analysis |DataFrame |- |A dataframe containing the analysis results and comments (expert comments if executed in the automatic mode); each row corresponds to a quenched magnet|
%% 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.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:
# 6. Current Leads
## 6.1. Plot of Current Leads
*QUERY*:
- PM for voltage of even leads, U_HTS, U_RES
- PM for voltage of odd leads, U_HTS, U_RES
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_type |str |- |Type of the analyzed circuit, e.g., 'RB'|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|u_leads_odd_df |DataFrame |V |Voltage of even leads, U_HTS, U_RES|
|u_leads_even_df | DataFrame |V |Voltage of even leads, U_HTS, U_RES|
*ANALYSIS*:
- quench detection for U_HTS for 2 consecutive datapoints above the threshold (3 mV)
- detection for U_RES for 2 consecutive datapoints above the threshold (100 mV)
*PLOT*:
For odd and even leads
- voltage of the normal conducting leads on the left axis, U_RES
- voltage of the HTS leads on the left axis, U_HTS
- t = 0 s corresponds to the respective (EVEN and ODD) LEADS timestamps.
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
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)
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:
# 7. Final Report
%% Cell type:code id: tags:
``` python
campaign = hwcb.get_campaign()
file_name_html = '{}-{}_report.html'.format(Time.to_datetime(t_start).strftime("%Y.%m.%d_%H%M%S.%f"), Time.to_datetime(t_end).strftime("%Y.%m.%d_%H%M%S.%f"))
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI1.b2.ipynb' --output /eos/project/l/lhcsm/hwc/RB/$circuit_name/$hwc_test/$campaign/$file_name_html
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI1.d2 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%>
The current in the circuit is increased to I_INJECTION and shortly maintained constant. A powering failure is then generated. After a minute the EE system is activated to rapidly extract the energy of the circuit. The aim of this test is to verify the correct functionality of the PC when a powering failure occurs.
The required analysis and signatures are listed below.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/PLI1_current.png" width=75%>
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 (if the discharge was provoked by the operator)|Maximum voltage on EE resistance ($R*I$±10%) and maximum temperature of the EE resistance (±10% from theoretical value)|
|EE|Energy discharge (if the discharge was provoked by the operator)|Time delay on switch opening (300±50ms at odd point and 600±50ms at even point)|
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> (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.
- In case an analyzed signal can't be queried, a particular analysis is skipped. In other words, all signals have to be available in order to perform an 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
In order to update the lhcsmapi, please execute the following command in the SWAN terminal <a href="https://github.com/swan-cern/help/blob/master/swan/open_terminal.md">[?]</a>:
`pip install --user --upgrade lhcsmapi`
## 0.1. Import Necessary Packages
%% Cell type:code id: tags:
``` python
import io
import re
import sys
import pandas as pd
# NXCALS libraries
from cern.nxcals.pyquery.builders import *
# lhc-sm-api
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
# GUI
from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
from lhcsmapi.gui.pc.FgcPmSearchBaseModule import FgcPmSearchBaseModule
from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator
from lhcsmapi.gui.hwc.HwcBrowser import HwcBrowser
# Query
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
# Analysis
from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
```
%% Cell type:markdown id: tags:
## 0.2. LHCSMAPI Version
%% Cell type:code id: tags:
``` python
import lhcsmapi
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__))
```
%% Output
Analysis executed with lhcsmapi version: 1.3.225
%% Cell type:markdown id: tags:
## 0.3. Notebook Version
%% Cell type:code id: tags:
``` python
with io.open("../__init__.py", "rt", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version))
```
%% Output
Analysis executed with lhc-sm-hwc notebooks version: 1.0.3
%% Cell type:markdown id: tags:
# 1. Select PLI1.d2 HWC Test
- 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
circuit_type = 'RB'
hwc_test = 'PLI1.d2'
hwc_test_history_df = pd.read_csv('/eos/project/l/lhcsm/hwc/RB/hwc_test_history.csv')
hwcb = HwcBrowser(hwc_test_history_df, circuit_type, hwc_test)
display(hwcb.widget)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
circuit_name = hwcb.get_circuit_name()
t_start = hwcb.get_start_time()
t_end = hwcb.get_end_time()
author = hwcb.get_author()
is_automatic = hwcb.is_automatic_mode()
rb_query = RbCircuitQuery(circuit_type, circuit_name)
with Timer():
# PC
source_timestamp_pc = rb_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc = source_timestamp_pc.at[0, 'timestamp']
# EE Voltage
source_timestamp_ee_df = rb_query.find_source_timestamp_ee(timestamp_fgc)
timestamp_ee_odd = source_timestamp_ee_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(source_ee_odd, timestamp_ee_odd, timestamp_ee_odd, system='EE_ODD')[0]
timestamp_ee_even = source_timestamp_ee_df.loc[2, 'timestamp']
source_ee_even = source_timestamp_ee_df.loc[2, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(source_ee_even, timestamp_ee_even, timestamp_ee_even, system='EE_EVEN')[0]
# PC
i_meas_nxcals_df = QueryBuilder().with_nxcals(spark) \
.with_duration(t_start=t_start, t_end=t_end) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name=circuit_name, system='PC', signal='I_MEAS') \
.signal_query() \
.synchronize_time() \
.convert_index_to_sec().dfs[0]
i_meas_df, i_a_df, i_ref_df = rb_query.query_pc_pm(timestamp_fgc, timestamp_ee_odd, signal_names=['I_MEAS', 'I_A', 'I_REF'])
# 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', signals=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signals=['U_RES'], spark=spark)
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', signals=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signals=['U_RES'], spark=spark)
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)
rb_analysis = RbCircuitAnalysis(circuit_type, pd.DataFrame(), is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% Cell type:code id: tags:
``` python
timestamp_dct = {'FGC': timestamp_fgc, 'EE_EVEN': timestamp_ee_even, 'EE_ODD': timestamp_ee_odd,
'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:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*QUERY*:
- NXCALS for the main power converter current, I_MEAS
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|i_meas_df | DataFrame | A | Main power converter current, I_MEAS|
*ANALYSIS*:
- Calculation of the duration of current plateaus
*PLOT*:
- The main power converter current (reference and actual) on the left axis, I_MEAS
- t = 0 s corresponds to the respective (actual and reference) FGC timestamps.
- Orange box(es) represent period(s) of time with constant current used for calculation of busbar resistance and DFB thresholds
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
ax = i_meas_nxcals_df.plot(figsize=(30, 10), grid=True)
ax.set_xlabel("time, [s]", fontsize=15)
ax.set_ylabel("I_MEAS, [A]", fontsize=15)
ax.tick_params(labelsize=15)
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*QUERY*:
- PM for the reference power converter current (STATUS.I_REF)
- PM for two energy extraction voltages (U_DUMP_RES_1, U_DUMP_RES_2)
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|timestamp_ee |int |ns |Timestamp of an EE PM entry being analyzed|
|timestamp_pic |int |ns |Timestamp of a PIC trigger, 0 ns if can't be queried|
|i_a_df |DataFrame |A |I_A is the raw power converter current logged around the FPA with high sampling frequench|
|i_meas_df |DataFrame |A |I_MEAS is filtered I_A with lower sampling frequency and longer duration|
|i_ref_df | DataFrame | A | Reference power converter current, STATUS.I_REF|
|u_dump_res_1_sync_df | DataFrame | V | First energy extraction voltage U_DUMP_RES_1|
|u_dump_res_2_sync_df | DataFrame | V | Second energy extraction voltage U_DUMP_RES_2|
|is_automatic |bool |- |Flag denoting whether each analysis step is automatically approved (True) or requires an expert approval (False)|
*ANALYSIS*:
- Check if all signals are present:
- If the reference power converter current is missing, there is a warning and the analysis continues
- If any of the energy extraction voltages is not present, raise an error and abort analysis
- U_dump_res (t=0) = 0.075*I V (±10%).
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 110 s<-Tau <130 s
- Time stamp difference between FGC and EE an odd point: 290±30 ms (to be checked with Reiner)
After YETS 2017/8 the EE timestamp odd(RR or UJ) has been reduced and should now be 100+-30 ms after the FGC time stamp
- Time stamp difference between FGC and EE an even point: 560±40 ms (to be checked with Reiner)
*PLOT*:
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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
Second plot (triggering view):
- the power converter current on the left axix, 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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
*OUTPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|is_ee_correct |str |- |Result of an automatic analysis|
|report_analysis |DataFrame |- |A dataframe containing the analysis results and comments (expert comments if executed in the automatic mode); each row corresponds to a quenched magnet|
%% 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:markdown id: tags:
# 6. Current Leads
## 6.1. Plot of Current Leads
*QUERY*:
- PM for voltage of even leads, U_HTS, U_RES
- PM for voltage of odd leads, U_HTS, U_RES
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_type |str |- |Type of the analyzed circuit, e.g., 'RB'|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|u_leads_odd_df |DataFrame |V |Voltage of even leads, U_HTS, U_RES|
|u_leads_even_df | DataFrame |V |Voltage of even leads, U_HTS, U_RES|
*ANALYSIS*:
- quench detection for U_HTS for 2 consecutive datapoints above the threshold (3 mV)
- detection for U_RES for 2 consecutive datapoints above the threshold (100 mV)
*PLOT*:
For odd and even leads
- voltage of the normal conducting leads on the left axis, U_RES
- voltage of the HTS leads on the left axis, U_HTS
- t = 0 s corresponds to the respective (EVEN and ODD) LEADS timestamps.
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
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)
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:
# 7. Final Report
%% Cell type:code id: tags:
``` python
campaign = hwcb.get_campaign()
file_name_html = '{}-{}_report.html'.format(Time.to_datetime(t_start).strftime("%Y.%m.%d_%H%M%S.%f"), Time.to_datetime(t_end).strftime("%Y.%m.%d_%H%M%S.%f"))
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI1.d2.ipynb' --output /eos/project/l/lhcsm/hwc/RB/$circuit_name/$hwc_test/$campaign/$file_name_html
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI2.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%>
The aim of this test is to check the performance of the QPS and EE systems and the correct current sharing in the different FWT. The current to earth and the current error from the PC are checked during the sequence.
From May 2011 on, two options are available for the PLI2.B2 sequence. The quench simulation from a current lead is performed from I_INJECTION current plateau or a PIC_Discharge_Request is performed during the ramp close to I_INJECTION current.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/PLI2_current.png" width=75%>
The required analysis and signatures are listed below.
|Responsible|Type of analysis|Criterion|
|-----------|----------------|---------|
|PC|FWT check and 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|FWT check and PC voltage check|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)|
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> (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.
- In case an analyzed signal can't be queried, a particular analysis is skipped. In other words, all signals have to be available in order to perform an 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
In order to update the lhcsmapi, please execute the following command in the SWAN terminal <a href="https://github.com/swan-cern/help/blob/master/swan/open_terminal.md">[?]</a>:
`pip install --user --upgrade lhcsmapi`
## 0.1. Import Necessary Packages
%% Cell type:code id: tags:
``` python
import io
import re
import sys
import pandas as pd
# NXCALS libraries
from cern.nxcals.pyquery.builders import *
# lhc-sm-api
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
# GUI
from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
from lhcsmapi.gui.pc.FgcPmSearchBaseModule import FgcPmSearchBaseModule
from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator
from lhcsmapi.gui.hwc.HwcBrowser import HwcBrowser
# Query
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
# Analysis
from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
```
%% Cell type:markdown id: tags:
## 0.2. LHCSMAPI Version
%% Cell type:code id: tags:
``` python
import lhcsmapi
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__))
```
%% Output
Analysis executed with lhcsmapi version: 1.3.225
%% Cell type:markdown id: tags:
## 0.3. Notebook Version
%% Cell type:code id: tags:
``` python
with io.open("../__init__.py", "rt", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version))
```
%% Output
Analysis executed with lhc-sm-hwc notebooks version: 1.0.3
%% Cell type:markdown id: tags:
# 1. Select PLI2.b2 HWC Test
- 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
circuit_type = 'RB'
hwc_test = 'PLI2.b2'
hwc_test_history_df = pd.read_csv('/eos/project/l/lhcsm/hwc/RB/hwc_test_history.csv')
hwcb = HwcBrowser(hwc_test_history_df, circuit_type, hwc_test)
display(hwcb.widget)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
circuit_name = hwcb.get_circuit_name()
t_start = hwcb.get_start_time()
t_end = hwcb.get_end_time()
author = hwcb.get_author()
is_automatic = hwcb.is_automatic_mode()
rb_query = RbCircuitQuery(circuit_type, circuit_name)
with Timer():
# PC
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)
# EE Voltage
source_timestamp_ee_df = rb_query.find_source_timestamp_ee(timestamp_fgc)
timestamp_ee_odd = source_timestamp_ee_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(source_ee_odd, timestamp_ee_odd, timestamp_fgc, system='EE_ODD')[0]
timestamp_ee_even = source_timestamp_ee_df.loc[2, 'timestamp']
source_ee_even = source_timestamp_ee_df.loc[2, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(source_ee_even, timestamp_ee_even, timestamp_fgc, system='EE_EVEN')[0]
# PC
i_meas_nxcals_df = QueryBuilder().with_nxcals(spark) \
.with_duration(t_start=t_start, t_end=t_end) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name=circuit_name, system='PC', signal='I_MEAS') \
.signal_query() \
.synchronize_time() \
.convert_index_to_sec().dfs[0]
i_meas_df, i_a_df, i_ref_df = rb_query.query_pc_pm(timestamp_fgc, timestamp_ee_odd, signal_names=['I_MEAS', 'I_A', 'I_REF'])
# 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', signals=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signals=['U_RES'], spark=spark)
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', signals=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signals=['U_RES'], spark=spark)
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)
rb_analysis = RbCircuitAnalysis(circuit_type, pd.DataFrame(), is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% 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,
'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:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*QUERY*:
- NXCALS for the main power converter current, I_MEAS
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|i_meas_df | DataFrame | A | Main power converter current, I_MEAS|
*ANALYSIS*:
- Calculation of the duration of current plateaus
*PLOT*:
- The main power converter current (reference and actual) on the left axis, I_MEAS
- t = 0 s corresponds to the respective (actual and reference) FGC timestamps.
- Orange box(es) represent period(s) of time with constant current used for calculation of busbar resistance and DFB thresholds
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
ax = i_meas_nxcals_df.plot(figsize=(30, 10), grid=True)
ax.set_xlabel("time, [s]", fontsize=15)
ax.set_ylabel("I_MEAS, [A]", fontsize=15)
ax.tick_params(labelsize=15)
```
%% Cell type:markdown id: tags:
# 5. Energy Extraction System
## 5.1. Analysis of the Energy Extraction Voltage
*QUERY*:
- PM for the reference power converter current (STATUS.I_REF)
- PM for two energy extraction voltages (U_DUMP_RES_1, U_DUMP_RES_2)
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|timestamp_ee |int |ns |Timestamp of an EE PM entry being analyzed|
|timestamp_pic |int |ns |Timestamp of a PIC trigger, 0 ns if can't be queried|
|i_a_df |DataFrame |A |I_A is the raw power converter current logged around the FPA with high sampling frequench|
|i_meas_df |DataFrame |A |I_MEAS is filtered I_A with lower sampling frequency and longer duration|
|i_ref_df | DataFrame | A | Reference power converter current, STATUS.I_REF|
|u_dump_res_1_sync_df | DataFrame | V | First energy extraction voltage U_DUMP_RES_1|
|u_dump_res_2_sync_df | DataFrame | V | Second energy extraction voltage U_DUMP_RES_2|
|is_automatic |bool |- |Flag denoting whether each analysis step is automatically approved (True) or requires an expert approval (False)|
*ANALYSIS*:
- Check if all signals are present:
- If the reference power converter current is missing, there is a warning and the analysis continues
- If any of the energy extraction voltages is not present, raise an error and abort analysis
- U_dump_res (t=0) = 0.075*I V (±10%).
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 110 s<-Tau <130 s
- Time stamp difference between FGC and EE an odd point: 290±30 ms (to be checked with Reiner)
After YETS 2017/8 the EE timestamp odd(RR or UJ) has been reduced and should now be 100+-30 ms after the FGC time stamp
- Time stamp difference between FGC and EE an even point: 560±40 ms (to be checked with Reiner)
*PLOT*:
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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
Second plot (triggering view):
- the power converter current on the left axix, 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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
*OUTPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|is_ee_correct |str |- |Result of an automatic analysis|
|report_analysis |DataFrame |- |A dataframe containing the analysis results and comments (expert comments if executed in the automatic mode); each row corresponds to a quenched magnet|
%% 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.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:
# 6. Current Leads
## 6.1. Plot of Current Leads
*QUERY*:
- PM for voltage of even leads, U_HTS, U_RES
- PM for voltage of odd leads, U_HTS, U_RES
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_type |str |- |Type of the analyzed circuit, e.g., 'RB'|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|u_leads_odd_df |DataFrame |V |Voltage of even leads, U_HTS, U_RES|
|u_leads_even_df | DataFrame |V |Voltage of even leads, U_HTS, U_RES|
*ANALYSIS*:
- quench detection for U_HTS for 2 consecutive datapoints above the threshold (3 mV)
- detection for U_RES for 2 consecutive datapoints above the threshold (100 mV)
*PLOT*:
For odd and even leads
- voltage of the normal conducting leads on the left axis, U_RES
- voltage of the HTS leads on the left axis, U_HTS
- t = 0 s corresponds to the respective (EVEN and ODD) LEADS timestamps.
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
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)
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:
# 7. Final Report
%% Cell type:code id: tags:
``` python
campaign = hwcb.get_campaign()
file_name_html = '{}-{}_report.html'.format(Time.to_datetime(t_start).strftime("%Y.%m.%d_%H%M%S.%f"), Time.to_datetime(t_end).strftime("%Y.%m.%d_%H%M%S.%f"))
!{sys.executable} -m jupyter nbconvert --to html $'AN_RB_PLI2.b2.ipynb' --output /eos/project/l/lhcsm/hwc/RB/$circuit_name/$hwc_test/$campaign/$file_name_html
```
%% Cell type:code id: tags:
``` python
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of PLI3.d2 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%>
The circuit is powered up to I_INTERM_2. After a short plateau a powering failure is simulated by the power converter. After a minute the EE system is activated by a quench simulation in a current lead.
The aim of this test is to verify the correct functionality of the PC when a powering failure is generated.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/raw/master/figures/rb/PLI3_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)|
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. Depending on what signal is missing, an analysis can raise a warning and continue or an error and abort the analysis.
- In case an analyzed signal can't be queried, a particular analysis is skipped. In other words, all signals have to be available in order to perform an 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
In order to update the lhcsmapi, please execute the following command in the SWAN terminal <a href="https://github.com/swan-cern/help/blob/master/swan/open_terminal.md">[?]</a>:
`pip install --user --upgrade lhcsmapi`
## 0.1. Import Necessary Packages
%% Cell type:code id: tags:
``` python
import io
import re
import sys
import pandas as pd
# NXCALS libraries
from cern.nxcals.pyquery.builders import *
# lhc-sm-api
from lhcsmapi.Time import Time
from lhcsmapi.Timer import Timer
# GUI
from lhcsmapi.gui.hwc.HwcBrowser import HwcBrowser
# Query
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.analysis.RbCircuitQuery import RbCircuitQuery
# Analysis
from lhcsmapi.analysis.RbCircuitAnalysis import RbCircuitAnalysis
```
%% Cell type:markdown id: tags:
## 0.2. LHCSMAPI Version
%% Cell type:code id: tags:
``` python
import lhcsmapi
print('Analysis executed with lhcsmapi version: {}'.format(lhcsmapi.__version__))
```
%% Output
Analysis executed with lhcsmapi version: 1.3.225
%% Cell type:markdown id: tags:
## 0.3. Notebook Version
%% Cell type:code id: tags:
``` python
with io.open("../__init__.py", "rt", encoding="utf8") as f:
version = re.search(r'__version__ = "(.*?)"', f.read()).group(1)
print('Analysis executed with lhc-sm-hwc notebooks version: {}'.format(version))
```
%% Output
Analysis executed with lhc-sm-hwc notebooks version: 1.0.3
%% Cell type:markdown id: tags:
# 1. Select PLI1.d2 HWC Test
- 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
circuit_type = 'RB'
hwc_test = 'PLI3.d2'
hwc_test_history_df = pd.read_csv('/eos/project/l/lhcsm/hwc/RB/hwc_test_history.csv')
hwcb = HwcBrowser(hwc_test_history_df, circuit_type, hwc_test)
display(hwcb.widget)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
# 2.1. User Input
circuit_name = hwcb.get_circuit_name()
t_start = hwcb.get_start_time()
t_end = hwcb.get_end_time()
author = hwcb.get_author()
is_automatic = hwcb.is_automatic_mode()
rb_query = RbCircuitQuery(circuit_type, circuit_name)
with Timer():
# PC
source_timestamp_pc = rb_query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc = source_timestamp_pc.at[0, 'timestamp']
# EE Voltage
source_timestamp_ee_df = rb_query.find_source_timestamp_ee(timestamp_fgc)
timestamp_ee_odd = source_timestamp_ee_df.loc[0, 'timestamp']
source_ee_odd = source_timestamp_ee_df.loc[0, 'source']
u_dump_res_odd_df = rb_query.query_ee_u_dump_res_pm(source_ee_odd, timestamp_ee_odd, timestamp_ee_odd, system='EE_ODD')[0]
timestamp_ee_even = source_timestamp_ee_df.loc[2, 'timestamp']
source_ee_even = source_timestamp_ee_df.loc[2, 'source']
u_dump_res_even_df = rb_query.query_ee_u_dump_res_pm(source_ee_even, timestamp_ee_even, timestamp_ee_even, system='EE_EVEN')[0]
# PC
i_meas_nxcals_df = QueryBuilder().with_nxcals(spark) \
.with_duration(t_start=t_start, t_end=t_end) \
.with_circuit_type(circuit_type) \
.with_metadata(circuit_name=circuit_name, system='PC', signal='I_MEAS') \
.signal_query() \
.synchronize_time() \
.convert_index_to_sec().dfs[0]
i_meas_df, i_a_df, i_ref_df = rb_query.query_pc_pm(timestamp_fgc, timestamp_ee_odd, signal_names=['I_MEAS', 'I_A', 'I_REF'])
# 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', signals=['U_HTS'], spark=spark)
u_res_odd_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_odd_df, system='LEADS_ODD', signals=['U_RES'], spark=spark)
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', signals=['U_HTS'], spark=spark)
u_res_even_dfs = rb_query.query_leads(timestamp_fgc, source_timestamp_leads_even_df, system='LEADS_EVEN', signals=['U_RES'], spark=spark)
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)
rb_analysis = RbCircuitAnalysis(circuit_type, pd.DataFrame(), is_automatic=is_automatic)
```
%% Cell type:markdown id: tags:
# 3. Timestamps
%% Cell type:code id: tags:
``` python
timestamp_dct = {'FGC': timestamp_fgc, 'EE_EVEN': timestamp_ee_even, 'EE_ODD': timestamp_ee_odd,
'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:
# 4. Power Converter
## 4.1. Plot of the Power Converter Main Current
*QUERY*:
- NXCALS for the main power converter current, I_MEAS
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|i_meas_df | DataFrame | A | Main power converter current, I_MEAS|
*ANALYSIS*:
- Calculation of the duration of current plateaus
*PLOT*:
- The main power converter current (reference and actual) on the left axis, I_MEAS
- t = 0 s corresponds to the respective (actual and reference) FGC timestamps.
- Orange box(es) represent period(s) of time with constant current used for calculation of busbar resistance and DFB thresholds
*OUTPUT*:
- *No output is generated*
%% Cell type:code id: tags:
``` python
ax = i_meas_nxcals_df.plot(figsize=(30, 10), grid=True)
ax.set_xlabel("time, [s]", fontsize=15)
ax.set_ylabel("I_MEAS, [A]", fontsize=15)
ax.tick_params(labelsize=15)
```
%% Cell type:markdown id: tags:
# 4. Energy Extraction System
## 4.1. Analysis of the Energy Extraction Voltage
*QUERY*:
- PM for the reference power converter current (STATUS.I_REF)
- PM for two energy extraction voltages (U_DUMP_RES_1, U_DUMP_RES_2)
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_name |str |- |Name of the analyzed circuit, e.g., 'RB.A12'|
|timestamp_fgc |int |ns |Timestamp of an FGC PM entry being analyzed|
|timestamp_ee |int |ns |Timestamp of an EE PM entry being analyzed|
|timestamp_pic |int |ns |Timestamp of a PIC trigger, 0 ns if can't be queried|
|i_a_df |DataFrame |A |I_A is the raw power converter current logged around the FPA with high sampling frequench|
|i_meas_df |DataFrame |A |I_MEAS is filtered I_A with lower sampling frequency and longer duration|
|i_ref_df | DataFrame | A | Reference power converter current, STATUS.I_REF|
|u_dump_res_1_sync_df | DataFrame | V | First energy extraction voltage U_DUMP_RES_1|
|u_dump_res_2_sync_df | DataFrame | V | Second energy extraction voltage U_DUMP_RES_2|
|is_automatic |bool |- |Flag denoting whether each analysis step is automatically approved (True) or requires an expert approval (False)|
*ANALYSIS*:
- Check if all signals are present:
- If the reference power converter current is missing, there is a warning and the analysis continues
- If any of the energy extraction voltages is not present, raise an error and abort analysis
- U_dump_res (t=0) = 0.075*I V (±10%).
- Characteristic time of pseudo-exponential decay of I_MEAS from t=1 to 120 s: 110 s<-Tau <130 s
- Time stamp difference between FGC and EE an odd point: 290±30 ms (to be checked with Reiner)
After YETS 2017/8 the EE timestamp odd(RR or UJ) has been reduced and should now be 100+-30 ms after the FGC time stamp
- Time stamp difference between FGC and EE an even point: 560±40 ms (to be checked with Reiner)
*PLOT*:
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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
Second plot (triggering view):
- the power converter current on the left axix, 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_1, U_DUMP_RES_2
- t = 0 s corresponds to the PM timestamp of the FGC
*OUTPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|is_ee_correct |str |- |Result of an automatic analysis|
|report_analysis |DataFrame |- |A dataframe containing the analysis results and comments (expert comments if executed in the automatic mode); each row corresponds to a quenched magnet|
%% 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:markdown id: tags:
# 5. Current Leads
## 5.1. Plot of Current Leads
*QUERY*:
- PM for voltage of even leads, U_HTS, U_RES
- PM for voltage of odd leads, U_HTS, U_RES
*INPUT*:
|Variable Name |Variable Type |Variable Unit |Comment
|---------------|---------------|---------------|------|
|circuit_type |str |- |Type of the analyzed circuit, e.g., 'RB'|