-
Notifications
You must be signed in to change notification settings - Fork 1
/
calibrate.html
547 lines (471 loc) · 17.9 KB
/
calibrate.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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
<!doctype html>
<html>
<head>
<title>TAGS: GeoLight Interface</title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false"></script>
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="lib/spin.min.js" type="text/javascript"></script>
<script src="lib/d3.v3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/tablesort.min.js" type="text/javascript"></script>
<script src="lib/Blob.js" type="text/javascript"></script>
<script src="lib/FileSaver.min.js" type="text/javascript"></script>
<script src="lib/google_leaflet.js" type="text/javascript"></script>
<script src="js/cybercommons.js" type="text/javascript"></script>
<script src="js/utilities.js" type="text/javascript"></script>
<script src="js/base.js" type="text/javascript"></script>
<script src="js/log.js"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css">
<link rel="stylesheet" href="css/calibrate.css">
</head>
<body>
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="index.html">TAGS</a>
<ul class="nav">
<li><a href="index.html">Datasets</a></li>
<li><a href="http://animalmigration.org/TAGS/help.htm" target="_new">Help</a></li>
</ul>
<ul class="nav pull-right">
<li><a href=""></a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span12">
<div class="btn-toolbar pull-right shortcuts">
<div class="btn-group">
<button class="btn btn-mini" title="Beginning" data-function="gotoBeginning">
<i class="icon-double-angle-left"></i>
</button>
<button class="btn btn-mini" title="Previous section: left-arrow" data-function="previousSection">
<i class="icon-angle-left"></i>
</button>
<button class="btn btn-mini" title="Next section: right-arrow" data-function="nextSection">
<i class="icon-angle-right"></i>
</button>
<button class="btn btn-mini" title="End" data-function="gotoEnd">
<i class="icon-double-angle-right"></i>
</button>
</div>
<div class="btn-group">
<button class="btn btn-mini" title="Previous error: shift-left-arrow" data-function="gotoPreviousProblem">
<i class="icon-circle-arrow-left"></i>
</button>
<button class="btn btn-mini" title="Next error: shift-right-arrow" data-function="gotoNextProblem">
<i class="icon-circle-arrow-right"></i>
</button>
</div>
<div class="btn-group">
<button class="btn btn-mini" title="Zoom out: z" data-function="zoomOut">
<i class="icon-zoom-out"></i>
</button>
<button class="btn btn-mini" title="Zoom in: x" data-function="zoomIn">
<i class="icon-zoom-in"></i>
</button>
</div>
<div class="btn-group">
<button class="btn btn-mini" title="Settings" data-function="settings" data-toggle="dropdown">
<i class="icon-cog"></i>
</button>
<button href="" class="btn btn-mini" data-toggle="popover"
data-placement="bottom" title="Keyboard Shortcuts"
data-content="
Left arrow: previous section<br>
Right arrow: next section<br><br>
Shift + left arrow: previous error<br>
Shift + right arrow: next error<br><br>
Z: zoom out<br>
X: zoom in<br><br>
O: show +/- 24 hours<br>
P: show points
">
<i class="icon-info-sign"></i>
</button>
<ul class="dropdown-menu pull-right" role="menu" aria-labelledby="dropdownMenu">
<li><a tabindex="-1" href="#overlay" data-function="toggleSurroundingDays">Overlay +/- 24 hours</a></li>
<li><a tabindex="-1" href="#points" data-function="togglePoints">Show individuals data points</a></li>
</ul>
</div>
</div>
<h3><span class="tagname">PABU222150714_curtailed</span> <span class="muted">GeoLight</span></h3>
</div>
</div>
<!--
<div class="row ">
<div class="span12">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<p>
<strong>Instructions</strong>:
Calibrate and clean up your dataset to submit it for processing.<br>
1) Specify a light threshold for twilight events.
2) Review the problem areas and remove erroneous twilight events.<br>
3) Set calibration coordinates and a calibration period for the sun angle, or provide a sun angle.
4) Submit.
</p>
<p>
<strong>Shortcuts</strong>
</p>
</div>
</div>
</div>
-->
<div class="row">
<div class="span12">
<div id="chart">
<div id="activity-indicator">
<div id="activity-spinner"></div>
<p>Loading Dataset</p>
</div>
<!-- placeholder -->
</div>
</div>
</div>
<div class="row">
<div class="span8">
<ul class="nav nav-tabs" id="app-tabs">
<li class="active"><a href="#events-tab" data-toggle="tab">Excluded Events</a></li>
<li><a href="#map-tab" data-toggle="tab" for="map">Locations Map</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="events-tab">
<script type="text/template" id="event-row">
<tr data-datetime={{id}} class="event">
<td data-sort={{id}}><a href="#" data-datetime="{{id}}"><small>{{datetime}}</small></a></td>
<td><small>{{type}}</small></td>
</tr>
</script>
<table class="table table-condensed table-bordered table-striped" id="table-events">
<thead>
<tr>
<th class="event-header">Excluded Events: Date & Time</th>
<th class="no-sort">Event Type</th>
</tr>
</thead>
<tbody>
<tr class="nodata no-sort" data-datetime="0">
<td colspan="2" class="include">No data</td>
</tr>
</tbody>
</table>
</div>
<div class="tab-pane" id="map-tab">
<!-- map placeholder -->
<div id="map"></div>
</div>
</div>
</div> <!-- table span -->
<div class="span4">
<div class="well control-interface">
<div class="form-horizontal error-group">
<div class="control-group">
<label class="control-label" for="threshold" data-toggle="tooltip" data-trigger="manual" data-placement='left' data-error='tooltip' title="Specify a twilight light level threshold">Light Threshold</label>
<div class="controls">
<div class="input-append">
<input type="text" id="threshold-val" class="input-mini">
<button class="btn" id="decrease-threshold">-</a>
<button class="btn" id="increase-threshold">+</a>
</div>
</div>
</div>
</div>
<hr>
<h5>Calibration Coordinates</h5>
<div class="form-horizontal error-group">
<div class="control-group">
<label class="control-label" for="latitude" data-toggle="tooltip" data-trigger="manual" data-placement='left' data-error='tooltip' title="Specify latitude between -90 and 90 and longitude between -180 and 180">Latitude</label>
<div class="controls">
<input type="text" class="span2" name="latitude" placeholder="metadata">
</div>
</div>
<div class="control-group">
<label class="control-label" for="longitude">Longitude</label>
<div class="controls">
<input type="text" class="span2" name="longitude" placeholder="metadata">
</div>
</div>
</div>
<hr>
<h5>Calibration Period <span class="muted">for sun angle</span></h5>
<div class="form-horizontal error-group">
<div class="control-group">
<label class="control-label" for="cal-start-date" data-toggle="tooltip" data-trigger="manual" data-placement='left' data-error='tooltip' title="Specify start and stop dates with an earlier start date">Start Date</label>
<div class="controls">
<input type="text" class="span2" name="cal-start-date" placeholder="select">
</div>
</div>
<div class="control-group">
<label class="control-label" for="cal-stop-date" data-toggle="tooltip" data-trigger="manual" data-placement="left" data-error="tooltip" title="The calibration period must include at least two active twilight events">Stop Date</label>
<div class="controls">
<input type="text" class="span2" name="cal-stop-date" placeholder="select">
</div>
</div>
<div class="control-group">
<label class="control-label">
<i class="icon-refresh icon-spin" id="sun-angle-indicator" style="position:relative;left:0px;top:-4px;"></i>
</label>
<div class="controls">
<a href="" id="compute-sun-angle">Compute sun angle</a><br>
<span class="xor">OR SUPPLY</span>
</div>
</div>
<div class="control-group error-group">
<label class="control-label" for="sun-angle" data-toggle="tooltip" data-trigger="manual" data-placement='left' data-error='tooltip' title="Specify a sun angle or compute from calibration period">Sun Angle</label>
<div class="controls">
<div class="input-append">
<input type="text" class="span2" name="sun-angle" style="width:100px" placeholder="angle">
<span class="add-on" style="min-width:14px;">°</span>
</div>
</div>
</div>
</div>
<hr>
<button class="submit btn btn-primary" id="submit-for-processing" style="position:relative;">
<i class="icon-refresh icon-spin" style="position:absolute;left:8px;top:6px;"></i>
<span class="text">Compute Coordinate Data</span>
</button>
<hr>
<p style="text-align:center;">
<span class="xor">Downloads</span><br>
<a href="#" id="export-csv">Light-Twilight</a> |
<a href="#" id="export-map">Lat-Lng</a> |
<a href="#" id="export-json">All Data</a>
</p>
<!--
<div class="form-horizontal error-group">
<div class="control-group">
<label class="control-label" for="cal-stop-date"></label>
<div class="controls">
<span class="xor">Downloads</span><br>
<a href="#" id="export-csv">Light-Twilight CSV</a><br>
<a href="#" id="export-json">All Data JSON</a><br>
<a href="#" id="export-map">Lat-Lng CSV</a>
</div>
</div>
</div>
-->
<!--
<button class="submit btn btn-success" id="export-data">
Download Data as JSON
</button>
-->
</div> <!-- well -->
</div> <!-- controls span -->
</div> <!-- row -->
</div>
<script type="text/javascript" src="app/app.js"></script>
<script type="text/javascript" src="app/chart.js"></script>
<script type="text/javascript" src="app/calibration.js"></script>
<script type="text/javascript" src="app/twilights.js"></script>
<script type="text/javascript" src="app/map.js"></script>
<script type="text/javascript" src="app/process.js"></script>
<script type="text/javascript" src="app/exporter.js"></script>
<script>
$(document).ready(function() {
//(function() {
"use strict";
var DateFormat = "yy-mm-dd";
// interface preparation
$('#sun-angle-indicator').hide();
$('#submit-for-processing i').hide();
// set up page observers and interactions: data-bindings
$('[data-toggle=popover]').popover({html:true});
// latitude and longitude
app.addObserver('releaseLocation', function(loc) {
$('input[name=latitude]').val(loc[0]);
$('input[name=longitude]').val(loc[1]);
});
$('input[name=latitude]').change(function() {
var loc = app.get('releaseLocation');
loc[0] = $(this).val();
app.set('releaseLocation',loc);
});
$('input[name=longitude]').change(function() {
var loc = app.get('releaseLocation');
loc[1] = $(this).val();
app.set('releaseLocation',loc);
});
// threshold
app.addObserver('threshold', function(t) {
$('#threshold-val').val(t.toFixed(1));
});
$('#increase-threshold').click(function() {
app.set('threshold',app.get('threshold')+0.1);
return false;
});
$('#decrease-threshold').click(function() {
app.set('threshold',app.get('threshold')-0.1);
return false;
});
$('#threshold-val').change(function() {
var t = app.chart.constrainToLightRange( Number($(this).val()) );
app.set('threshold', t);
return false;
});
$('#threshold-val').keydown(function(e) {
if (e.keyCode == 38) {
app.set('threshold',app.get('threshold')+0.1);
} else if (e.keyCode == 40) {
app.set('threshold',app.get('threshold')-0.1);
}
});
// calibration period
app.addObserver('calibrationPeriod', function(r) {
$('input[name=cal-start-date]').val(
$.datepicker.formatDate(DateFormat,r[0])
);
$('input[name=cal-stop-date]').val(
$.datepicker.formatDate(DateFormat,r[1])
);
});
$('input[name=cal-start-date]').change(function() {
var daterange = app.get('calibrationPeriod');
daterange[0] = $(this).datepicker('getDate');
app.set('calibrationPeriod',daterange);
});
$('input[name=cal-stop-date]').change(function() {
var daterange = app.get('calibrationPeriod');
daterange[1] = $(this).datepicker('getDate');
app.set('calibrationPeriod',daterange);
});
// sun angle
app.addObserver('sunangle', function(a) {
$('input[name=sun-angle]').val(a.toFixed(4));
});
$('input[name=sun-angle]').change(function() {
app.set('sunangle',$(this).val());
});
// control group and their appwide keyboard shortcuts
$('[data-function=zoomIn]').click(function() {
app.chart.zoomIn(); return false;
});
$('[data-function=zoomOut]').click(function() {
app.chart.zoomOut(); return false;
});
$('[data-function=previousSection]').click(function() {
app.chart.gotoPreviousSection(); return false;
});
$('[data-function=nextSection]').click(function() {
app.chart.gotoNextSection(); return false;
});
$('[data-function=gotoBeginning]').click(function() {
app.chart.gotoBeginning(); return false;
});
$('[data-function=gotoEnd]').click(function() {
app.chart.gotoEnd(); return false;
});
$('[data-function=gotoPreviousProblem]').click(function() {
app.twilights.gotoPreviousProblem(); return false;
});
$('[data-function=gotoNextProblem]').click(function() {
app.twilights.gotoNextProblem(); return false;
});
$('[data-function=toggleSurroundingDays]').click(function() {
app.chart.toggleSurroundingDays(); return false;
});
$('[data-function=togglePoints]').click(function() {
app.chart.togglePoints(); return false;
});
$(document).keydown(function(e) {
if ($('*:focus').prop('tagName') == 'INPUT' )
return;
if (e.which == 37 || e.which == 39) {
e.preventDefault(); // left or right key
if (e.shiftKey) {
if (app.get('problems').length == 0) return;
if (e.which == 37) app.twilights.gotoPreviousProblem();
if (e.which == 39) app.twilights.gotoNextProblem();
} else {
if (e.which == 37) app.chart.gotoPreviousSection();
if (e.which == 39) app.chart.gotoNextSection();
}
} else if ( e.which == 88 || e.which == 90 ) {
e.preventDefault(); // z and x keys
if (e.which == 88) app.chart.zoomIn();
if (e.which == 90) app.chart.zoomOut();
} else if ( e.which == 79 || e.which == 80 ) {
e.preventDefault(); // o and p keys
if (e.which == 79) app.chart.toggleSurroundingDays();
if (e.which == 80) app.chart.togglePoints();
}
});
// main progress indicator
var sp, spinner;
app.chart.addObserver('readyState', function(state) {
if ( state == 1) {
sp = document.getElementById('activity-indicator');
spinner = new Spinner({color:'#fff'}).spin(document.getElementById('activity-spinner'));
} else if ( state == 2 ) {
spinner.stop();
sp.parentNode.removeChild(sp);
}
});
app.chart.addObserver('readyState', function(state) {
if ( state == 2 ) {
$('input[name=cal-start-date], input[name=cal-stop-date]').datepicker({
showOtherMonths: true,
selectOtherMonths: true,
defaultDate: new Date(app.chart.domainMin()),
minDate: new Date(app.chart.domainMin()),
maxDate: new Date(app.chart.domainMax()),
dateFormat: DateFormat
});
}
});
// point updating ~ cannot draw all points simultaneously
// and datagroup updating ~ optimize
app.addObserver('extent', function() { // should be in charting?
if ( app.chart.pointsVisible() ) {
app.chart.redrawPoints();
}
});
// processing
$('#compute-sun-angle').click(function() {
app.process.sunAngle();
return false;
});
$('#submit-for-processing').click(function() {
app.process.locations();
return false;
});
// exporting / downloads
$('#export-csv').click(function(d) {
app.exporter.exportCsv(app.exporter.tildeData());
return false;
});
$('#export-json').click(function(d) {
app.exporter.exportJson(app.exporter.tildeData());
return false;
});
$('#export-map').click(function(d) {
app.exporter.exportMapCsv(_.clone(app.get('birdLocations')));
return false;
});
// clear error on input label once editing begins
$('input').focus(function() {
$(this).parents('.error-group')
.find('label[data-error=tooltip]')
.tooltip('destroy');
});
function loadChart(filename) {
//app.chart.load("/datasets/"+filename);
$('.tagname').text(filename);
app.chart.load(filename); // error checking
}
// load the dataset for visualization // ?callback=? jsonp
loadChart(window.location.hash.slice(1));
});
</script>
</body>
</html>