-
Notifications
You must be signed in to change notification settings - Fork 3
/
aladin.html
642 lines (557 loc) · 20.8 KB
/
aladin.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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<meta charset="utf-8"/>
<title>Aladin Lite finding chart</title>
<link rel='stylesheet' href='https://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.css' />
<script type='text/javascript' src='https://code.jquery.com/jquery-1.9.1.min.js' charset='utf-8'></script>
<!--
<script type='text/javascript' src='https://aladin.u-strasbg.fr/AladinLite/api/v2/latest/aladin.min.js' charset='utf-8'>
-->
<!-- Try a local copy of aladin source -->
<script type='text/javascript' src='aladin-local.js' charset='utf-8'>
</script>
<script type='text/javascript' src='vizier_mirrors.js' charset='utf-8'></script>
<!-- Functions for Aladin Lite finder interface. The version string here is
present to force browsers to load the file if we make changes, and update
the version string here. It is not used in the script. -->
<script type='text/javascript' src='aladin-tess.js?version=1.12' charset='utf-8'></script>
<!-- DOMPurify library for sanitizing URL params, https://github.com/cure53/DOMPurify -->
<script type='text/javascript' src='src/purify.min.js'></script>
<!-- Some styling for aligning equations at = sign, based on
https://stackoverflow.com/questions/22763127/aligning-text-on-a-specific-character -->
<style>
.equation div {
display: flex;
width: 60%;
}
.equation div span {
flex: 1;
}
.equation div span:first-of-type {
text-align: right;
padding-right: 5px;
font-style: italic;
}
.equation div span:last-of-type {
padding-left: 5px;
}
<!-- Prevent browser from flagging initial field as invalid with red border-->
input {
border:none;
box-shadow:none;
}
input:invalid {
box-shadow:none;
}
input.fov-box {
width: 2.5em;
height: 1.5em;
text-align: right;
}
</style>
</head>
<body>
<div id='checkboxes' style='text-align: center; width: 100%; margin-bottom: 10px; margin-top: 10px;'>
<span id="tic-group" style="white-space:nowrap;">
<input type="checkbox" id="tic" onclick="toggleElements(this)">
<label for="tic"><span id='tic-N-sources'></span> TIC sources within 5'
<!-- Legend symbol, initially hidden -->
<svg width="15" height="15" viewBox="0 0 15 15" style="align: center">
<path id="tic-legend" d="M 3 6 L 12 15 M 3 15 L 12 6"
style="fill:none;stroke-width:2.0;stroke:none;" />
</svg>
</label>
</span>
<span id="gaia-blend-group" style="white-space:nowrap;">
<input type="checkbox" id="gaia" onclick="toggleElements(this)">
<label for="gaia" id="gaia-blend-label"><span id='gaia-blends-N-sources'></span> Possibly-blending Gaia DR3 sources within 2.5' for depth
<input type="number" id="depth-input" size="5" step="0.1" min="0"
oninput="setTimeout(changeGaiaNeighbors(this.value),200)"> ppt
<!-- Legend symbol, initially hidden -->
<svg width="15" height="15" viewBox="0 0 15 15" style="align: center">
<rect id="gaia-legend" width="9" height="9" x="3" y="5"
style="fill:none;stroke-width:2.0;stroke:none;" />
</svg>
<!-- Link to apertures file, url is populated dynamically, initially hidden -->
<span id="aij-link-span" style="display: none"><a href="#" id="aij-link"></a></span>
</label>
</span>
<span id="gaia-group" style="white-space:nowrap;">
<input type="checkbox" id="gaiaAll" onclick="toggleElements(this)">
<label for="gaiaAll">All <span id='gaia-N-sources'></span> Gaia DR3 sources within 5'
<!-- Legend symbol, initially hidden -->
<svg width="15" height="15" viewBox="0 0 16 16" style="align: center">
<circle id="gaiaAll-legend" r="6" cx="7.5" cy="9"
style="fill:none;stroke-width:2.0;stroke:none;" />
</svg>
</label>
</span>
<span id="simbad-group" style="white-space:nowrap;">
<input type="checkbox" id="simbad" onclick="toggleElements(this)">
<label for="simbad">Simbad sources
<!-- Legend symbol, initially hidden -->
<svg width="16" height="16" viewBox="0 0 17 17">
<polygon id="simbad-legend" points="7,4 14,16 2,16"
style="fill:none;stroke-width:2.5;stroke:none;" />
</svg>
</label>
</span>
<span id="eb-group" style="white-space:nowrap;">
<input type="checkbox" id="ebs" onclick="toggleElements(this)">
<label for="ebs"><span id='gaia-ebs-N-sources'></span> Gaia
EBs
<!-- Legend symbol, initially hidden -->
<svg width="16" height="16" viewBox="0 0 17 17">
<polygon id="ebs-legend" points="7,4 14,16 2,16"
style="fill:none;stroke-width:2.5;stroke:none;" />
</svg>
</label>
</span>
<span id="var-group" style="white-space:nowrap;">
<input type="checkbox" id="vars" onclick="toggleElements(this)">
<label for="vars"> <span id='gaia-vars-N-sources'></span> Gaia vars
<!-- Legend symbol, initially hidden -->
<svg width="16" height="16" viewBox="0 0 17 17">
<polygon id="vars-legend" points="8,2 9,2 15,8.5 9,15 8,15 2,8.5"
style="fill:none;stroke-width:2.5;stroke:none;" />
</svg>
</label>
</span>
<span style="white-space:nowrap;" id="tess-ffi-group">
TESS FFI layer opacity:
<input id='ffi_slider' style='vertical-align:middle;width:10vw;' step='0.01'
min='0' max='1' type='range' value='0.00'>
<span id='ffiAlpha'>0.00</span>
</span>
<span id='surveys' style="white-space:nowrap;">
Images:
<input type="radio" id="panstarrs-button" name="survey" value="P/PanSTARRS/DR1/color-z-zg-g"
onclick="aladin.setImageSurvey(value)"><label for="panstarrs" id="panstarrs-label">Pan-STARRS</label>
<input type="radio" id="dss-button" name="survey" value="P/DSS2/color"
onclick="aladin.setImageSurvey(value)"><label for="dss2" id="dss-label">DSS2</label>
<input type="radio" id="sdss-button" name="survey" value="P/SDSS9/color"
onclick="aladin.setImageSurvey(value)"><label for="sdss" id="sdss-label">SDSS</label>
</span>
<span style="white-space:nowrap;" id="fov-controls">
<span class="with_tooltip"
data-tippy-content="Show outline of detector size">
<input type="checkbox" id="fov-toggle">
<label for="fov-toggle"> Detector outline
</label></span>
<span id="fov-params" style="display:none">:
<label for="fov-width">Width:</label> <input id="fov-width" class="fov-box" oninput="setTimeout(changeFovPars,300,this.value,'width')"> '
<label for="fov-height">Height:</label> <input id="fov-height" class="fov-box" oninput="setTimeout(changeFovPars,300,this.value,'height')"> '
<label for="fov-PA">PA:</label> <input id="fov-PA" class="fov-box"
oninput="setTimeout(changeFovPars,300,this.value,'PA')"> °
<button onclick="copyCoords()" class="button_tooltip"
data-tippy-content="Copy coords to clipboard">⇒📋<span class="confirmation" data-tippy-content="Coords copied!"></span></button>
</span>
</span>
</div>
<div id='aladin-lite-div' style='width: 100%; height: 95%' onclick='mouseToRaDec(event,true)'></div>
<script type='text/javascript' charset='utf-8'>
// Get params from URL
const urlParams = new URLSearchParams(window.location.search);
// Function to make sure params are clean:
function cleanUrlParam(p) {
return DOMPurify.sanitize(urlParams.get(p));
}
// Vizier mirrors are having issues; temporarily change
// default to Strasbourg server, don't query mirrors or
// used cached server value:
var vizierServer = 'https://vizier.u-strasbg.fr/';
// This is our default value; may get changed below:
//var vizierServer = 'https://vizier.cfa.harvard.edu/';
// If the Vizier URL is already cached, use it. Otherwise, set a
// default value and then asynchronously query for the nearest mirror.
// It may not be set by the time we make our first Vizier query, but
// it will be there for next time:
// if (localStorage.getItem('VizierURL')) {
// // Do a sanity check to make sure that the stored value
// // actually seems like a URL before setting:
// const myURL = localStorage.getItem('VizierURL');
// if (/https.*vizier.*/.test(myURL)) {
// console.log('Using saved server ' + myURL);
// vizierServer = myURL;
// } else {
// localStorage.removeItem('VizierURL');
// setVizier();
// }
// } else {
// // Start the query:
// setVizier();
// }
// Override the saved value if needed for testing:
if (urlParams.has('ip')) {
setVizier(cleanUrlParam('ip'));
}
// A few numbers we will use:
const gaiaRadius = 2.5/60;
const fieldSize = 40/60;
// Some constants we'll use throughout:
const ms2year = 1/(365.242189 * 86400 * 1000);
const mas2deg = 1/(3600*1000.);
const deg2rad = Math.PI / 180;
// Parse URL params, with defaults for each.
// First and most important is to make sure we have the field
// center coordinates - we can't do much without them. Often
// they will be passed as part of the URL parameters, but if
// not, we'll have to resolve the name and wait until that
// completes before we can do anything else.
var have_center_coords = false;
var ra_center = null;
var dec_center = null;
var ra_string = null;
var starname = '';
var tic_number = 0;
var tic_number_full; // Possibly includes trailing .01, etc.
var Tmag = '';
if (urlParams.has('mag')) {
Tmag = parseFloat(cleanUrlParam('mag'));
// The parameter could have been empty, so make sure we
// actually got a number:
if (isNaN(Tmag)) {
Tmag = '';
}
}
// If no depth is passed, we leave it set to 'null' which can be used
// as a boolean later for whether to show that part of the interface.
var depth = null;
if (urlParams.has('depth')) {
depth = parseFloat(cleanUrlParam('depth'));
}
/* Now get the delta mag we want, based on the depth of the transit.
Depth is in ppt, so convert and find as a delta mag. If depth is
not (yet) defined use a large depth that won't yield any blends.
If depth is defined later, this should be updated as well. */
var depthDeltaMag = -2.5*Math.log10((depth || 1E10)/1000.);
if (urlParams.has('name')) {
starname = cleanUrlParam('name');
// Get just the number; first drop the leading 'TIC':
if (starname.match(/TIC/)) {
tic_number_full = starname.replace(/^TIC */, '');
// Then possibly trailing .01, .02 etc., which ExoFOP doesn't like:
tic_number = tic_number_full.split('.')[0];
}
// Just cosmetic, but if there is no space between the 'TIC' and the
// number, add it in:
if (starname.match(/^TIC\d/)) {
starname = starname.replace('TIC', 'TIC ');
}
document.title = starname;
}
// Regex for sexagesimal coord string: three sets of digits, separated
// by at least one colon or space, with optional extra whitespace. The
// \1 is a backreference to for the second delimeter to match the
// first, to detect the case of mixing colons and spaces as
// delimiters, since that would cause the parsing code to fail.
let coordRe = /\d+\s*?(:|\s)\s*?\d+\s*?\1\s*?\d+/;
// Regex for a pure number, with optional leading and/or trailing space,
// and optional leading sign. The second part in parentheses is to
// match a case like ".345" with no digit before decimal place.
let numberRe = /^\s*[+-]?(\d+\.?\d*|\.\d+)\s*$/;
if (urlParams.has('ra') && coordRe.test(cleanUrlParam('ra')) &&
urlParams.has('dec') && coordRe.test(cleanUrlParam('dec'))) {
// Convert RA from hours to degrees:
ra_center = sexagesimalToDecimal(cleanUrlParam('ra').trim())*15;
ra_string = '' + ra_center;
dec_center = sexagesimalToDecimal(cleanUrlParam('dec').trim());
if (ra_center && dec_center) {
have_center_coords = true;
} else {
alert("Could not parse entered coordinates: " + cleanUrlParam('ra') +
' ' + cleanUrlParam('dec'));
}
} else if (urlParams.has('ra') && numberRe.test(cleanUrlParam('ra')) &&
urlParams.has('dec') && numberRe.test(cleanUrlParam('dec'))) {
// Use decimal coords from URL. Work around a quirk of Vizier query - if
// RA param is an integer, Vizier interprets it as hours, not
// degrees. Add a decimal point in that case to get correct
// interpretation.
ra_string = cleanUrlParam('ra');
if (! ra_string.includes('.')) {
ra_string = ra_string + '.0';
}
ra_center = parseFloat(ra_string);
dec_center = parseFloat(cleanUrlParam('dec'));
have_center_coords = true;
} else if (urlParams.has('name') && (/\S+/.test(starname))) {
/* Already got name from URL above;
attempt to resolve name into coords. First function
is success callback, second is failure callback.
*/
let matchname;
if (tic_number != 0) {
// Reconstruct TIC name possibly including trailing .01, .02, etc.
// Those can be resolved locally, but won't match in Sesame.
matchname = 'TIC ' + tic_number_full;
} else {
matchname = starname;
}
// Try to resolve coords; this async function will set necessary variables once it succeeds.
resolveCoords(matchname);
} else {
let message = "Must specify either target name ('name') or field RA and Dec ('ra', 'dec') in URL.\n";
message += "If you provided coordinates and still see this message, the coordinates could not be interpreted.";
alert(message);
}
// Are the blending Gaia stars shown initially?
var showGaiaBlends = false;
if (urlParams.has('showBlends')) {
showGaiaBlends = Boolean(parseFloat(cleanUrlParam('showBlends')));
}
// Same idea for the other catalogs:
// Are they shown initially?
var showGaia = false;
if (urlParams.has('showGaia')) {
showGaia = Boolean(parseFloat(cleanUrlParam('showGaia')));
}
var showTIC = false;
if (urlParams.has('showTIC')) {
showTIC = Boolean(parseFloat(cleanUrlParam('showTIC')));
}
var showSimbad = false;
if (urlParams.has('showSimbad')) {
showSimbad = Boolean(parseFloat(cleanUrlParam('showSimbad')));
}
var showEBs = false;
if (urlParams.has('showEBs')) {
showEBs = Boolean(parseFloat(cleanUrlParam('showEBs')));
}
var showVars = false;
if (urlParams.has('showVars')) {
showVars = Boolean(parseFloat(cleanUrlParam('showVars')));
}
// Whether to show Gaia sources that don't match TIC:
var showMismatches = false;
if (urlParams.has('showMismatches')) {
showMismatches = Boolean(parseFloat(cleanUrlParam('showMismatches')));
}
// Thresholds for determining how much mismatch between DR2
// (listed in TIC) and DR3 (used for Gaia catalog) we allow before
// declaring a mismatch of Gaia source:
var gaiaDistThresh = 0.5; // arcsec
var gaiaMagThresh = 0.5;
if (urlParams.has('gaiaDistThresh')) {
gaiaDistThresh = parseFloat(cleanUrlParam('gaiaDistThresh'));
}
if (urlParams.has('gaiaMagThresh')) {
gaiaMagThresh = parseFloat(cleanUrlParam('gaiaMagThresh'));
}
// Default settings for detector FOV outline; LCO 1m is 26' square.
var fov = {
height: 26,
width: 26,
PA: 0,
showing: false,
coord_string: ''};
if (urlParams.has('showFov')) {
fov.showing = Boolean(parseFloat(cleanUrlParam('showFov')));
}
if (urlParams.has('fovHeight')) {
const val = parseFloat(cleanUrlParam('fovHeight'));
// Only assign if a valid number:
if ((val) && (val > 0)) {
fov.height = val;
};
}
if (urlParams.has('fovWidth')) {
const val = parseFloat(cleanUrlParam('fovWidth'));
// Only assign if a valid number:
if ((val) && (val > 0)) {
fov.width = val;
};
}
if (urlParams.has('fovPA')) {
const val = parseFloat(cleanUrlParam('fovPA'));
// Only assign if a valid number; negative OK
if (val) {
fov.PA = val;
};
};
// Colors for different symbols:
const colors = { simbad: "lightblue",
gaiaEBs: "orange",
gaiaVars: "orange",
gaiaBlends: "green",
gaiaAll: "#cc99ff",
centralStar: "#3366FF",
fov: "#FFAAFF",
tic: "#FBB917"};
const gaia_options = {color: 'lightgreen', lineWidth: 1,
opacity: 0.5, name: "Gaia 2.5' circle"};
// Boolean to track if we've finished shifting sources in the TIC:
var TIC_is_done = false;
// Likewise for Gaia:
var gaiaShiftDone = false;
// Save hashes of deltaT and Tmag values for some sources, so
// we can also display them with Gaia sources. These will be
// filled in by shiftCatalogTIC, and indexed by Gaia number.
// We declare them here so they are global.
var deltaT_vals = {};
var Tmag_vals = {};
var TIC_vals = {};
// Globals for various elements of the display. Initially these
// are undefined, but will get set in the various functions
// below that set them up at the appropriate time:
var centralStar = null;
var TIC = null;
var gaiaBlends = null;
var gaiaAll = null;
var Gaia_boundary = null;
var hipsSimbad = null;
var aladin = null;
var field_center = null;
var center_coo = null;
// Since we might still be waiting for coordinates, wrap the
// initialization of the Aladin div and loading of image survey
// in a function that will wait as needed for coordinates.
async function setupAladin() {
// Since we might not have coords yet, need to wait a
// bit before proceeding. But don't keep
// waiting indefinitely - after 10 seconds give up and move on.
let waited = 0;
while ((! have_center_coords) && (waited < 10000)) {
await sleep(100);
waited += 100; // milliseconds
}
if (waited >= 10000) {
alert('Waited 10 seconds and did not resolve coordinates.');
}
// Make sure this includes the string RA due to note above:
field_center = ra_string + ' ' + dec_center;
center_coo = new Coo(ra_center, dec_center);
// As soon as we have the field center, load the div. Pan-STARRS
// is complete down to about -30 but a little jaggy there, so
// back up 1 degree; otherwise use DSS2.
var imageSurvey;
if (dec_center < -29) {
imageSurvey = 'P/DSS2/color';
document.getElementById('dss-button').checked=true;
} else {
imageSurvey = 'P/PanSTARRS/DR1/color-z-zg-g';
document.getElementById('panstarrs-button').checked=true;
}
aladin = A.aladin('#aladin-lite-div', {target: field_center,
fov: fieldSize,
survey: imageSurvey});
// Call the various functions to set up different aspects of the display, now that we
// have the Aladin framework defined:
findSurveyCoverage();
setupCentralStar();
setupTIC();
setupGaia();
setupSimbad();
setupFFI();
setupGaiaEBs();
setupGaiaVars();
setAladinHeight();
createFovCanvas();
redrawFov();
/* To work around an issue with popups sometimes
not working, allow them also to triggered on
mouse hover over an object, but only when the
Shift key is pressed. First, we bind events
to track whether Shift is up or down, and then
we bind the hover event to the popups, checking
on the Shift key boolean.
*/
$(document).keydown(function( event ) {
if ( event.which == 16 ) {
shift_pressed = true;
}
});
$(document).keyup(function( event ) {
if ( event.which == 16 ) {
shift_pressed = false;
}
});
// define function triggered when a source is hovered
aladin.on('objectHovered', function(object) {
// Do nothing unless Shift key is down and
// we have an object:
if ((!object) || (!shift_pressed)) {
return;
}
if (object.hasOwnProperty('catalog')) {
if (object.catalog.name == 'TIC') {
TICpopup(object);
} else if (object.catalog.name.includes('Gaia')) {
gaiaPopup(object);
} else if (object.catalog.name.includes('Central star')) {
view = object.catalog.view;
view.popup.setText(object.popupDesc);
view.popup.setTitle(object.popupTitle);
view.popup.setSource(object);
view.popup.show();
} else if (object.catalog.name.includes('Simbad')) {
simbadPopup(object);
}
}
});
}
// Track whether or not the shift key is down:
var shift_pressed = false;
// Call the above master function that sets everything up:
setupAladin();
$(window).resize(setAladinHeight);
</script>
<!-- Now that all content is loaded, invoke the script to
recognize and style the tooltips. -->
<!-- Library for better tooltips -->
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>
<!-- Style for tooltips: -->
<style>
.tippy-box[data-theme~='purple'] {
background-color: Thistle;
color: #333;
border: 2px solid Indigo;
font-family: "Verdana", sans-serif;
font-size: 100%;
text-align: center;
}
</style>
<script type='text/javascript'>
tippy.setDefaultProps(
{ arrow: true,
placement: 'right',
interactive: true,
theme: 'purple',
allowHTML: true,
delay: [800,200],
animation: 'scale',
}
);
all_tips = tippy('.with_tooltip');
button_tip = tippy('.button_tooltip');
copy_button = tippy('.confirmation', {trigger: 'manual',
duration: [100,1000],
delay: [0,0],
placement: 'auto',
interactive: false,
});
function copyCoords() {
/* Copy FOV coordinates to the system clipboard,
then display a confirmation message.
*/
navigator.clipboard.writeText(fov.coord_string);
// Hide the general tooltip if showing:
button_tip[0].hide;
// Then show, pause, and hide the "copied!" message:
copy_button[0].show();
sleep(800);
copy_button[0].hide();
};
</script>
</body> </html>