Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LHCData
lhc-sm-hwc
Commits
a3c2dd63
Commit
a3c2dd63
authored
Jul 26, 2021
by
Aleksandra Mnich
Browse files
QH notebooks adapted
parent
b88f35dd
Pipeline
#2862237
passed with stage
in 28 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
qh/HWC_IPD_QHDA.ipynb
View file @
a3c2dd63
%% 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
;
import
pandas
as
pd
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
,
get_expert_decision
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:
%% Cell type:code id: tags:
parameters
```
python
circuit_type
=
'IPD'
qh_pm_search
=
QhPmSearchModuleMediator
(
DateTimeBaseModule
(
start_date_time
=
'2021-01-12 00:00:00+01:00'
,
end_date_time
=
Time
.
to_string
(
Time
.
now
())),
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
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
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
)
if
'qh_pm_search'
in
locals
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
discharge_level
=
qh_pm_search
.
get_discharge_level
()
source_timestamp_df
=
qh_pm_search
.
source_timestamp_df
is_automatic
=
qh_pm_search
.
is_automatic_mode
()
else
:
import
pandas
as
pd
source_timestamp_df
=
pd
.
DataFrame
({
'source'
:
sources
,
'timestamp'
:
timestamps
})
source_timestamp_df
[
'datetime'
]
=
pd
.
to_datetime
(
source_timestamp_df
[
'timestamp'
])
ipd_query
=
IpdCircuitQuery
(
circuit_type
,
circuit_name
)
ipd_analysis
=
IpdCircuitAnalysis
(
circuit_type
)
u_hds_dfss
=
ipd_query
.
query_qh_pm
(
source_timestamp_df
,
signal_names
=
[
'U_HDS'
])
u_hds_ref_dfss
=
ipd_query
.
query_qh_pm
(
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'
])
print
(
index
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
])
if
u_hds_dfs
:
ipd_analysis
.
analyze_single_qh_voltage_with_ref
(
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
()
)
ipd_analysis
.
analyze_single_qh_voltage_with_ref
(
circuit_name
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
],
u_hds_dfs
,
u_hds_ref_dfs
,
nominal_voltage
=
discharge_level
)
else
:
print
(
f
"No Quench Heater Discharges !"
)
index
+=
1
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 4. Signature Decision
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
signature
=
get_expert_decision
(
'Expert Signature Decision: '
,
[
'PASSED'
,
'FAILED'
])
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 5. Final Report
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
analysis_start_time
=
Time
.
get_analysis_start_time
()
date_time_qh
=
Time
.
to_datetime
(
qh_pm_search
.
source_timestamp_df
.
loc
[
0
,
'timestamp'
]).
strftime
(
"%Y-%m-%d-%Hh%M"
)
date_time_qh
=
Time
.
to_datetime
(
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
,
signature
)
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:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 6. Save Timestamps in Reference Format (if update needed)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
!
mkdir
-
p
/
eos
/
project
/
m
/
mp3
/
IPD
/
$
circuit_name
/
QHDA
file_name
=
"{}_QHDA-{}-{}_Reference"
.
format
(
circuit_name
,
date_time_qh
,
analysis_start_time
)
csv_full_path
=
'/eos/project/m/mp3/IPD/{}/QHDA/{}.csv'
.
format
(
circuit_name
,
file_name
)
cell_datetime_timestamp
=
pd
.
DataFrame
(
qh_pm_search
.
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
=
pd
.
DataFrame
(
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
.
to_csv
(
csv_full_path
,
index
=
False
)
print
(
'Reference timestamp table saved to (Windows): '
+
'
\\\\
cernbox-smb'
+
csv_full_path
.
replace
(
'/'
,
'
\\
'
))
```
...
...
qh/HWC_IPQ_QHDA.ipynb
View file @
a3c2dd63
%% 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
;
import
pandas
as
pd
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
,
get_expert_decision
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:
%% Cell type:code id: tags:
parameters
```
python
circuit_type
=
'IPQ'
qh_pm_search
=
QhPmSearchModuleMediator
(
DateTimeBaseModule
(
start_date_time
=
'2021-01-12 00:00:00+01:00'
,
end_date_time
=
Time
.
to_string
(
Time
.
now
())),
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
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
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
)
if
'qh_pm_search'
in
locals
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
discharge_level
=
qh_pm_search
.
get_discharge_level
()
source_timestamp_df
=
qh_pm_search
.
source_timestamp_df
is_automatic
=
qh_pm_search
.
is_automatic_mode
()
else
:
import
pandas
as
pd
source_timestamp_df
=
pd
.
DataFrame
({
'source'
:
sources
,
'timestamp'
:
timestamps
})
source_timestamp_df
[
'datetime'
]
=
pd
.
to_datetime
(
source_timestamp_df
[
'timestamp'
])
ipq_query
=
IpqCircuitQuery
(
circuit_type
,
circuit_name
)
ipq_analysis
=
IpqCircuitAnalysis
(
circuit_type
,
None
,
circuit_name
=
circuit_name
)
u_hds_dfss
=
ipq_query
.
query_qh_pm
(
source_timestamp_df
,
signal_names
=
[
'U_HDS'
])
u_hds_ref_dfss
=
ipq_query
.
query_qh_pm
(
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'
])
print
(
index
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
])
if
u_hds_dfs
:
ipq_analysis
.
analyze_single_qh_voltage_with_ref
(
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
())
ipq_analysis
.
analyze_single_qh_voltage_with_ref
(
circuit_name
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
],
u_hds_dfs
,
u_hds_ref_dfs
,
nominal_voltage
=
qh_pm_search
.
get_discharge_level
())
else
:
print
(
f
"No Quench Heater Discharges!"
)
index
+=
1
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 4. Signature Decision
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
signature
=
get_expert_decision
(
'Expert Signature Decision: '
,
[
'PASSED'
,
'FAILED'
])
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 5. Final Report
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
analysis_start_time
=
Time
.
get_analysis_start_time
()
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"
)
date_time_qh
=
Time
.
to_datetime
(
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
,
signature
)
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:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 6. Save Timestamps in Reference Format (if update needed)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
analysis_start_time
=
Time
.
get_analysis_start_time
()
prefix_circuit_name
=
circuit_name
.
split
(
'.'
)[
0
]
!
mkdir
-
p
/
eos
/
project
/
m
/
mp3
/
IPQ
/
$
prefix_circuit_name
/
$
circuit_name
/
QHDA
file_name
=
"{}_QHDA-{}-{}_Reference"
.
format
(
circuit_name
,
date_time_qh
,
analysis_start_time
)
csv_full_path
=
'/eos/project/m/mp3/IPQ/{}/{}/QHDA/{}.csv'
.
format
(
prefix_circuit_name
,
circuit_name
,
file_name
)
cell_datetime_timestamp
=
pd
.
DataFrame
(
qh_pm_search
.
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
=
pd
.
DataFrame
(
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
.
to_csv
(
csv_full_path
,
index
=
False
)
print
(
'Reference timestamp table saved to (Windows): '
+
'
\\\\
cernbox-smb'
+
csv_full_path
.
replace
(
'/'
,
'
\\
'
))
```
...
...
qh/HWC_IT_QHDA.ipynb
View file @
a3c2dd63
%% 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
;
import
pandas
as
pd
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
,
get_expert_decision
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:
%% Cell type:code id: tags:
parameters
```
python
circuit_type
=
'IT'
qh_pm_search
=
QhPmSearchModuleMediator
(
DateTimeBaseModule
(
start_date_time
=
'2021-01-12 00:00:00+01:00'
,
end_date_time
=
Time
.
to_string
(
Time
.
now
())),
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
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
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
)
if
'qh_pm_search'
in
locals
():
circuit_name
=
qh_pm_search
.
get_circuit_name
()
discharge_level
=
qh_pm_search
.
get_discharge_level
()
source_timestamp_df
=
qh_pm_search
.
source_timestamp_df
is_automatic
=
qh_pm_search
.
is_automatic_mode
()
else
:
import
pandas
as
pd
source_timestamp_df
=
pd
.
DataFrame
({
'source'
:
sources
,
'timestamp'
:
timestamps
})
source_timestamp_df
[
'datetime'
]
=
pd
.
to_datetime
(
source_timestamp_df
[
'timestamp'
])
it_query
=
ItCircuitQuery
(
circuit_type
,
circuit_name
)
it_analysis
=
ItCircuitAnalysis
(
it_query
.
circuit_type
)
u_hds_dfss
=
it_query
.
query_qh_pm
(
source_timestamp_df
,
signal_names
=
[
'U_HDS'
])
u_hds_ref_dfss
=
it_query
.
query_qh_pm
(
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
):
if
u_hds_dfs
:
print
(
index
,
qh_pm_search
.
source_timestamp_df
.
loc
[
index
,
'timestamp'
])
it_analysis
.
analyze_single_qh_voltage_with_ref
(
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
()
)
print
(
index
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
])
it_analysis
.
analyze_single_qh_voltage_with_ref
(
circuit_name
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
],
u_hds_dfs
,
u_hds_ref_dfs
,
nominal_voltage
=
discharge_level
)
else
:
print
(
f
"No Quench Heater discharges for
{
qh_pm_search
.
get_
circuit_name
()
}
on time
{
qh_pm_search
.
source_timestamp_df
.
loc
[
index
,
'timestamp'
]
}
!"
)
print
(
f
"No Quench Heater discharges for
{
circuit_name
}
on time
{
source_timestamp_df
.
loc
[
index
,
'timestamp'
]
}
!"
)
index
+=
1
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 4. Signature Decision
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
signature
=
get_expert_decision
(
'Expert Signature Decision: '
,
[
'PASSED'
,
'FAILED'
])
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 5. Final Report
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
analysis_start_time
=
Time
.
get_analysis_start_time
()
date_time_qh
=
Time
.
to_datetime
(
qh_pm_search
.
source_timestamp_df
.
loc
[
0
,
'timestamp'
]).
strftime
(
"%Y-%m-%d-%Hh%M"
)
date_time_qh
=
Time
.
to_datetime
(
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
,
signature
)
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:markdown id: tags:
%% Cell type:markdown id: tags:
ignore
# 6. Save Timestamps in Reference Format (if update needed)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
ignore
```
python
if
not
qh_pm_search
.
source_timestamp_df
.
empty
:
if
not
source_timestamp_df
.
empty
:
analysis_start_time
=
Time
.
get_analysis_start_time
()
!
mkdir
-
p
/
eos
/
project
/
m
/
mp3
/
IT
/
$
circuit_name
/
QHDA
file_name
=
"{}_QHDA-{}-{}_Reference"
.
format
(
circuit_name
,
date_time_qh
,
analysis_start_time
)
csv_full_path
=
'/eos/project/m/mp3/IT/{}/QHDA/{}.csv'
.
format
(
circuit_name
,
file_name
)
cell_datetime_timestamp
=
pd
.
DataFrame
(
qh_pm_search
.
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
qh_pm_search
.
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
=
pd
.
DataFrame
(
source_timestamp_df
.
rename
(
columns
=
{
'source'
:
'Cell'
})[
'Cell'
])
cell_datetime_timestamp
[
'Timestamp String'
]
=
source_timestamp_df
[
'timestamp'
].
apply
(
lambda
col
:
Time
.
to_string_short
(
col
,
n_dec_digits
=
9
))
cell_datetime_timestamp
[
'Timestamp'
]
=
source_timestamp_df
[
'timestamp'
]
cell_datetime_timestamp
.
to_csv
(
csv_full_path
,
index
=
False
)
print
(
'Reference timestamp table saved to (Windows): '
+
'
\\\\
cernbox-smb'
+
csv_full_path
.
replace
(
'/'
,
'
\\
'
))
```
%% Cell type:code id: tags:
```
python
```
...
...
qh/HWC_QHD_PM_LIST.ipynb
View file @
a3c2dd63
...
...
@@ -125,7 +125,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.
6.5
"
"version": "3.
8.6
"
},
"toc": {
"base_numbering": 1,
...
...
qh/HWC_RB_QHDA.ipynb
View file @
a3c2dd63
%% 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/13)'
);
import
sys
;
import
pandas
as
pd
;
import
warnings
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.RbCircuitAnalysis
import
RbCircuitAnalysis
print
(
'Loading (9/12)'
);
from
lhcsmapi.analysis.expert_input
import
check_show_next
,
get_expert_decision
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:
%% Cell type:code id: tags:
parameters
```
python
circuit_type
=
'RB'
qh_pm_search
=
QhPmSearchModuleMediator
(
DateTimeBaseModule
(
start_date_time
=
'2021-05-19 11:00:00+01:00'
,
end_date_time
=
'2021-05-19 12:09:00+01:00'
),
circuit_type
=
circuit_type
)
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
skip_output
%% 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
,
timestamp
)
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
,
.
with_metadata
(
circuit_name
=
circuit_name
,
system
=
'QH'
,
signal
=
[
'U_HDS'
,
'I_HDS'
],
source
=
source
,
wildcard
=
{
'CELL'
:
source
})
\
.
signal_query
()
\
.
synchronize_time
(
timestamp
)
\
.
convert_index_to_sec
()
\
.
drop_first_npoints
(
5
)
\
.
drop_last_npoints
(
5
).
dfs
print
(
'Done: %s: %d'
%
(
source
,
timestamp
))
return
source
,
timestamp
,
u_hds_dfs
```
%% Cell type:code id: tags:skip_output