HWC_IPQ_QHDA.ipynb 6.39 KB
Newer Older
1
2
3
4
5
6
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
7
    "<h1><center>Analysis of a QH discharge in an IPQ Circuit</center></h1>"
8
9
10
11
12
13
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
14
    "# 0. Initialise Working Environment"
15
16
17
18
   ]
  },
  {
   "cell_type": "code",
19
   "execution_count": null,
20
21
22
   "metadata": {},
   "outputs": [],
   "source": [
23
    "# External libraries\n",
24
25
26
    "print('Loading (1/13)'); import sys\n",
    "print('Loading (2/13)'); from multiprocessing import Pool\n",
    "print('Loading (3/13)'); from IPython.display import display, HTML, Javascript, clear_output\n",
27
    "\n",
28
    "# Internal libraries\n",
29
30
31
32
33
34
35
36
37
38
    "print('Loading (4/13)'); import lhcsmapi\n",
    "print('Loading (5/13)'); from lhcsmapi.Time import Time\n",
    "print('Loading (6/13)'); from lhcsmapi.Timer import Timer\n",
    "print('Loading (7/13)'); from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n",
    "print('Loading (8/13)'); from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis\n",
    "print('Loading (9/13)'); from lhcsmapi.analysis.expert_input import check_show_next\n",
    "print('Loading (10/13)'); from lhcsmapi.analysis.report_template import apply_report_template\n",
    "print('Loading (11/13)'); from lhcsmapi.gui.DateTimeBaseModule import DateTimeBaseModule\n",
    "print('Loading (12/13)'); from lhcsmapi.gui.qh.QhPmSearchModuleMediator import QhPmSearchModuleMediator\n",
    "print('Loading (13/13)'); from lhcsmapi.gui.hwc.HwcSearchModuleMediator import HwcSearchModuleMediator\n",
39
    "\n",
40
41
    "clear_output()\n",
    "lhcsmapi.get_lhcsmapi_version()\n",
42
43
    "lhcsmapi.get_lhcsmhwc_version('../__init__.py')\n",
    "print('Analysis performed by %s' % HwcSearchModuleMediator.get_user())"
44
45
46
47
48
49
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
50
    "# 1. Find QH Post Mortem Entries"
51
52
53
54
   ]
  },
  {
   "cell_type": "code",
55
   "execution_count": null,
56
   "metadata": {},
57
   "outputs": [],
58
   "source": [
59
    "circuit_type = 'IPQ'\n",
60
    "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)"
61
62
63
64
65
66
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
67
    "# 2. Query All Signals Prior to Analysis"
68
69
70
71
   ]
  },
  {
   "cell_type": "code",
72
   "execution_count": null,
73
   "metadata": {},
74
   "outputs": [],
75
   "source": [
76
77
78
79
80
81
    "ipq_query = IpqCircuitQuery(circuit_type, qh_pm_search.get_circuit_name())\n",
    "ipq_analysis = IpqCircuitAnalysis(ipq_query.circuit_type, None, circuit_name=qh_pm_search.get_circuit_name())\n",
    "\n",
    "with Timer():\n",
    "    u_hds_dfss = ipq_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'])\n",
    "    u_hds_ref_dfss = ipq_query.query_qh_pm(qh_pm_search.source_timestamp_df, signal_names=['U_HDS'], is_ref=True)"
82
83
84
85
86
87
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
88
89
90
91
92
93
94
95
96
97
98
99
    "# 3. Quench Heaters\n",
    "\n",
    "*CRITERIA*:\n",
    "- all characteristic times of an exponential decay calculated with the 'charge' approach for voltage is +/- 5 ms from the reference ones\n",
    "- the initial voltage should be between 810 V and 1000 V\n",
    "- the final voltage should be between 0 V and 10 V\n",
    "\n",
    "*GRAPHS*:  \n",
    "- t = 0 s corresponds to the start of the pseudo-exponential decay\n",
    "\n",
    "Voltage view (linear and log)\n",
    "- the queried and filtered quench heater voltage on the left axis (actual signal continuous, reference dashed), U_HDS"
100
101
102
103
   ]
  },
  {
   "cell_type": "code",
104
   "execution_count": null,
105
106
107
   "metadata": {
    "scrolled": false
   },
108
   "outputs": [],
109
   "source": [
110
111
112
    "index = 0\n",
    "for u_hds_dfs, u_hds_ref_dfs in zip(u_hds_dfss, u_hds_ref_dfss):\n",
    "    print(index, qh_pm_search.source_timestamp_df.loc[index, 'timestamp'])\n",
113
    "    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())\n",
114
    "    index += 1"
115
116
117
118
119
120
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
121
    "# 4. Final Report"
122
123
124
125
126
127
128
129
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
130
    "if not qh_pm_search.source_timestamp_df.empty:\n",
131
    "    analysis_start_time = Time.get_analysis_start_time()\n",
132
133
134
135
136
137
138
139
140
141
142
143
    "    circuit_name = qh_pm_search.get_circuit_name()\n",
    "    prefix_circuit_name = circuit_name.split('.')[0]\n",
    "    date_time_qh = Time.to_datetime(qh_pm_search.source_timestamp_df.loc[0, 'timestamp']).strftime(\"%Y-%m-%d-%Hh%M\")\n",
    "\n",
    "    apply_report_template()\n",
    "    !mkdir -p /eos/project/m/mp3/IPQ/$prefix_circuit_name/$circuit_name/QHDA\n",
    "    file_name_html = \"{}_QHDA-{}-{}.html\".format(circuit_name, date_time_qh, analysis_start_time)\n",
    "    full_path = '/eos/project/m/mp3/IPQ/{}/{}/QHDA/{}'.format(prefix_circuit_name, circuit_name, file_name_html)\n",
    "    print('Compact notebook report saved to (Windows): ' + '\\\\\\\\cernbox-smb' + full_path.replace('/', '\\\\'))\n",
    "    display(Javascript('IPython.notebook.save_notebook();'))\n",
    "    Time.sleep(5)\n",
    "    !{sys.executable} -m jupyter nbconvert --to html $'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\"]'"
144
   ]
145
146
147
148
149
150
151
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": false,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}