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

Added voltage-dependent QH discharge criteria

parent 7bbfd0ae
Pipeline #2262228 passed with stage
in 15 seconds
%% Cell type:markdown id: tags:
<h1><center>Analysis of an FPA in an 60A Circuit</center></h1>
The LHC comprises a total of 376 pairs of horizontal and vertical orbit correctors which are installed at each focusing and defocusing main quadrupole magnet in the arcs. Quenches on 60 A magnets are detected by the power converter through magnet impedance growing. In addition, the power converter also provides current lead protection. The Figure below shows the circuit diagram of the 60 A arc orbit correctors.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/60A/60A.png" width=70%>
source: Test Procedure and Acceptance Criteria for the 60 A Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874724/">https://edms.cern.ch/document/874724/</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.
- 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:code id: tags:
``` python
# External libraries
print('Loading (1/15)'); import pandas as pd
print('Loading (2/15)'); import numpy as np
print('Loading (3/15)'); import sys
print('Loading (4/15)'); from IPython.display import display, Javascript, clear_output, HTML
# Internal libraries
print('Loading (5/15)'); import lhcsmapi
print('Loading (6/15)'); from lhcsmapi.Time import Time
print('Loading (7/15)'); from lhcsmapi.Timer import Timer
print('Loading (8/15)'); from lhcsmapi.analysis.R60_80_120ACircuitQuery import R60_80_120ACircuitQuery
print('Loading (9/15)'); from lhcsmapi.analysis.R60_80_120ACircuitAnalysis import R60_80_120ACircuitAnalysis
print('Loading (10/15)'); from lhcsmapi.analysis.expert_input import get_expert_decision
print('Loading (11/15)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (12/15)'); from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
print('Loading (13/15)'); from lhcsmapi.gui.pc.R60AFgcPmSearchBaseModule import R60AFgcPmSearchBaseModule
print('Loading (14/15)'); from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator
print('Loading (15/15)'); from lhcsmapi.metadata.SignalMetadata import SignalMetadata
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
```
%% Cell type:markdown id: tags:
# 1. Select FGC Post Mortem Entry
%% Cell type:markdown id: tags:
In order to perform the analysis of a FPA in an IPQ circuit please:
1. Select circuit name prefix (e.g., RQ5)
2. Choose start and end time
3. Choose analysis mode (Automatic by default)
Once these inputs are provided, click 'Find FGC PM entries' button. This will trigger a search of the PM database in order to provide a list of timestamps of FGC events associated with the selected circuit name for the provided period of time. Select one timestamp from the 'FGC PM Entries' list to be processed by the following cells.
**Note that 24 hours is the maximum duration of a single PM query for an event. To avoid delays in querying events, please restrict your query duration as much as possible.**
%% Cell type:code id: tags:
``` python
circuit_type = '60A'
fgc_pm_search = FgcPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2018-03-12 00:00:00+01:00',
end_date_time='2018-03-13 00:00:00+01:00'), R60AFgcPmSearchBaseModule(), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
with Timer():
timestamp_fgc = fgc_pm_search.get_fgc_timestamp()
circuit_name = fgc_pm_search.get_fgc_circuit()
author = fgc_pm_search.get_author()
is_automatic = fgc_pm_search.is_automatic_mode()
query = R60_80_120ACircuitQuery(circuit_type, circuit_name, max_executions=1)
# PC
i_meas_df, i_a_df, i_ref_df = query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF'])
i_meas_df, i_a_df, i_ref_df, i_earth_df = query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF', 'I_EARTH'])
results_table = query.create_report_analysis_template(timestamp_fgc, init_file_path='../__init__.py', author=author)
analysis = R60_80_120ACircuitAnalysis(circuit_type, results_table)
timestamp_dct = {'FGC': timestamp_fgc}
```
%% Cell type:markdown id: tags:
# 3. Timestamps
## 3.1. FPA
%% Cell type:code id: tags:
``` python
analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
# 4. PC
## 4.1. Main Current
*ANALYSIS*:
- calculation of the ramp rate
- calculation of the duration of a plateau prior to a quench
- calculation of DCCT MIIts
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
- one plot for each power converter
%% Cell type:code id: tags:
``` python
import matplotlib as mpl
mpl.rcParams['savefig.dpi'] = 80
mpl.rcParams['figure.dpi'] = 80
%matplotlib notebook
analysis.plot_i_meas_pc(circuit_name, timestamp_fgc, [i_meas_df, i_a_df, i_ref_df])
```
%% Cell type:code id: tags:
``` python
t_quench = analysis.find_time_of_quench(i_ref_df, i_a_df)
t_quench = 0 if t_quench is None else t_quench
analysis.plot_i_meas_pc(circuit_name, timestamp_fgc, [i_meas_df, i_a_df, i_ref_df], xlim=(t_quench-0.1, t_quench+0.1))
```
%% Cell type:code id: tags:
``` python
analysis.calculate_current_miits(i_meas_df, t_quench, col_name='MIITS_circ')
analysis.calculate_quench_current(i_meas_df, t_quench, col_name='I_Q_circ')
analysis.calculate_current_slope(i_meas_df, col_name=['Ramp rate', 'Plateau duration'])
```
%% Cell type:markdown id: tags:
## 4.2. Earth Current
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
%% Cell type:code id: tags:
``` python
analysis.plot_i_earth_pc(circuit_name, timestamp_fgc, i_earth_df)
analysis.calculate_max_i_earth_pc(i_earth_df, col_name='I_Earth_max')
```
%% Cell type:markdown id: tags:
# 5. Quench Protection System
%% Cell type:code id: tags:
``` python
analysis.results_table['FPA Reason'] = get_expert_decision('Reason for FPA: ', ['QPS trip', 'Converter trip', 'EE spurious opening', 'Spurious heater firing', 'Busbar quench', 'Magnet quench', 'HTS current lead quench' ,'RES current lead overvoltage', 'Unknown'])
```
%% Cell type:code id: tags:
``` python
analysis.results_table['Type of Quench'] = get_expert_decision('Type of Quench: ', ['Training', 'Heater-provoked', 'Beam-induced', 'GHe propagation', 'QPS crate reset', 'Single Event Upset' ,'Short-to-ground', 'EM disturbance' ,'Unknown'])
```
%% Cell type:markdown id: tags:
# 6. Analysis Comment
%% Cell type:code id: tags:
``` python
analysis.results_table['Comment'] = input('Comment: ')
```
%% Cell type:markdown id: tags:
# 7. Final Report
%% Cell type:code id: tags:
``` python
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
analysis_start_time = Time.get_analysis_start_time()
date_time_fgc = Time.to_datetime(timestamp_fgc).strftime("%Y-%m-%d-%Hh%M")
prefix_circuit_name = circuit_name.split('.')[0]
!mkdir -p /eos/project/m/mp3/60A/$prefix_circuit_name/$circuit_name/FPA
file_name = "{}_FPA-{}-{}".format(circuit_name, date_time_fgc, analysis_start_time)
full_path = '/eos/project/m/mp3/60A/{}/{}/FPA/{}.csv'.format(prefix_circuit_name, circuit_name, file_name)
mp3_results_table = analysis.create_mp3_results_table()
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()
full_path = '/eos/project/m/mp3/60A/{}/{}/FPA/{}.html'.format(prefix_circuit_name, circuit_name, file_name)
print('Compact notebook report saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
display(Javascript('IPython.notebook.save_notebook();'))
Time.sleep(5)
file_name_html = file_name + '.html'
!{sys.executable} -m jupyter nbconvert --to html $'AN_60A_FPA.ipynb' --output /eos/project/m/mp3/60A/$prefix_circuit_name/$circuit_name/FPA/$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
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of an FPA in an 80-120A Circuit</center></h1>
Figure below shows the electrical diagram of the 80-120 A corrector circuits including the connection to the PC. It’s important to note the positioning of the crowbar with respect to the DCCTs. During a power abort the current will transfer from the PC into the crowbar and the measured current (I_MEAS) goes immediately to almost 0 A, and is therefore not representative for the current in the cold part of the circuit including the magnet. Note that there is no QPS present in these circuits but that the PC will shut-down in case of overvoltage.
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/80-120A/80-120A.png" width=70%>
source: Test Procedure and Acceptance Criteria for the 80 A and 120 A Dipole Corrector Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874722/">https://edms.cern.ch/document/874722/</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.
- 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:code id: tags:
``` python
# External libraries
print('Loading (1/15)'); import pandas as pd
print('Loading (2/15)'); import numpy as np
print('Loading (3/15)'); import sys
print('Loading (4/15)'); from IPython.display import display, Javascript, clear_output, HTML
# Internal libraries
print('Loading (5/15)'); import lhcsmapi
print('Loading (6/15)'); from lhcsmapi.Time import Time
print('Loading (7/15)'); from lhcsmapi.Timer import Timer
print('Loading (8/15)'); from lhcsmapi.analysis.R60_80_120ACircuitQuery import R60_80_120ACircuitQuery
print('Loading (9/15)'); from lhcsmapi.analysis.R60_80_120ACircuitAnalysis import R60_80_120ACircuitAnalysis
print('Loading (10/15)'); from lhcsmapi.analysis.expert_input import get_expert_decision
print('Loading (11/15)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (12/15)'); from lhcsmapi.gui.qh.DateTimeBaseModule import DateTimeBaseModule
print('Loading (13/15)'); from lhcsmapi.gui.pc.R80_120AFgcPmSearchBaseModule import R80_120AFgcPmSearchBaseModule
print('Loading (14/15)'); from lhcsmapi.gui.pc.FgcPmSearchModuleMediator import FgcPmSearchModuleMediator
print('Loading (15/15)'); from lhcsmapi.metadata.SignalMetadata import SignalMetadata
clear_output()
lhcsmapi.get_lhcsmapi_version()
lhcsmapi.get_lhcsmhwc_version('../__init__.py')
```
%% Cell type:markdown id: tags:
# 1. Select FGC Post Mortem Entry
%% Cell type:markdown id: tags:
In order to perform the analysis of a FPA in an IPQ circuit please:
1. Select circuit name prefix (e.g., RQ5)
2. Choose start and end time
3. Choose analysis mode (Automatic by default)
Once these inputs are provided, click 'Find FGC PM entries' button. This will trigger a search of the PM database in order to provide a list of timestamps of FGC events associated with the selected circuit name for the provided period of time. Select one timestamp from the 'FGC PM Entries' list to be processed by the following cells.
**Note that 24 hours is the maximum duration of a single PM query for an event. To avoid delays in querying events, please restrict your query duration as much as possible.**
%% Cell type:code id: tags:
``` python
circuit_type = '80-120A'
fgc_pm_search = FgcPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2021-01-06 00:00:00+01:00',
end_date_time='2021-01-21 00:00:00+01:00'), R80_120AFgcPmSearchBaseModule(), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
with Timer():
timestamp_fgc = fgc_pm_search.get_fgc_timestamp()
circuit_name = fgc_pm_search.get_fgc_circuit()
author = fgc_pm_search.get_author()
is_automatic = fgc_pm_search.is_automatic_mode()
query = R60_80_120ACircuitQuery(circuit_type, circuit_name, max_executions=1)
# PC
i_meas_df, i_a_df, i_ref_df = query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF'])
i_meas_df, i_a_df, i_ref_df, i_earth_df = query.query_pc_pm(timestamp_fgc, timestamp_fgc, signal_names=['I_MEAS', 'I_A', 'I_REF', 'I_EARTH'])
results_table = query.create_report_analysis_template(timestamp_fgc, init_file_path='../__init__.py', author=author)
analysis = R60_80_120ACircuitAnalysis(circuit_type, results_table)
timestamp_dct = {'FGC': timestamp_fgc}
```
%% Cell type:markdown id: tags:
# 3. Timestamps
## 3.1. FPA
%% Cell type:code id: tags:
``` python
analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
# 4. PC
## 4.1. Main Current
*ANALYSIS*:
- calculation of the ramp rate
- calculation of the duration of a plateau prior to a quench
- calculation of DCCT MIIts
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
- one plot for each power converter
%% Cell type:code id: tags:
``` python
import matplotlib as mpl
mpl.rcParams['savefig.dpi'] = 80
mpl.rcParams['figure.dpi'] = 80
%matplotlib notebook
analysis.plot_i_meas_pc(circuit_name, timestamp_fgc, [i_meas_df, i_a_df, i_ref_df])
```
%% Cell type:code id: tags:
``` python
t_quench = analysis.find_time_of_quench(i_ref_df, i_a_df)
t_quench = 0 if t_quench is None else t_quench
analysis.plot_i_meas_pc(circuit_name, timestamp_fgc, [i_meas_df, i_a_df, i_ref_df], xlim=(t_quench-0.1, t_quench+0.1))
```
%% Cell type:code id: tags:
``` python
analysis.calculate_current_miits(i_meas_df, t_quench, col_name='MIITS_circ')
analysis.calculate_quench_current(i_meas_df, t_quench, col_name='I_Q_circ')
analysis.calculate_current_slope(i_meas_df, col_name=['Ramp rate', 'Plateau duration'])
```
%% Cell type:markdown id: tags:
## 4.2. Earth Current
*GRAPHS*:
- t = 0 s corresponds to the FGC timestamp
%% Cell type:code id: tags:
``` python
analysis.plot_i_earth_pc(circuit_name, timestamp_fgc, i_earth_df)
analysis.calculate_max_i_earth_pc(i_earth_df, col_name='I_Earth_max')
```
%% Cell type:markdown id: tags:
# 5. Quench Protection System
%% Cell type:code id: tags:
``` python
analysis.results_table['FPA Reason'] = get_expert_decision('Reason for FPA: ', ['QPS trip', 'Converter trip', 'EE spurious opening', 'Spurious heater firing', 'Busbar quench', 'Magnet quench', 'HTS current lead quench' ,'RES current lead overvoltage', 'Unknown'])
```
%% Cell type:code id: tags:
``` python
analysis.results_table['Type of Quench'] = get_expert_decision('Type of Quench: ', ['Training', 'Heater-provoked', 'Beam-induced', 'GHe propagation', 'QPS crate reset', 'Single Event Upset' ,'Short-to-ground', 'EM disturbance' ,'Unknown'])
```
%% Cell type:markdown id: tags:
# 6. Analysis Comment
%% Cell type:code id: tags:
``` python
analysis.results_table['Comment'] = input('Comment: ')
```
%% Cell type:markdown id: tags:
# 7. Final Report
%% Cell type:code id: tags:
``` python
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
analysis_start_time = Time.get_analysis_start_time()
date_time_fgc = Time.to_datetime(timestamp_fgc).strftime("%Y-%m-%d-%Hh%M")
prefix_circuit_name = circuit_name.split('.')[0]
!mkdir -p /eos/project/m/mp3/80-120A/$prefix_circuit_name/$circuit_name/FPA
file_name = "{}_FPA-{}-{}".format(circuit_name, date_time_fgc, analysis_start_time)
full_path = '/eos/project/m/mp3/80-120A/{}/{}/FPA/{}.csv'.format(prefix_circuit_name, circuit_name, file_name)
mp3_results_table = analysis.create_mp3_results_table()
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()
full_path = '/eos/project/m/mp3/80-120A/{}/{}/FPA/{}.html'.format(prefix_circuit_name, circuit_name, file_name)
print('Compact notebook report saved to (Windows): ' + '\\\\cernbox-smb' + full_path.replace('/', '\\'))
display(Javascript('IPython.notebook.save_notebook();'))
Time.sleep(5)
file_name_html = file_name + '.html'
!{sys.executable} -m jupyter nbconvert --to html $'AN_80-120A_FPA.ipynb' --output /eos/project/m/mp3/80-120A/$prefix_circuit_name/$circuit_name/FPA/$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
```
......
This diff is collapsed.
__version__ = "1.5.12"
__version__ = "1.5.13"
figures/monitoring-vs-hwc.png

388 KB | W: | H:

figures/monitoring-vs-hwc.png

232 KB | W: | H:

figures/monitoring-vs-hwc.png
figures/monitoring-vs-hwc.png
figures/monitoring-vs-hwc.png
figures/monitoring-vs-hwc.png
  • 2-up
  • Swipe
  • Onion skin
%% Cell type:markdown id: tags:
<h1><center>Analysis of a PIC2 Test in an IPD Circuit</center></h1>
Superconducting beam separation dipoles of four different types are required in the Experimental Insertions (IR 1, 2, 5 and 8) and the RF insertion (IR 4). Single aperture dipoles D1 (MBX) and twin aperture dipoles D2 (MBRC) are utilized in the Experimental Insertions. They bring the two beams of the LHC into collision at four separate points then separate the beams again beyond the collision point. In the RF Insertions two types of twin aperture dipoles, each type with two different aperture spacings are used: D3 (MBRS) and D4 (MBRB). The D3 and D4 magnets increase the separation of the beams in IR 4 from the nominal spacing 194 mm to 420 mm. D2 and D4 are the twin apertures magnets with common iron core for both apertures. D3 is a twin apertures magnet with independent iron cores for each aperture.
The MBRC dipole consists of two individually powered apertures assembled in a common yoke structure.
- MBX – D1
Single aperture of the magnet powered with one power supply.
- MBRC – D2
- MBRB – D4
Apertures B1 and B2 of the magnet are powered in series with one power supply.
- MBRS - D3
Apertures B1 and B2 of the magnet are powered in series with one power supply but series connection done in the DFBA.
|Magnets in the Circuit|Temperature|Position|General information|
|----------------------|-----------|--------|-------------------|
|MBX (D1)|1.9 K| RD1.R2, RD1.R8|I Nominal: 5800A, I_Ultimate: 6100A|
| | | |L tot: 26 mH, L per aperture: 26 mH|
| | | |max(di/dt): 17.453 A/s|
|MBRC (D2)|4.5 K| RD2.L1, RD2.R1, RD2.L5, RD2.R5|I Nominal: 4400A, I_Ultimate: 4670A|
| | | RD2.L2, RD2.R2, RD2.L8, RD2.R8|I Nominal: 6000A, I_Ultimate: 6500A|
| | | |L tot: 52 mH, L per aperture: 26 mH|
| | | |max(di/dt): 18.147 A/s|
|MBRS (D3)|4.5 K| RD3.L4, RD3.R4|I Nominal: 5520A, I_Ultimate: 6000A|
| | | |L tot: 26 mH, L per aperture: 26 mH|
| | | |max(di/dt): 18.147 A/s|
|MBRB (D4)|4.5 K| RD4.L4, RD4.R4|I Nominal: 5520A, I_Ultimate: 6000A|
| | | |L tot: 26 mH, L per aperture: 26 mH|
| | | |max(di/dt): 18.147 A/s|
### PIC2
The aim of this test is to check the current functioning of the powering interlock controller with standby current in the circuits.
The plot with the test below has been added for the sake of completeness. The detailed procedures for implementation of the interlock tests are subject to a detailed document, which will remain the reference for these tests (LHC-D-HCP-0002).
<img src="https://gitlab.cern.ch/LHCData/lhc-sm-hwc/-/raw/master/figures/ipd/PIC2_current.png" width=75%>
<center>IPD currents during PIC2. Note: the actual parameters are listed in Appendix 1.</center>
source: Test Procedure and Acceptance Criteria for the Separation Dipoles Circuits, MP3 Procedure, <a href="https://edms.cern.ch/document/874885">https://edms.cern.ch/document/874885</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. 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)'); import pandas as pd
print('Loading (3/12)'); from IPython.display import display, Javascript, clear_output
# 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.IpdCircuitQuery import IpdCircuitQuery
print('Loading (8/12)'); from lhcsmapi.analysis.IpdCircuitAnalysis import IpdCircuitAnalysis
print('Loading (9/12)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (10/12)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
print('Loading (11/12)'); from lhcsmapi.pyedsl.PlotBuilder import create_hwc_plot_title_with_circuit_name
print('Loading (12/12)'); from lhcsmapi.analysis.expert_input import get_expert_decision
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 = 'PIC2'
circuit_name = 'RD1.L2'
campaign = 'HWC_2018_1'
t_start = '2018-03-13 19:13:07.613'
t_end = '2018-03-13 19:30:26.299'
```
2. To analyze a historical test with a browser GUI, copy and execute the following code in the cell below
```
circuit_type = 'IPD'
hwc_test = 'PIC2'
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 = 'IPD'
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
query = IpdCircuitQuery(circuit_type, circuit_name, max_executions=9)
with Timer():
# PC
source_timestamp_df = query.find_source_timestamp_pc(t_start, t_end)
timestamp_fgc = source_timestamp_df.at[0, 'timestamp']
i_meas_df = query.query_signal_nxcals(t_start, t_end, t0=timestamp_fgc, system='PC', signal_names='I_MEAS', spark=spark)[0]
# PIC
timestamp_pic = query.find_timestamp_pic(timestamp_fgc, spark=spark)
# QDS
source_timestamp_qds_df = query.find_source_timestamp_qds(timestamp_fgc, duration=[(2, 's'), (2, 's')])
timestamp_qds = float('nan') if source_timestamp_qds_df.empty else source_timestamp_qds_df.loc[0, 'timestamp']
signal_names = 'U_RES_B1' if query.circuit_type == 'IPD2_B1B2' else 'U_RES'
u_res_df = query.query_signal_nxcals(t_start, t_end, t0=timestamp_fgc, system='QDS', signal_names=signal_names, spark=spark)[0]
# QH
u_hds_dfss = query.query_qh_pm(source_timestamp_qds_df.drop_duplicates('source') if not source_timestamp_qds_df.empty else pd.DataFrame(), signal_names=['U_HDS'])
u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else []
# # Reference
u_hds_ref_dfss = query.query_qh_pm(source_timestamp_qds_df.drop_duplicates('source') if not source_timestamp_qds_df.empty else pd.DataFrame(), signal_names=['U_HDS'], is_ref=True)
u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else []
# LEADS
u_hts_dfs = query.query_leads(timestamp_fgc, source_timestamp_qds_df.drop_duplicates('source') if not source_timestamp_qds_df.empty else pd.DataFrame(), system='LEADS', signal_names=['U_HTS'], spark=spark, duration=[(t_end-t_start, 'ns')])
u_res_dfs = query.query_leads(timestamp_fgc, source_timestamp_qds_df.drop_duplicates('source') if not source_timestamp_qds_df.empty else pd.DataFrame(), system='LEADS', signal_names=['U_RES'], spark=spark, duration=[(t_end-t_start, 'ns')])
analysis = IpdCircuitAnalysis(query.circuit_type, pd.DataFrame())
timestamp_dct = {'FGC': timestamp_fgc, 'PIC': timestamp_pic,
'QDS_A':source_timestamp_qds_df.loc[0, 'timestamp'] if len(source_timestamp_qds_df) > 0 else float('nan'),
'QDS_B':source_timestamp_qds_df.loc[1, 'timestamp'] if len(source_timestamp_qds_df) > 1 else float('nan')}
```
%% Cell type:markdown id: tags:
# 3. Timestamps
The analysis for MP3 consists of checking the existence of PM events and of consistency of the PM timestamps (PC, QPS). The criterion of passing this test described in detail in 600APIC2.
In short the following criteria should be checked:
- The PC timestamp (51_self) is QPS timestamp +-20 ms.
- The difference between QPS board A and B timestamp = 1ms.
If one or more of these conditions are not fulfilled, then an in-depth analysis has to be performed by the QPS team.
%% Cell type:code id: tags:
``` python
analysis.create_timestamp_table(timestamp_dct)
```
%% Cell type:markdown id: tags:
# 4. PC
## 4.1. 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
analysis.plot_i_meas_pc(circuit_name, timestamp_fgc, [i_meas_df])
```
%% Cell type:markdown id: tags:
# 5. Quench Protection System
The signal names used for quench detection are shown in the figures above (picture from A. Erokhin).
**Quench Detector Type**
DQQDC - current leads quench detector
DQAMG - controller attached to global protection
**Current Leads:**
- Typical resistance for U_RES: 7 uOhm
- Threshold for U_HTS: 3 mV, 1s
- Polarity convention: Arrows show how signals are measured. If I > 0, LD1: U_RES > 0, LD2: U_RES < 0
- PM file
- Buffer range 0 to 250, event at point 50
- Time range: -10 to 40 s
- Frequency: 5 Hz (dt = 200 ms)
**Magnet:**
- See polarity convention in the circuit schematics
- U_RES_B1 = U_1_B1 + U_2_B1
- Threshold on U_RES_B1: 100 mV, 10 ms
- U_RES_B2, U_1_B2, U_2_B2 and U_INDUCT_B2 are given for diagnostics only
- Signals are measured with -2.5 V offset and with the gain factor = 0.0012
- *Attention: B1 signals and B2 singals can be shifted by 4 ms from each other*
- If pure inductive signal and di/dt < 0:
- U_1_B1 = L di/dt < 0
- U_2_B1 = -L di/dt < 0
- PM file
- Buffer range 501 to 1500, event at point 1000
- Time range: -2 to 2 s
- Frequency: 250 Hz (dt = 4 ms)
%% Cell type:markdown id: tags:
## 5.1. Resistive Voltage
*GRAPHS*:
- t = 0 s corresponds to the start of the test
%% Cell type:code id: tags:
``` python
analysis.plot_u_res(circuit_name, timestamp_qds, u_res_df, i_meas_df)
```
%% Cell type:markdown id: tags:
## 5.2. Current Leads
*CRITERIA*:
- quench detection for U_HTS for 2 consecutive datapoints above the threshold of 3 mV
- detection for U_RES for 2 consecutive datapoints above the threshold of 100 mV
*GRAPHS*:
- t = 0 s corresponds to the test start time
%% Cell type:code id: tags:
``` python
analysis.analyze_leads_voltage(u_hts_dfs, circuit_name, timestamp_qds, signal='U_HTS', value_min=-0.003, value_max=0.003)
```
%% Cell type:code id: tags:
``` python
analysis.analyze_leads_voltage(u_res_dfs, circuit_name, timestamp_qds, signal='U_RES', value_min=-0.1, value_max=0.1)
```
%% Cell type:markdown id: tags:
## 5.3. Quench Heaters
*CRITERIA*:
- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage is +/- 5 ms from the reference ones
- the initial voltage should be between 810 V and 1000 V
- the final voltage should be between 0 V and 10 V
*GRAPHS*:
- t = 0 s corresponds to the start of the pseudo-exponential decay
Voltage view (linear and log)
- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS
%% Cell type:code id: tags:
``` python
if u_hds_dfs:
analysis.analyze_qh(circuit_name, timestamp_qds, u_hds_dfs, u_hds_ref_dfs)
else:
print('No Quench Heater discharges!')
```
%% Cell type:code id: tags:
``` python
analysis.find_voltage_threshold_detection(u_hts_dfs, threshold=0.003)
```
%% Cell type:markdown id: tags:
# 6. Signature Decision
%% Cell type:code id: tags:
``` python
signature = get_expert_decision('Expert Signature Decision: ', ['PASSED', 'FAILED'])
```
%% Cell type:markdown id: tags:
# 7. Final Report
%% Cell type:code id: tags:
``` python
analysis_start_time = Time.get_analysis_start_time()
file_name_html = '{}_{}-{}-{}_{}.html'.format(circuit_name, hwc_test, Time.to_datetime(t_start).strftime("%Y-%m-%d-%Hh%M"), analysis_start_time, signature)
hwc_test = hwc_test.split(' ')[0]
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/IPD/{}/{}/{}'.format(circuit_name, hwc_test, file_name_html)
!mkdir -p /eos/project/m/mp3/IPD/$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_IPD_PIC2.ipynb' --output /eos/project/m/mp3/IPD/$circuit_name/$hwc_test/$file_name_html --TemplateExporter.exclude_input=True --TagRemovePreprocessor.remove_all_outputs_tags='["skip_output"]'
```
%% Cell type:code id: tags:
``` python
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of a QH discharge in an IPD Circuit</center></h1>
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/13)'); import sys
print('Loading (2/13)'); from multiprocessing import Pool
print('Loading (3/13)'); from IPython.display import display, HTML, Javascript, clear_output
# Internal libraries
print('Loading (4/13)'); import lhcsmapi
print('Loading (5/13)'); from lhcsmapi.Time import Time
print('Loading (6/13)'); from lhcsmapi.Timer import Timer
print('Loading (7/13)'); from lhcsmapi.analysis.IpdCircuitQuery import IpdCircuitQuery
print('Loading (8/13)'); from lhcsmapi.analysis.IpdCircuitAnalysis import IpdCircuitAnalysis
print('Loading (9/13)'); from lhcsmapi.analysis.expert_input import check_show_next
print('Loading (10/13)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (11/13)'); from lhcsmapi.gui.DateTimeBaseModule import DateTimeBaseModule
print('Loading (12/13)'); from lhcsmapi.gui.qh.QhPmSearchModuleMediator import QhPmSearchModuleMediator
print('Loading (13/13)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
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. Find QH Post Mortem Entries
%% Cell type:code id: tags:
``` python
circuit_type = 'IPD'
qh_pm_search = QhPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2021-01-12 00:00:00+01:00', end_date_time='2021-01-31 00:00:00+01:00'), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
ipd_query = IpdCircuitQuery(circuit_type, qh_pm_search.get_circuit_name())
ipd_analysis = IpdCircuitAnalysis(ipd_query.circuit_type)
with Timer():
u_hds_dfss = ipd_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'])
u_hds_ref_dfss = ipd_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'], is_ref=True)
```
%% Cell type:markdown id: tags:
# 3. Quench Heaters
*CRITERIA*:
- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage is +/- 5 ms from the reference ones
- the initial voltage should be between 810 V and 1000 V
- the final voltage should be between 0 V and 10 V
*GRAPHS*:
- t = 0 s corresponds to the start of the pseudo-exponential decay
Voltage view (linear and log)
- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS
%% Cell type:code id: tags:
``` python
index = 0
for u_hds_dfs, u_hds_ref_dfs in zip(u_hds_dfss, u_hds_ref_dfss):
print(index, qh_pm_search.source_timestamp_df.loc[index, 'timestamp'])
ipd_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
ipd_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs, nominal_voltage=qh_pm_search.get_discharge_level())
index += 1
```
%% Cell type:markdown id: tags:
# 4. Final Report
%% Cell type:code id: tags:
``` python
if not qh_pm_search.source_timestamp_df.empty:
analysis_start_time = Time.get_analysis_start_time()
circuit_name = qh_pm_search.get_circuit_name()
date_time_qh = Time.to_datetime(qh_pm_search.source_timestamp_df.loc[0, 'timestamp']).strftime("%Y-%m-%d-%Hh%M")
file_name_html = "{}_QHDA-{}-{}.html".format(circuit_name, date_time_qh, analysis_start_time)
apply_report_template()
!mkdir -p /eos/project/m/mp3/IPD/$circuit_name/QHDA
full_path = '/eos/project/m/mp3/IPD/{}/QHDA/{}'.format(circuit_name, 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 $'HWC_IPD_QHDA.ipynb' --output /eos/project/m/mp3/IPD/$circuit_name/QHDA/$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
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of a QH discharge in an IPQ Circuit</center></h1>
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/13)'); import sys
print('Loading (2/13)'); from multiprocessing import Pool
print('Loading (3/13)'); from IPython.display import display, HTML, Javascript, clear_output
# Internal libraries
print('Loading (4/13)'); import lhcsmapi
print('Loading (5/13)'); from lhcsmapi.Time import Time
print('Loading (6/13)'); from lhcsmapi.Timer import Timer
print('Loading (7/13)'); from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery
print('Loading (8/13)'); from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis
print('Loading (9/13)'); from lhcsmapi.analysis.expert_input import check_show_next
print('Loading (10/13)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (11/13)'); from lhcsmapi.gui.DateTimeBaseModule import DateTimeBaseModule
print('Loading (12/13)'); from lhcsmapi.gui.qh.QhPmSearchModuleMediator import QhPmSearchModuleMediator
print('Loading (13/13)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
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. Find QH Post Mortem Entries
%% Cell type:code id: tags:
``` python
circuit_type = 'IPQ'
qh_pm_search = QhPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2021-01-12 00:00:00+01:00', end_date_time='2021-01-31 00:00:00+01:00'), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
ipq_query = IpqCircuitQuery(circuit_type, qh_pm_search.get_circuit_name())
ipq_analysis = IpqCircuitAnalysis(ipq_query.circuit_type, None, circuit_name=qh_pm_search.get_circuit_name())
with Timer():
u_hds_dfss = ipq_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'])
u_hds_ref_dfss = ipq_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'], is_ref=True)
```
%% Cell type:markdown id: tags:
# 3. Quench Heaters
*CRITERIA*:
- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage is +/- 5 ms from the reference ones
- the initial voltage should be between 810 V and 1000 V
- the final voltage should be between 0 V and 10 V
*GRAPHS*:
- t = 0 s corresponds to the start of the pseudo-exponential decay
Voltage view (linear and log)
- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS
%% Cell type:code id: tags:
``` python
index = 0
for u_hds_dfs, u_hds_ref_dfs in zip(u_hds_dfss, u_hds_ref_dfss):
print(index, qh_pm_search.source_timestamp_df.loc[index, 'timestamp'])
ipq_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
ipq_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs, nominal_voltage=qh_pm_search.get_discharge_level())
index += 1
```
%% Cell type:markdown id: tags:
# 4. Final Report
%% Cell type:code id: tags:
``` python
if not qh_pm_search.source_timestamp_df.empty:
analysis_start_time = Time.get_analysis_start_time()
circuit_name = qh_pm_search.get_circuit_name()
prefix_circuit_name = circuit_name.split('.')[0]
date_time_qh = Time.to_datetime(qh_pm_search.source_timestamp_df.loc[0, 'timestamp']).strftime("%Y-%m-%d-%Hh%M")
apply_report_template()
!mkdir -p /eos/project/m/mp3/IPQ/$prefix_circuit_name/$circuit_name/QHDA
file_name_html = "{}_QHDA-{}-{}.html".format(circuit_name, date_time_qh, analysis_start_time)
full_path = '/eos/project/m/mp3/IPQ/{}/{}/QHDA/{}'.format(prefix_circuit_name, circuit_name, 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 $'HWC_IPQ_QHDA.ipynb' --output /eos/project/m/mp3/IPQ/$prefix_circuit_name/$circuit_name/QHDA/$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
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of a QH discharge in an IT Circuit</center></h1>
%% Cell type:markdown id: tags:
# 0. Initialise Working Environment
%% Cell type:code id: tags:
``` python
# External libraries
print('Loading (1/13)'); import sys
print('Loading (2/13)'); from multiprocessing import Pool
print('Loading (3/13)'); from IPython.display import display, HTML, Javascript, clear_output
# Internal libraries
print('Loading (4/13)'); import lhcsmapi
print('Loading (5/13)'); from lhcsmapi.Time import Time
print('Loading (6/13)'); from lhcsmapi.Timer import Timer
print('Loading (7/13)'); from lhcsmapi.analysis.ItCircuitQuery import ItCircuitQuery
print('Loading (8/13)'); from lhcsmapi.analysis.ItCircuitAnalysis import ItCircuitAnalysis
print('Loading (9/13)'); from lhcsmapi.analysis.expert_input import check_show_next
print('Loading (10/13)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (11/13)'); from lhcsmapi.gui.DateTimeBaseModule import DateTimeBaseModule
print('Loading (12/13)'); from lhcsmapi.gui.qh.QhPmSearchModuleMediator import QhPmSearchModuleMediator
print('Loading (13/13)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
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. Find QH Post Mortem Entries
%% Cell type:code id: tags:
``` python
circuit_type = 'IT'
qh_pm_search = QhPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2021-01-12 00:00:00+01:00', end_date_time='2021-01-31 00:00:00+01:00'), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
it_query = ItCircuitQuery(circuit_type, qh_pm_search.get_circuit_name())
it_analysis = ItCircuitAnalysis(it_query.circuit_type)
with Timer():
u_hds_dfss = it_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'])
u_hds_ref_dfss = it_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'], is_ref=True)
```
%% Cell type:markdown id: tags:
# 3. Quench Heaters
*CRITERIA*:
- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage is +/- 5 ms from the reference ones
- the initial voltage should be between 810 V and 1000 V
- the final voltage should be between 0 V and 10 V
*GRAPHS*:
t = 0 s corresponds to the start of the pseudo-exponential decay
Voltage view (linear and log)
- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS
%% Cell type:code id: tags:
``` python
index = 0
for u_hds_dfs, u_hds_ref_dfs in zip(u_hds_dfss, u_hds_ref_dfss):
print(index, qh_pm_search.source_timestamp_df.loc[index, 'timestamp'])
it_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)
it_analysis.analyze_qh(qh_pm_search.get_circuit_name(), qh_pm_search.source_timestamp_df.loc[index, 'timestamp'], u_hds_dfs, u_hds_ref_dfs, nominal_voltage=qh_pm_search.get_discharge_level())
index += 1
```
%% Cell type:markdown id: tags:
# 4. Final Report
%% Cell type:code id: tags:
``` python
if not qh_pm_search.source_timestamp_df.empty:
analysis_start_time = Time.get_analysis_start_time()
circuit_name = qh_pm_search.get_circuit_name()
date_time_qh = Time.to_datetime(qh_pm_search.source_timestamp_df.loc[0, 'timestamp']).strftime("%Y-%m-%d-%Hh%M")
file_name_html = "{}_QHDA-{}-{}.html".format(circuit_name, date_time_qh, analysis_start_time)
apply_report_template()
!mkdir -p /eos/project/m/mp3/IT/$circuit_name/QHDA
full_path = '/eos/project/m/mp3/IT/{}/QHDA/{}'.format(circuit_name, 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 $'HWC_IT_QHDA.ipynb' --output /eos/project/m/mp3/IT/$circuit_name/QHDA/$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
```
......
%% Cell type:markdown id: tags:
<h1><center>Analysis of a QH discharge in an RB Circuit</center></h1>
%% 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 multiprocessing import Pool
print('Loading (3/12)'); from IPython.display import display, HTML, Javascript, clear_output
# 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.qh.QuenchHeaterAnalysis import analyze_single_qh, plot_qh_discharge_hwc
print('Loading (9/12)'); from lhcsmapi.analysis.expert_input import check_show_next
print('Loading (10/12)'); from lhcsmapi.analysis.report_template import apply_report_template
print('Loading (11/12)'); from lhcsmapi.gui.DateTimeBaseModule import DateTimeBaseModule
print('Loading (12/12)'); from lhcsmapi.gui.qh.QhPmSearchModuleMediator import QhPmSearchModuleMediator
print('Loading (13/13)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator
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. Find QH Post Mortem Entries
%% Cell type:code id: tags:
``` python
circuit_type = 'RB'
qh_pm_search = QhPmSearchModuleMediator(DateTimeBaseModule(start_date_time='2021-01-12 00:00:00+01:00', end_date_time='2021-01-31 00:00:00+01:00'), circuit_type=circuit_type)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
``` python
from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder
from lhcsmapi.reference.Reference import Reference
def query_qh_parallel(input_param):
source, timestamp, is_ref = input_param
if is_ref:
timestamp = Reference.get_quench_heater_reference_discharge('RB', source)
u_hds_dfs = QueryBuilder().with_pm() \
.with_timestamp(timestamp) \
.with_circuit_type('RB') \
.with_metadata(circuit_name=qh_pm_search.get_circuit_name(), system='QH', signal=['U_HDS', 'I_HDS'], source=source,
wildcard={'CELL': source}) \
.signal_query() \
.synchronize_time(timestamp) \
.convert_index_to_sec().dfs
print('Done: %s: %d' % (source, timestamp))
return u_hds_dfs
with Timer():
input_params = list(zip(qh_pm_search.source_timestamp_df['source'].values, qh_pm_search.source_timestamp_df['timestamp'].values, [False]*len(qh_pm_search.source_timestamp_df)))
print('Querying requested QH events...')
with Pool(processes=8) as pool:
qh_dfs = pool.map(query_qh_parallel, input_params)
input_params = list(zip(qh_pm_search.source_timestamp_df['source'].values, qh_pm_search.source_timestamp_df['timestamp'].values, [True]*len(qh_pm_search.source_timestamp_df)))
print('Querying reference QH events...')
with Pool(processes=8) as pool:
qh_ref_dfs = pool.map(query_qh_parallel, input_params)
qh_pm_search.source_timestamp_df.sort_values(by='source', inplace=True)
qh_pm_search.source_timestamp_df.reset_index(drop=True, inplace=True)
qh_dfs.sort(key=lambda el: el[0].columns.values[0].split(':')[0])
qh_ref_dfs.sort(key=lambda el: el[0].columns.values[0].split(':')[0])
```
%% Cell type:markdown id: tags:
# 3. Quench Protection System
## 3.1. 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
Bottom plot (Resistance view)
- the calculated quench heater resistance on the left axis, R_HDS
%% Cell type:code id: tags:
``` python
index_max = len(qh_dfs) - 1
qh_pm_search.source_timestamp_df['acceptance'] = float('nan')
qh_pm_search.source_timestamp_df['datetime'] = float('nan')
qh_pm_search.source_timestamp_df['link_to_analysis'] = float('nan')
for index, row in qh_pm_search.source_timestamp_df.iterrows():
source = row['source']
timestamp = row['timestamp']
print('{}/{}: Analysing quench heater signals of {} on {}, {}'.format(index, index_max, source, Time.to_string_short(timestamp), timestamp))
display(HTML('<a id=' + source + '>' + source + '</a>, <a href=#Table>Back to Table</a>'))
# Get matching voltage and current
u_hds_dfs = list(filter(lambda col: 'U_HDS' in col.columns.values[0], qh_dfs[index]))
i_hds_dfs = list(filter(lambda col: 'I_HDS' in col.columns.values[0], qh_dfs[index]))
# Get matching reference voltage and current
u_hds_ref_dfs = list(filter(lambda col: 'U_HDS' in col.columns.values[0], qh_ref_dfs[index]))
i_hds_ref_dfs = list(filter(lambda col: 'I_HDS' in col.columns.values[0], qh_ref_dfs[index]))
is_qh_correct = analyze_single_qh(timestamp, source, u_hds_dfs, i_hds_dfs, u_hds_ref_dfs, i_hds_ref_dfs, plot_qh_discharge=plot_qh_discharge_hwc, mean_start_value=50, current_offset=0.085)
is_qh_correct = analyze_single_qh(timestamp, source, u_hds_dfs, i_hds_dfs, u_hds_ref_dfs, i_hds_ref_dfs, plot_qh_discharge=plot_qh_discharge_hwc, mean_start_value=50, current_offset=0.085, nominal_voltage=qh_pm_search.get_discharge_level())
print('QH assessment is:', 'Pass' if is_qh_correct else 'Fail')
# Show next
check_show_next(index, index_max, is_automatic=qh_pm_search.is_automatic_mode())
qh_pm_search.source_timestamp_df.loc[index, 'acceptance'] = 'Pass' if is_qh_correct else 'Fail'
qh_pm_search.source_timestamp_df.loc[index, 'datetime'] = '<a id="' + source + '_in_table">' + Time.to_string_short(timestamp) + '</a>'
qh_pm_search.source_timestamp_df.loc[index, 'link_to_analysis'] = '<a href="#'+ source + '">' + source + '</a>'
```
%% Cell type:markdown id: tags:
## 3.2. Display QH Discharge Table
%% Cell type:code id: tags:
``` python
display(HTML('<a id=Table>Table</a>'))
qh_pm_search.source_timestamp_df.style
```
%% Cell type:markdown id: tags:
# 4. Final Report
%% Cell type:code id: tags:
``` python
if not qh_pm_search.source_timestamp_df.empty:
analysis_start_time = Time.get_analysis_start_time()
circuit_name = qh_pm_search.get_circuit_name()
date_time_qh = Time.to_datetime(qh_pm_search.source_timestamp_df.loc[0, 'timestamp']).strftime("%Y-%m-%d-%Hh%M")
file_name_html = "{}_QHDA-{}-{}.html".format(circuit_name, date_time_qh, analysis_start_time)
apply_report_template()
!mkdir -p /eos/project/m/mp3/RB/$circuit_name/QHDA
full_path = '/eos/project/m/mp3/RB/{}/QHDA/{}'.format(circuit_name, 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 $'HWC_RB_QHDA.ipynb' --output /eos/project/m/mp3/RB/$circuit_name/QHDA/$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
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment