Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ClassifyStorms
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Leonie Pick
ClassifyStorms
Commits
4126ba84
Commit
4126ba84
authored
May 09, 2019
by
Leonie Pick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed correct representation of synthetic feature.
parent
6ead95d6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
457 additions
and
48 deletions
+457
-48
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
+294
-19
ClassifyStorms.ipynb
ClassifyStorms.ipynb
+154
-21
Modules.py
Modules.py
+7
-6
Plots.py
Plots.py
+2
-2
No files found.
.ipynb_checkpoints/ClassifyStorms-checkpoint.ipynb
View file @
4126ba84
...
...
@@ -84,20 +84,146 @@
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 93. 82. 83. 62. 38. 60.\n",
" 72. 93. 90. 78. 82. 94. 73. 77. 50. 43. 85. 93.\n",
" 86. 109. 94. 117. 94. 77. 46. 39. 87. 103. 91. 97.\n",
" 105. 81. 49. 39. 24. 8. 33. 61. 80. 56. 71. 65.\n",
" 73. 77. 101. 83. 58. 54. 92. 87. 63. 93. 108. 105.\n",
" 102. 79. 57. 41. 70. 104. 100. 111. 94. 69. 78. 66.\n",
" 24. 40. 79. 73. 99. 64. 81. 112. 79. 71. 32. 20.\n",
" 10. 2. 10. 25. 54. 36. 31. 74.]\n"
]
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>HMC percentile</th>\n",
" <th>Min. HMC drop [nT]</th>\n",
" <th>Scaling power</th>\n",
" <th>Separation [h]</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>29.0</td>\n",
" <td>7.0</td>\n",
" <td>1.0</td>\n",
" <td>26.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" HMC percentile Min. HMC drop [nT] Scaling power Separation [h]\n",
"0 29.0 7.0 1.0 26.0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fraction [%]</th>\n",
" <th>No. targets</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Selection</th>\n",
" <td>1.001109</td>\n",
" <td>7547</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fraction [%] No. targets\n",
"Selection 1.001109 7547"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>No. CIRs</th>\n",
" <th>No. CMEs</th>\n",
" <th>Total</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Training set</th>\n",
" <td>571</td>\n",
" <td>297</td>\n",
" <td>868</td>\n",
" </tr>\n",
" <tr>\n",
" <th>in Target set</th>\n",
" <td>342</td>\n",
" <td>196</td>\n",
" <td>538</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" No. CIRs No. CMEs Total\n",
"Training set 571 297 868\n",
"in Target set 342 196 538"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
...
...
@@ -153,18 +279,167 @@
},
{
"cell_type": "code",
"execution_count":
5
,
"execution_count":
4
,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Q2 CIRs</th>\n",
" <th>Q2 CMEs</th>\n",
" <th>Q2 Difference</th>\n",
" <th>IQR Overlap</th>\n",
" <th>Q2 Difference- IQR Overlap</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.084</td>\n",
" <td>0.154</td>\n",
" <td>0.071</td>\n",
" <td>0.008</td>\n",
" <td>0.063</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.456</td>\n",
" <td>0.737</td>\n",
" <td>0.280</td>\n",
" <td>0.069</td>\n",
" <td>0.211</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.143</td>\n",
" <td>0.221</td>\n",
" <td>0.078</td>\n",
" <td>0.059</td>\n",
" <td>0.020</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.452</td>\n",
" <td>0.290</td>\n",
" <td>0.162</td>\n",
" <td>0.100</td>\n",
" <td>0.062</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.500</td>\n",
" <td>0.500</td>\n",
" <td>0.000</td>\n",
" <td>0.000</td>\n",
" <td>0.000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.583</td>\n",
" <td>0.667</td>\n",
" <td>0.083</td>\n",
" <td>0.208</td>\n",
" <td>-0.125</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.132</td>\n",
" <td>0.218</td>\n",
" <td>0.087</td>\n",
" <td>0.061</td>\n",
" <td>0.026</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.050</td>\n",
" <td>0.050</td>\n",
" <td>0.000</td>\n",
" <td>0.050</td>\n",
" <td>-0.050</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.066</td>\n",
" <td>0.118</td>\n",
" <td>0.052</td>\n",
" <td>0.012</td>\n",
" <td>0.040</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>0.514</td>\n",
" <td>0.652</td>\n",
" <td>0.138</td>\n",
" <td>0.159</td>\n",
" <td>-0.021</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>0.636</td>\n",
" <td>0.610</td>\n",
" <td>0.026</td>\n",
" <td>0.068</td>\n",
" <td>-0.042</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>0.250</td>\n",
" <td>0.501</td>\n",
" <td>0.251</td>\n",
" <td>-0.238</td>\n",
" <td>0.490</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Q2 CIRs Q2 CMEs Q2 Difference IQR Overlap Q2 Difference- IQR Overlap\n",
"1 0.084 0.154 0.071 0.008 0.063\n",
"2 0.456 0.737 0.280 0.069 0.211\n",
"3 0.143 0.221 0.078 0.059 0.020\n",
"4 0.452 0.290 0.162 0.100 0.062\n",
"5 0.500 0.500 0.000 0.000 0.000\n",
"6 0.583 0.667 0.083 0.208 -0.125\n",
"7 0.132 0.218 0.087 0.061 0.026\n",
"8 0.050 0.050 0.000 0.050 -0.050\n",
"9 0.066 0.118 0.052 0.012 0.040\n",
"10 0.514 0.652 0.138 0.159 -0.021\n",
"11 0.636 0.610 0.026 0.068 -0.042\n",
"12 0.250 0.501 0.251 -0.238 0.490"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"HMC1y = md.LowpassFilter(Var['HMC'],Frequency/(24*SiderealYear),Frequency)\n",
"\n",
"
#
Save = True\n",
"Save = True\n",
"#FeatureIndices, Features = md.Get_Features(Var['Time'],TargetEvents,Var['Training'],Var['HMC'],HMC11y,HMC1y,dHMC,Var['B_MLT'],Var['ASY'],Save)\n",
"\n",
"FeatureSave = np.load('./Dump/Out/
development/Features_SC0
.npz')\n",
"FeatureSave = np.load('./Dump/Out/
Features
.npz')\n",
"FeatureIndices = FeatureSave['FeatureIndices']; Features = FeatureSave['Features']\n",
"
#
md.Get_Diagnostics(Features,TargetEvents,Var['Training'],Save)"
"md.Get_Diagnostics(Features,TargetEvents,Var['Training'],Save)"
]
},
{
...
...
ClassifyStorms.ipynb
View file @
4126ba84
...
...
@@ -80,7 +80,7 @@
},
{
"cell_type": "code",
"execution_count":
3
,
"execution_count":
4
,
"metadata": {},
"outputs": [
{
...
...
@@ -224,22 +224,6 @@
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 93. 86. 88. 71. 56. 68.\n",
" 79. 96. 94. 80. 84. 98. 93. 93. 74. 67. 95. 105.\n",
" 92. 112. 94. 117. 95. 79. 68. 67. 102. 108. 93. 106.\n",
" 111. 102. 88. 81. 72. 61. 71. 91. 93. 84. 86. 83.\n",
" 94. 93. 105. 87. 85. 74. 103. 103. 76. 104. 110. 107.\n",
" 108. 96. 73. 71. 94. 109. 110. 120. 104. 94. 89. 83.\n",
" 64. 79. 101. 89. 107. 88. 96. 117. 94. 96. 61. 51.\n",
" 54. 36. 50. 72. 83. 64. 84. 93.]\n"
]
}
],
"source": [
...
...
@@ -297,16 +281,165 @@
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Q2 CIRs</th>\n",
" <th>Q2 CMEs</th>\n",
" <th>Q2 Difference</th>\n",
" <th>IQR Overlap</th>\n",
" <th>Q2 Difference- IQR Overlap</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.084</td>\n",
" <td>0.154</td>\n",
" <td>0.071</td>\n",
" <td>0.008</td>\n",
" <td>0.063</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.456</td>\n",
" <td>0.737</td>\n",
" <td>0.280</td>\n",
" <td>0.069</td>\n",
" <td>0.211</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.143</td>\n",
" <td>0.221</td>\n",
" <td>0.078</td>\n",
" <td>0.059</td>\n",
" <td>0.020</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.452</td>\n",
" <td>0.290</td>\n",
" <td>0.162</td>\n",
" <td>0.100</td>\n",
" <td>0.062</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.500</td>\n",
" <td>0.500</td>\n",
" <td>0.000</td>\n",
" <td>0.000</td>\n",
" <td>0.000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.583</td>\n",
" <td>0.667</td>\n",
" <td>0.083</td>\n",
" <td>0.208</td>\n",
" <td>-0.125</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.132</td>\n",
" <td>0.218</td>\n",
" <td>0.087</td>\n",
" <td>0.061</td>\n",
" <td>0.026</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.050</td>\n",
" <td>0.050</td>\n",
" <td>0.000</td>\n",
" <td>0.050</td>\n",
" <td>-0.050</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.066</td>\n",
" <td>0.118</td>\n",
" <td>0.052</td>\n",
" <td>0.012</td>\n",
" <td>0.040</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>0.514</td>\n",
" <td>0.652</td>\n",
" <td>0.138</td>\n",
" <td>0.159</td>\n",
" <td>-0.021</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>0.636</td>\n",
" <td>0.610</td>\n",
" <td>0.026</td>\n",
" <td>0.068</td>\n",
" <td>-0.042</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>0.250</td>\n",
" <td>0.749</td>\n",
" <td>0.499</td>\n",
" <td>-0.485</td>\n",
" <td>0.984</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Q2 CIRs Q2 CMEs Q2 Difference IQR Overlap Q2 Difference- IQR Overlap\n",
"1 0.084 0.154 0.071 0.008 0.063\n",
"2 0.456 0.737 0.280 0.069 0.211\n",
"3 0.143 0.221 0.078 0.059 0.020\n",
"4 0.452 0.290 0.162 0.100 0.062\n",
"5 0.500 0.500 0.000 0.000 0.000\n",
"6 0.583 0.667 0.083 0.208 -0.125\n",
"7 0.132 0.218 0.087 0.061 0.026\n",
"8 0.050 0.050 0.000 0.050 -0.050\n",
"9 0.066 0.118 0.052 0.012 0.040\n",
"10 0.514 0.652 0.138 0.159 -0.021\n",
"11 0.636 0.610 0.026 0.068 -0.042\n",
"12 0.250 0.749 0.499 -0.485 0.984"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"HMC1y = md.LowpassFilter(Var['HMC'],Frequency/(24*SiderealYear),Frequency)\n",
"\n",
"
#
Save = True\n",
"Save = True\n",
"#FeatureIndices, Features = md.Get_Features(Var['Time'],TargetEvents,Var['Training'],Var['HMC'],HMC11y,HMC1y,dHMC,Var['B_MLT'],Var['ASY'],Save)\n",
"\n",
"FeatureSave = np.load('./Dump/Out/
development/Features_SC0
.npz')\n",
"FeatureSave = np.load('./Dump/Out/
Features
.npz')\n",
"FeatureIndices = FeatureSave['FeatureIndices']; Features = FeatureSave['Features']\n",
"
#
md.Get_Diagnostics(Features,TargetEvents,Var['Training'],Save)"
"md.Get_Diagnostics(Features,TargetEvents,Var['Training'],Save)"
]
},
{
...
...
Modules.py
View file @
4126ba84
...
...
@@ -328,11 +328,11 @@ def Get_F11(i,TrTimeIndex,TrClass):
if
i
in
TrTimeIndex
:
position
=
np
.
where
(
TrTimeIndex
==
i
)[
0
][
0
]
if
TrClass
[
position
]
==
0
:
F11
=
np
.
random
.
normal
(
loc
=
0.25
,
scale
=
0.01
,
size
=
1
)
F11
=
np
.
random
.
normal
(
loc
=
0.25
,
scale
=
0.01
,
size
=
None
)
elif
TrClass
[
position
]
==
1
:
F11
=
np
.
random
.
normal
(
loc
=
0.
5
,
scale
=
0.01
,
size
=
1
)
F11
=
np
.
random
.
normal
(
loc
=
0.
75
,
scale
=
0.01
,
size
=
None
)
else
:
F11
=
np
.
random
.
normal
(
loc
=
0.75
,
scale
=
0.01
,
size
=
1
)
F11
=
np
.
random
.
normal
(
loc
=
0.75
,
scale
=
0.01
,
size
=
None
)
else
:
F11
=
0.5
return
F11
...
...
@@ -415,7 +415,7 @@ def Get_Features(Time, Storms, Training, HMC, HMC11y, HMC1y, dHMC, B_MLT, ASY, S
print
(
'Caution!'
)
if
Save
==
True
:
np
.
savez
(
'./Dump/Out/
development/Features_SC0
'
,
Features
=
FeatureMatrix
,
FeatureIndices
=
PeakIndices
)
np
.
savez
(
'./Dump/Out/
Features
'
,
Features
=
FeatureMatrix
,
FeatureIndices
=
PeakIndices
)
return
PeakIndices
,
FeatureMatrix
###
...
...
@@ -431,7 +431,7 @@ def Get_Diagnostics(FeatureMatrix,Storms,Training,Save):
IndicesD
=
np
.
where
(
np
.
in1d
(
Storms
,
TrTimeIndex
))[
0
]
TargetKnown
=
np
.
where
(
TrKnown
==
1
)[
0
]
Data
=
FeatureMatrix
[
IndicesD
,:]
NData
=
(
Data
-
Data
.
mean
(
0
))
/
Data
.
std
(
0
)
NData2
=
(
NData
-
NData
.
min
(
0
))
/
NData
.
ptp
(
0
)
...
...
@@ -445,9 +445,10 @@ def Get_Diagnostics(FeatureMatrix,Storms,Training,Save):
TargetClasses
[
i
]
=
np
.
where
(
TrClass
[
TargetKnown
]
==
i
)[
0
]
#FData[i] = Data[TargetClasses[i],:]
NData
[
i
]
=
NData2
[
TargetClasses
[
i
],:]
NData
[
i
][:,
11
]
=
Data
[
TargetClasses
[
i
],
11
]
MData
[
i
]
=
np
.
nanmedian
(
NData
[
i
],
axis
=
0
)
SData
[
i
]
=
np
.
nanstd
(
NData
[
i
],
axis
=
0
)
FeatureResults
=
np
.
zeros
((
n_features
,
5
))
Ranges
=
np
.
zeros
((
n_features
,
n_classes
,
2
))
k
=
0
...
...
Plots.py
View file @
4126ba84
...
...
@@ -243,8 +243,8 @@ def Diagnostics(n_features,n_classes,NData, Save):
k
+=
1
if
Save
==
True
:
fig
.
savefig
(
'./Dump/Fig/
development/Features_SC0
.pdf'
,
format
=
'pdf'
,
dpi
=
200
,
transparent
=
True
)
#
fig.savefig('./Dump/Fig/Features.png',format='png',dpi=200,transparent=True)
fig
.
savefig
(
'./Dump/Fig/
Features
.pdf'
,
format
=
'pdf'
,
dpi
=
200
,
transparent
=
True
)
fig
.
savefig
(
'./Dump/Fig/Features.png'
,
format
=
'png'
,
dpi
=
200
,
transparent
=
True
)
plt
.
show
()
###
###
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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