HWC_IPQ_QHDA.ipynb 4.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Import Functions"
   ]
  },
  {
   "cell_type": "code",
12
   "execution_count": null,
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   "metadata": {},
   "outputs": [],
   "source": [
    "from lhcsmapi.Time import Time\n",
    "from lhcsmapi.Timer import Timer\n",
    "from lhcsmapi.pyedsl.QueryBuilder import QueryBuilder\n",
    "from lhcsmapi.analysis.IpqCircuitQuery import IpqCircuitQuery\n",
    "from lhcsmapi.analysis.IpqCircuitAnalysis import IpqCircuitAnalysis"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# User Input"
   ]
  },
  {
   "cell_type": "code",
32
   "execution_count": null,
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
   "metadata": {},
   "outputs": [],
   "source": [
    "circuit_type = 'IPQ'\n",
    "circuit_name = 'RQ4.L2'\n",
    "\n",
    "discharge_level = 900.0\n",
    "start_time = '2018-12-10 15:22:00'\n",
    "stop_time = '2018-12-10 17:22:00'\n",
    "\n",
    "ipq_query = IpqCircuitQuery(circuit_type, circuit_name)\n",
    "ipq_analysis = IpqCircuitAnalysis(ipq_query.circuit_type, None, circuit_name=circuit_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Execute a Parallel Query\n",
    "- Find PM QH events"
   ]
  },
  {
   "cell_type": "code",
57
   "execution_count": null,
58
   "metadata": {},
59
   "outputs": [],
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
   "source": [
    "source_timestamp_qds_df = QueryBuilder().with_pm() \\\n",
    "    .with_duration(t_start=start_time, t_end=stop_time) \\\n",
    "    .with_circuit_type(ipq_query.circuit_type) \\\n",
    "    .with_metadata(circuit_name=circuit_name, system='QH', source='*') \\\n",
    "    .event_query().df\n",
    "\n",
    "source_timestamp_qds_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Query in parallel several QH events"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Query QH Discharges"
   ]
  },
  {
   "cell_type": "code",
86
   "execution_count": null,
87
88
89
   "metadata": {
    "scrolled": false
   },
90
   "outputs": [],
91
92
93
94
95
96
97
98
99
100
101
102
103
104
   "source": [
    "u_hds_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'])\n",
    "u_hds_dfs = u_hds_dfss[0] if u_hds_dfss else []"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Query Reference QH Discharges"
   ]
  },
  {
   "cell_type": "code",
105
   "execution_count": null,
106
107
108
   "metadata": {
    "scrolled": false
   },
109
   "outputs": [],
110
111
112
113
114
115
116
117
118
119
120
121
122
123
   "source": [
    "u_hds_ref_dfss = ipq_query.query_qh_pm(source_timestamp_qds_df, signal_names=['U_HDS'], is_ref=True)\n",
    "u_hds_ref_dfs = u_hds_ref_dfss[0] if u_hds_ref_dfss else []"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculate Features and Plot Signals"
   ]
  },
  {
   "cell_type": "code",
124
   "execution_count": null,
125
126
127
   "metadata": {
    "scrolled": false
   },
128
   "outputs": [],
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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
   "source": [
    "if u_hds_dfs:\n",
    "    ipq_analysis.analyze_qh(circuit_name, source_timestamp_qds_df.loc[0, 'timestamp'], u_hds_dfs, u_hds_ref_dfs)\n",
    "else:\n",
    "    print('No Quench Heater discharges!')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "apply_report_template()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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
}