Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LHCData
lhc-sm-hwc
Commits
05c1d4db
Commit
05c1d4db
authored
Oct 28, 2021
by
Agata Chadaj
Browse files
wip
parent
06da42d8
Pipeline
#3176858
passed with stage
in 30 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CI/send_results.py
View file @
05c1d4db
...
...
@@ -24,8 +24,8 @@ def get_result():
result_nb
=
nbformat
.
read
(
result_path
,
as_version
=
4
)
nb
=
outputs
.
NotebookOutput
(
result_nb
)
try
:
summary
=
nb
.
get_cells_by_tag
(
'result'
)[
0
].
get_cell_output
(
outputs
.
CellOutputType
.
STDOUT
)[
0
]
result_flag
=
nb
.
get_cells_by_tag
(
'result'
)[
1
].
get_cell_output
(
outputs
.
CellOutputType
.
STDOUT
)[
0
]
summary
=
nb
.
get_cells_by_tag
(
'result'
)[
1
].
get_cell_output
(
outputs
.
CellOutputType
.
STDOUT
)[
0
]
result_flag
=
nb
.
get_cells_by_tag
(
'result'
)[
0
].
get_cell_output
(
outputs
.
CellOutputType
.
STDOUT
)[
0
]
except
IndexError
:
return
'FAILED'
,
''
return
result_flag
,
summary
...
...
@@ -35,7 +35,7 @@ def save_data_to_file(data: dict):
file_path
=
'/eos/home-m/mpesoft/test.csv'
df
=
pd
.
DataFrame
([
data
])
with
open
(
file_path
,
'a'
)
as
f
:
df
.
to_csv
(
f
,
mode
=
'a'
,
header
=
f
.
tell
()
==
0
)
df
.
to_csv
(
f
,
mode
=
'a'
,
header
=
f
.
tell
()
==
0
,
index
=
False
)
if
__name__
==
'__main__'
:
...
...
papermill_nxcals/src/papermill_nxcals/engine.py
View file @
05c1d4db
...
...
@@ -21,7 +21,9 @@ class PapermillNxcalsEngine(NBClientEngine):
to the notebook. Then calls :func: `NBClientEngine.execute_managed_notebook` to execute the parameterized
notebook locally.
"""
print
(
'papermill engine'
)
print
(
**
kwargs
)
print
(
kwargs
)
# make all cells tagged with 'ignore' raw
for
cell
in
nb_man
.
nb
.
cells
:
if
_IGNORE_TAG
in
cell
.
metadata
.
tags
:
...
...
@@ -34,6 +36,7 @@ class PapermillNxcalsEngine(NBClientEngine):
# call the papermill execution engine:
return
super
().
execute_managed_notebook
(
nb_man
,
kernel_name
,
**
kwargs
)
# save_analysis_result()
def
_replace_matplotlib_backend
(
nb_man
,
new_backend
=
'inline'
):
...
...
@@ -58,3 +61,7 @@ def _get_nxcals_config_cell():
def
_get_nxcals_config
():
return
pkgutil
.
get_data
(
'resources'
,
_MANUAL_SPARK_CONFIG_FILE
).
decode
(
"utf-8"
)
def
save_analysis_result
():
pass
qh/HWC_IPQ_QHDA.ipynb
View file @
05c1d4db
...
...
@@ -236,7 +236,7 @@
},
"outputs": [],
"source": [
"ipq_analysis.get_
result
()"
"ipq_analysis.get_
status
()"
]
},
{
...
...
%% 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/16)'
);
import
sys
;
import
pandas
as
pd
print
(
'Loading (2/16)'
);
from
multiprocessing
import
Pool
print
(
'Loading (3/16)'
);
from
IPython.display
import
display
,
HTML
,
Javascript
,
clear_output
# Internal libraries
print
(
'Loading (4/16)'
);
import
lhcsmapi
print
(
'Loading (5/16)'
);
from
lhcsmapi.Time
import
Time
print
(
'Loading (6/16)'
);
from
lhcsmapi.Timer
import
Timer
print
(
'Loading (7/16)'
);
from
lhcsmapi.analysis.IpqCircuitQuery
import
IpqCircuitQuery
print
(
'Loading (8/16)'
);
from
lhcsmapi.analysis.IpqCircuitAnalysis
import
IpqCircuitAnalysis
print
(
'Loading (9/16)'
);
from
lhcsmapi.analysis.expert_input
import
check_show_next
,
get_expert_decision
print
(
'Loading (10/16)'
);
from
lhcsmapi.analysis.qh.QuenchHeaterQuery
import
QuenchHeaterQuery
print
(
'Loading (11/16)'
);
from
lhcsmapi.analysis.report_template
import
apply_report_template
print
(
'Loading (12/16)'
);
from
lhcsmapi.gui.DateTimeBaseModule
import
DateTimeBaseModule
print
(
'Loading (13/16)'
);
from
lhcsmapi.gui.hwc.HwcSearchModuleMediator
import
HwcSearchModuleMediator
print
(
'Loading (14/16)'
);
from
lhcsmapi.gui.qh.QhPmSearchModuleMediator
import
QhPmSearchModuleMediator
print
(
'Loading (15/16)'
);
from
lhcsmapi.metadata.SignalMetadata
import
SignalMetadata
print
(
'Loading (16/16)'
);
from
lhcsmnb.parameters
import
are_all_parameters_injected
,
get_source_timestamp_df
,
NbType
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:parameters
```
python
circuit_type
=
'IPQ'
```
%% Cell type:code id: tags:
```
python
with
Timer
():
if
not
are_all_parameters_injected
(
NbType
.
QH
,
locals
()):
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
)
else
:
circuit_sub_type
=
SignalMetadata
.
get_circuit_type_for_circuit_name
(
circuit_name
)
source_timestamp_df
=
QuenchHeaterQuery
(
circuit_sub_type
,
circuit_name
).
find_source_timestamp_qh_with_pattern
(
'*'
,
start_time
,
end_time
)
display
(
HTML
(
source_timestamp_df
.
to_html
()))
```
%% Cell type:markdown id: tags:
# 2. Query All Signals Prior to Analysis
%% Cell type:code id: tags:
```
python
with
Timer
():
if
not
are_all_parameters_injected
(
NbType
.
QH
,
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
()
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
,
source_timestamp_df
.
loc
[
index
,
'timestamp'
])
if
u_hds_dfs
:
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
=
discharge_level
)
else
:
print
(
f
"No Quench Heater Discharges!"
)
index
+=
1
```
%% Cell type:markdown id: tags:ignore
# 4. Signature Decision
%% Cell type:markdown id: tags:ignore
# 5. Final Report
%% Cell type:code id: tags:ignore
```
python
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
(
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:ignore
# 6. Save Timestamps in Reference Format (if update needed)
%% Cell type:code id: tags:ignore
```
python
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
(
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:result
```
python
ipq_analysis
.
get_
result
()
ipq_analysis
.
get_
status
()
```
%% Cell type:code id: tags:result
```
python
ipq_analysis
.
get_analysis_result
()
```
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment