-
Notifications
You must be signed in to change notification settings - Fork 2
/
jsparc.html
216 lines (198 loc) · 9.18 KB
/
jsparc.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HiSPARC - jSparc - Analysis</title>
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="stylesheet" media="screen" href="styles/jquery.jqplot.css">
<link rel="stylesheet" media="screen" href="styles/leaflet.css">
<link rel="stylesheet" href="styles/common.css">
<link rel="stylesheet" media="screen" href="styles/jsparc.css">
<script src="scripts/jquery-1.7.2.min.js"></script>
<script src="scripts/leaflet.js"></script>
<script src="scripts/leaflet.hisparc.js"></script>
<script src="scripts/jquery.jqplot.min.js"></script>
<script src="scripts/plugins/jqplot.cursor.min.js"></script>
<script src="scripts/plugins/jqplot.canvasTextRenderer.min.js"></script>
<script src="scripts/plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script src="scripts/plugins/jqplot.canvasAxisTickRenderer.min.js"></script>
<script src="jsparc.js"></script>
<script>
/* global detectorNumber: true, makeShowerMap: true, plotGraph: true, writeDist: true, showerMerc: true, showEvent: true */
"use strict";
var BASE_URL = "https://data.hisparc.nl/analysis-session";
var MIPdens = [];
var detector_number = [];
var station_number;
var infoURL = [];
var get_coincidence = {};
get_coincidence.session_title = "";
get_coincidence.session_pin = "";
get_coincidence.student_name = "";
var diagramColor = ["#600", "#f00", "#f90", "#ff0",
"#6f0", "#6ff", "#f0f", "#666",
"#eee", "#fd0", "#ccc", "#060",
"#00f", "#0f0"];
var traceColor = ["#222", "#D22", "#1C2", "#1CC"];
var dataflag = true;
function padZero(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;}
return str;
}
function calcMIP() {
for (var i = 0; i < MIPdens.length; i++) {
$('#MIP' + i).val((2 * MIPdens[i] / $('#count' + i).val()).toFixed(2));}
}
function getStatus(i) {
window.open(infoURL[i]);
}
function timestampToDate(timestamp) {
var iso_date = new Date(timestamp * 1000).toISOString();
return iso_date.replace('T', ' ').replace('.000Z', '');
}
function timestampToGMST(timestamp) {
var sidDays = timestamp / 86400 - 10957;
var GMST = 18.697374558 + 24.06570982441908 * sidDays; // http://en.wikipedia.org/wiki/Sidereal_time
var hours = parseInt(GMST, 10);
var minutes = (GMST - hours) * 60;
var seconds = (minutes - parseInt(minutes)) * 60;
seconds = (parseInt(0.5 + seconds * 10)) / 10;
minutes = parseInt(minutes);
sidDays = parseInt(hours / 24, 10);
hours = hours - 24 * sidDays;
GMST = sidDays + " " + padZero(hours, 2) + ":" + padZero(minutes, 2) + ":" + padZero(seconds, 2);
return GMST;
}
function loadData(data) {
$("#dataButton").hide();
$("#exampleButton").hide();
$("body").addClass("loaded");
dataflag = false;
detector_number = detectorNumber(data);
station_number = detector_number.length;
// Disable session options
$('#sessionTitle').attr('disabled', true);
$('#sessionPin').attr('disabled', true);
$('#studentName').attr('disabled', true);
// Get Year, Month, Day, Hour, Minute, Second.
var datum = timestampToDate(data.events[0].timestamp);
$("#utc_date").html(datum);
// Greenwich Mean Sidereal Time in hours
var GMST = timestampToGMST(data.events[0].timestamp);
$("#gmst").html(GMST);
// Write information to dashboard
var i, j;
var column_count = 1 + station_number;
var txt = "<tr><td colspan='" + column_count + "'>Station</td></tr><tr class='data_buttons'><td></td>";
for (i = 0; i < station_number; i++) {
txt += "<td onclick='getStatus(" + i + ")' class='station_" + i + "'>" + data.events[i].number;}
txt += "</td></tr><tr><td colspan='" + column_count + "'>Distance to shower core in [m]</td></tr><tr><td></td>";
for (i = 0; i < station_number; i++) {
txt += "<td><input type='text' id='core_distance_" + i + "' disabled size=5></td>";
MIPdens[i] = 0;}
txt += "</tr><tr><td colspan='" + column_count + "'>Detector signal in [MIP/m<sup>2</sup>]</td></tr>";
for (j = 0; j < 4; j++) {
txt += "<tr><td align='center' class='detector_" + (j + 1) + "' style='border-radius:2px;'>" + (1 + j) + "</td>";
for (i = 0; i < station_number; i++) {
if (j < detector_number[i]) {
if (data.events[i].pulseheights[j] * data.events[i].integrals[j] !== 0) {
MIPdens[i] = data.events[i].mips[j] + MIPdens[i];
txt += "<td><input id='MIP" + i + "_" + j + "' type='text' value=" + (2 * data.events[i].mips[j]).toFixed(2) + " disabled size=5></td>";}
else {
txt += "<td><input id='MIP" + i + "_" + j + "' type='text' value='no data' style='color:#f33; -webkit-text-fill-color: #f33;' disabled size=5></td>";}}
else {
txt += "<td></td>";}}
txt += "</tr>";}
txt += "<tr><td></td>";
for (i = 0; i < station_number; i++) {
txt += "<td><select id='count" + i + "' onchange='calcMIP()'>";
for (j = detector_number[i]; j > 0; j--) {
txt += "<option value=" + j + ">" + j + "</option>";}
txt += "</select></td>";}
txt += "</tr><tr><td colspan='" + column_count + "'>Station average signal in [MIP/m<sup>2</sup>]</td></tr><tr><td>Data</td>";
for (i = 0; i < station_number; i++) {
txt += "<td><input type='text' id='MIP" + i + "' value=" + (MIPdens[i] / 2).toFixed(2) + " disabled size=5></td>";}
txt += "</tr><tr><td>Calc.</td>";
for (i = 0; i < station_number; i++) {
txt += "<td><input type='text' id='calculated_mip_" + i + "' disabled size=5></td>";
$("#choice").append("<div class='station_" + i + "'>" + data.events[i].number + "</div>");
infoURL[i] = "https://data.hisparc.nl/show/stations/" + data.events[i].number + "/" + datum.substring(0, 4) + "/" + datum.substring(5, 7) + "/" + datum.substring(8, 10) + "/";}
$(txt).appendTo("#coinInfo");
$('<input type="button" value="Send result" id="sendButton" onclick="sendResult()">').appendTo('#info');
$("#choice").on("click", "div", function(event) {showEvent($(this).index());});
makeShowerMap(data);
plotGraph(data);
// interactionTrace(data);
}
function showError(data) {
if (data.status === 0) {
alert('An error occured, try again');}
else {
var json = JSON.parse(data.responseText);
alert(json.message);}
}
function retrieveData() {
var url = BASE_URL + "/get_coincidence/";
// Use local test data
// url = 'examples/jsparc_data_n3.json';
// url = 'examples/jsparc_data_n6.json';
$.getJSON(url, {'session_title': 'example'})
.done(loadData)
.fail(showError);
}
function getExample() {
if (dataflag) {
retrieveData();}
}
$(function() {
// Animate HiSPARC logo during ajax activity
$(document).ajaxStart(function() {$('#pageHeader').addClass('animated');})
.ajaxStop(function() {$('#pageHeader').removeClass('animated');});
$("#sessionHash").val(get_coincidence.session_hash);
$("#exampleButton").click(getExample);
});
</script>
</head>
<body>
<div id="graphs">
<div id="chartdiv" class="coincidencegraph"></div>
<div id="choice"></div>
<div id="tracegraphs"></div>
<div id="tracelegend">
<div class="detector_1">Detector 1</div>
<div class="detector_2">Detector 2</div>
<div class="detector_3">Detector 3</div>
<div class="detector_4">Detector 4</div>
</div>
</div>
<div id="map_data">
<div id="datum">
<div>UTC Date: <span id="utc_date"></span></div>
<div>GMST: <span id="gmst"></span></div>
</div>
<div id="map"></div>
<div id="result">
<div>Latitude: <span id="core_latitude"></span>°</div>
<div>Longitude: <span id="core_longitude"></span>°</div>
<div>Energy: <span id="calculated_energy"></span> eV</div>
<div><a style="font-family: serif;">χ</a><sup>2</sup>: <span id="energy_error"></span></div>
</div>
</div>
<div id="dashboard">
<div id="logo"><a target="_blank" href="https://www.hisparc.nl/"><span id="pageHeader"></span></a></div>
<div id="doc_link">
<a href="https://docs.hisparc.nl/jsparc/jsparc_analysis.html" target="jsparc_doc">➔ Documentation</a>
<a href="index.html">➔ jSparc</a>
</div>
<div id="session_form">
<input type="button" id="exampleButton" value="Get a coincidence">
</div>
<form id="info">
<table id="coinInfo">
</table>
</form>
</div>
</body>
</html>