-
Notifications
You must be signed in to change notification settings - Fork 8
/
flares.html
372 lines (318 loc) · 9.99 KB
/
flares.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>solar flares</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<meta name="keywords" content="hmi,helioseismic and magnetic imager,sdo,solar dynamics observatory,nasa,astronomy,astrophysics,stanford university solar observatories group"/>
<title>flare locations</title>
<style type="text/css">
body{
margin: 0 auto;
font-family: Georgia;
color: #000000;
line-height: 1.15;
max-width: 1100px;
font-size: 20px;
background: #f5f4f0;
}
.axis path,
.axis line {
fill: none;
stroke: gray;
stroke-width: 2;
shape-rendering: crispEdges;
}
.axis text {
font-family: Georgia;
font-size: 20px;
fill: gray
}
circle:hover {
fill: purple;
}
#tooltip {
position: absolute;
width: 400px;
height: auto;
padding: 10px;
background-color: #f5f4f0;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
pointer-events: none;
}
#tooltip.hidden {
display: none;
}
#tooltip p {
margin: 0;
font-family: Georgia;
font-size: 20px;
line-height: 20px;
}
path {
fill: #f5f4f0;
opacity: 1.0;
stroke-linejoin: round;
}
.graticule {
stroke: #aaa;
fill: #f5f4f0;
opacity: 1.0;
}
#Xflaring {
color:#000;
font-size:20px;
font-family:Georgia;
padding:5px;
background:#e2e2e2;
cursor:pointer;
margin-left:0px;
margin-right:3px;
margin-top:3px;
margin-bottom:3px;
float:left;
width:125px;
}
#Mflaring {
color:#000;
font-size:20px;
font-family:Georgia;
padding:5px;
background:#e2e2e2;
cursor:pointer;
margin-left:3px;
margin-right:3px;
margin-top:3px;
margin-bottom:3px;
float:left;
width:125px;
}
#Cflaring {
color:#000;
font-size:20px;
font-family:Georgia;
padding:5px;
background:#e2e2e2;
cursor:pointer;
margin-top:3px;
margin-bottom:20px;
margin-left:0px;
margin-right:3px;
float:left;
width:125px;
}
#all {
color:#000;
font-size:20px;
font-family:Georgia;
padding:5px;
background:#e2e2e2;
cursor:pointer;
margin-top:3px;
margin-left:3px;
margin-right:3px;
margin-bottom:20px;
float:left;
width:125px;
}
aside {
width:295px;
float:right;
text-align:left;
}
footer {
clear:both;
margin-top:3px;
text-align:center;
font-size: 14px;
}
</style>
</head>
<body>
<div id="tooltip" class="hidden">
<p><span id="value">100</span></p>
</div>
<div id="titling"><h1>Solar Flares </h1></div>
<div id="main-text">
<p id="data-text">
All the flares observed by the <a href="http://sdo.gsfc.nasa.gov/"> Solar Dynamics Observatory</a>, which takes more data than any other NASA satellite in history, are plotted here in a <a href= "https://en.wikipedia.org/wiki/Stereographic_projection"> standard stereographic projection</a> with <a href="http://d3js.org/" target="_blank">D3</a>. In the absence of a definitive theory of flare physics, the best hope for forecasting flares lies in analyzing our vast data set for observational clues. <a href= "http://arxiv.org/abs/1411.1405"> One way</a> is to use artificial intelligence.
</p>
</div>
<!--- Create the rollover description --->
<aside>
<div id="titling"><h1>Flare Classes </h1></div>
<p>Flares are <a href= "https://en.wikipedia.org/wiki/Solar_flare#Classification"> classified</a> according <br> to their X-ray intensity.</p>
<div> <a id="Xflaring">X-class flares</a> </div>
<div> <a id="Mflaring">M-class flares</a> </div>
<div> <a id="Cflaring">C-class flares</a> </div>
<div> <a id="all">All flares</a> </div>
<p id="p8">Click on the buttons above to display select flare classes. Roll over the dots below for details about each flare class. </p>
<svg id="s4" width="200" height="40"></svg>
<script>
var keyCircles=[{"x":90, "y":20, "r": 20, "z":"rgba(225, 39, 0, 0.85)"},
{"x":140, "y":20, "r": 15, "z":"rgba(34, 169, 34, 0.85)"},
{"x":180, "y":20, "r": 10, "z":"rgba(220, 190, 38, 0.85)"}];
var keyTextArray = ["X-class: The largest flare class. These large flares almost always come from large, complicated, and rapidly evolving sunspots.", "M-class: Ten times smaller than X-class flares. These are usually associated with large sunspots but may come from simple ones.", "C-class: Ten times smaller than M-class flares. These tiny flares do not release much energy into the solar atmosphere."];
showKey = function(i){
var x=d3.select("#s4").selectAll("text");
d3.select(x[0][i]).style("visibility", "visible");
d3.select("#p8").text(keyTextArray[i]);}
eraseKey = function(i){
var x=d3.select("#s4").selectAll("text");
d3.select(x[0][i]).style("visibility", "visible");
d3.select("#p8").text("Click on the buttons above to display select flare classes. Roll over the dots below for details about each flare class.");}
d3.select("#s4").selectAll("circle")
.data(keyCircles).enter()
.append("circle")
.attr("cx",function(d, i) {return (d.x);})
.attr("cy",function(d){return d.y;})
.attr("r",function(d){return (d.r);})
.style("fill",function(d){return d.z;})
.on("mouseover", function(d,i) {showKey(i);})
.on("mouseout", function(d,i) {eraseKey(i);});
</script>
</aside>
<!--- END: Create the rollover description --->
<script type="text/javascript">
// Taken from Bostock's rotating orthographic block:
// http://bl.ocks.org/mbostock/5731578
var width = 780,
height = 600,
time = time;
/*format = d3.time.format("%Y.%m.%d_%H:%M:%S"),
NewTime = format.parse(time);*/
var projection = d3.geo.stereographic()
.scale(200)
.translate([width / 2, height / 2])
.rotate([0, 0])
.clipAngle(180 - 1e-4)
.clipExtent([[0, 0], [width, height]])
.precision(.1);
var path = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule();
// latitude and longitude are switched in d3
// use regular stonyhurst latitude
var latitude = d3.scale.linear()
.domain([0, width])
.range([90, -90]);
// define a carrington coordinate system in latitude
var longitude = d3.scale.linear()
.domain([0, height])
.range([0, 360]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
var feature = svg.selectAll("path");
// Render the plot for all the data points
function render(){
// remove the old svg elements such that the new ones can be plotted in the same place
svg.selectAll("circle")
.remove();
svg.selectAll("circle")
.data(d)
.enter()
.append("circle")
.attr("cx", function(d) {
var longitude = d.longitude;
var latitude = d.latitude;
return projection([latitude, longitude])[0];
})
.attr("cy", function(d) {
var longitude = d.longitude;
var latitude = d.latitude;
return projection([latitude, longitude])[1];
})
.attr("r", function(d) {
if (d.class === "X") {return Math.pow((100.0*d.level),0.7);}
if (d.class === "C") {return Math.pow((1.0*d.level),0.7) ;}
if (d.class === "M") {return Math.pow((10.0*d.level),0.7) ;}
})
.attr("fill", function(d) {
if (d.class === "X") {return "rgba("+ d3.round(((d.level*7)+180)) + ", 69, 0, 0.75)" ;}
if (d.class === "C") {return "rgba("+ d3.round(((d.level*5.5)+194)) + ", " + d3.round((d.level*4)+145) + ", " + d3.round(d.level+30)+ ", 0.75)" ;}
if (d.class === "M") {return "rgba(34," + d3.round((d.level*7)+104) + ", 34, 0.75)" ;}
})
.on("mouseover", function(d) {
//Get this bar's x/y values, then augment for the tooltip
var xPosition = parseFloat(d3.select(this).attr("cx"));
var yPosition = parseFloat(d3.select(this).attr("cy"));
//Update the tooltip position and value
d3.select("#tooltip")
.style("left", xPosition - 110 + "px")
.style("top", yPosition + 140 + "px")
.select("#value")
.text(d.class+"-"+d.level+" flare on "+ d.time ) ;
//Show the tooltip
d3.select("#tooltip").classed("hidden", false);
})
.on("mouseout", function() {
//Hide the tooltip
d3.select("#tooltip").classed("hidden", true);
});
};
//ready to roll
var d;
d3.csv("flares.csv", function(error, data) {
d = data,
//console.log(d);
render();
});
// use filters to plot flaring active regions
d3.select("#Xflaring")
.on("click",function() {
d3.csv("xflares.csv", function(data) {
d = data;
render();
});
});
d3.select("#Mflaring")
.on("click",function() {
d3.csv("mflares.csv", function(data) {
d = data;
render();
});
});
d3.select("#Cflaring")
.on("click",function() {
d3.csv("cflares.csv", function(data) {
d = data;
render();
});
});
d3.select("#all")
.on("click",function() {
d3.csv("flares.csv", function(data) {
d = data;
render();
});
});
svg.on("mousedown", function() {
drag = true;
var p = d3.mouse(this);
});
svg.on("mouseup", function() {
drag = false;
});
svg.on("mousemove", function() {
if (drag) {
var p = d3.mouse(this);
projection.rotate([longitude(p[0]), latitude(p[1])]);
svg.selectAll("path").attr("d", path);
render();
}
});
</script>
</body>
<footer>
Monica Bobra and Chau Dang 2014
</footer>
</html>