-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
616 lines (581 loc) · 28.8 KB
/
index.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
<html>
<head>
<title>Mars Clock by James Tauber</title>
<script>
// Difference between TAI and UTC. This value should be
// updated each time the IERS announces a leap second.
var tai_offset = 37;
// Last time the above value changed.
var last_leap_second = "1 January 2017";
</script>
<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,700,300,400" rel="stylesheet" type="text/css">
<style>
body {
font-family: "Open Sans", sans-serif;
font-weight: 300;
color: #222;
}
h1, h2 {
margin: 1.5em 0 0;
font-weight: 700;
}
h1 span, h2 span {
font-weight: 300;
color: #666;
font-size: 70%;
}
.container {
width: 960px;
margin: 50px auto;
text-align: center;
}
.clock {
background: #F7F7F7;
width: 250px;
margin: 10px auto;
padding: 5px 10px;
}
.clock h3 {
margin: 0;
font-weight: 300;
}
.clock .time {
font-size: 180%;
}
.clear {
clear: both;
}
.credits {
font-weight: 400;
margin-top: 50px;
font-size: 8pt;
}
a {
color: #222;
}
.column {
float: left;
width: 480px;
}
.explanation-link {
cursor: pointer;
}
.earth-date-input .utc-time {
display: block;
position: relative;
cursor: pointer;
padding: 1px 2px 1px 2px;
margin: 2px;
}
.earth-date-input .utc-time:hover,
.earth-date-input .utc-time:focus {
text-decoration: underline;
}
.earth-date-input .manual-input {
position: relative;
margin: 0 auto;
}
.earth-date-input .custom-datetime {
font: inherit;
padding: 1px 22px 0 2px;
border: none;
border-bottom: dotted 1px #999;
margin: 2px;
}
.earth-date-input .clear-button {
position: absolute;
font-size: 12px;
line-height: 1em;
padding: 7px 2px;
color: #999;
cursor: pointer;
margin-left: -28px;
width: 24px;
overflow: hidden;
}
.earth-date-input .clear-button:hover,
.earth-date-input .clear-button:focus {
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Mars Clock <span>by James Tauber</span></h1>
<p>
This is a live calculation of the time on Mars including mission times for MSL Curiosity and MER-B Opportunity.
</p>
<p>
Also see my much more recent (and gentle) <a href="https://jtauber.github.io/orbits/">Orbits Tutorial</a>.
</p>
<div style="margin-bottom: 50px;">
<a href="https://twitter.com/share" class="twitter-share-button" data-via="jtauber" data-related="jtauber">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<a href="https://twitter.com/jtauber" class="twitter-follow-button" data-show-count="true">Follow @jtauber</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<iframe style="border: 0; margin: 0; padding: 0;"
src="https://www.gittip.com/jtauber/widget.html"
width="48pt" height="20pt"></iframe>
</div>
<div class="column">
<h2>Earth</h2>
<div class="earth-date-input">
<span class="automatic-input">
<a class="utc-time" title="Click here to enter a date"></a>
</span>
<span class="manual-input" style="display:none;">
<input type="datetime" name="custom-datetime" class="custom-datetime" />
<a class="clear-button">⌫</a>
</span>
</div>
<div class="manual-input-invalid" style="display:none;">
<p>Please enter a valid date in a well-known format such as “August 6, 2012”.</p>
</div>
<div class="date-conversion-results">
<div>
<div class="explanation-link" data-explanation="#millis-explanation">
<i>millis</i> = <span class="millis"></span>
</div>
<div class="explanation-link" data-explanation="#jd_ut-explanation">
JD<sub>UT</sub> = <span class="jd_ut"></span>
</div>
<div class="explanation-link" data-explanation="#jd_tt-explanation">
JD<sub>TT</sub> = <span class="jd_tt"></span>
</div>
</div>
<div class="clock explanation-link" data-explanation="#j2000-explanation">
<h3>Days Since J2000 Epoch</h3>
<span class="time j2000"></span>
</div>
<h2>Mars</h2>
<div class="clock explanation-link" data-explanation="#msd-explanation">
<h3>Mars Sol Date</h3>
<div class="time msd"></div>
</div>
<div class="clock explanation-link" data-explanation="#mtc-explanation">
<h3>Coordinated Mars Time</h3>
<div class="time mtc"></div>
</div>
<div class="explanation-link" data-explanation="#m-explanation">
M = <span class="m"></span>°
</div>
<div class="explanation-link" data-explanation="#alpha_fms-explanation">
α<sub>FMS</sub> = <span class="alpha_fms"></span>°
</div>
<div class="explanation-link" data-explanation="#e-explanation">
<i>e</i> = <span class="e"></span>
</div>
<div>
PBS = <span class="pbs"></span>°
</div>
<div class="explanation-link" data-explanation="#nu_m-explanation">
ν - M = <span class="nu_m"></span>°
</div>
ν = <span class="nu"></span>°
<div class="explanation-link" data-explanation="#l_s-explanation">
<i>L</i><sub>s</sub> = <span class="l_s"></span>°<br>
</div>
<div>
EOT = <span class="eot"></span>° = <span class="eot_h"></span>
</div>
<h2>Curiosity<br><span>137.4°E longitude</span></h2>
<div class="clock">
<h3>Mission Sol</h3>
<div class="time curiosity_sol"></div>
</div>
<div class="clock">
<h3>Mission Time (Landing LMST)</h3>
<div class="time curiosity_lmst"></div>
</div>
<div class="clock">
<h3>Local True Solar Time</h3>
<div class="time curiosity_ltst"></div>
</div>
<h2>Opportunity</h2>
<div class="clock">
<h3>Mission Sol</h3>
<div class="time opportunity_sol"></div>
</div>
<div class="clock">
<h3>Mission Time (HLST)</h3>
<div class="time opportunity_mission"></div>
</div>
<div class="clock">
<h3>Local True Solar Time</h3>
<div class="time opportunity_ltst"></div>
</div>
</div>
</div>
<div class="column">
<p class="help">Mouse over a number on the left to get an explanation below<br>(in progress)</p>
<div class="explanation" id="millis-explanation">
<div class="clock">
<h3>Milliseconds since<br>Unix Epoch</h3>
<span class="time millis"></span>
</div>
<p>This is the number of milliseconds since<br>1 January 1970 00:00:00 UTC.</p>
<p>We get this straight from your browser.</p>
</div>
<div class="explanation" id="jd_ut-explanation">
<div class="clock">
<h3>Julian Date (UT)</h3>
<span class="time jd_ut"></span>
</div>
<p>This is the number of days (rather than milliseconds) since a much older epoch than Unix time.</p>
<p>
Rather than an elaborate conversion from the Gregorian date to the Julian date, we just divide
<i>millis</i> by 86,400,000 to get the number of days since the Unix epoch and add that number
to 2,440,587.5, the Julian Date at the Unix epoch.
</p>
<p>JD<sub>UT</sub> = 2,440,587.5 + (<i>millis</i> / 8.64 × 10<sup>7</sup> ms/day)</p>
</div>
<div class="explanation" id="jd_tt-explanation">
<div class="clock">
<h3>Julian Date (TT)</h3>
<span class="time jd_tt"></span>
</div>
<p>
We actually need the Terrestrial Time (TT) Julian Date rather than the UTC-based one.
This means we basically just add the leap seconds which, since
<span class="last_leap_second">?</span> are <span class="tai_offset">?</span> + 32.184.
</p>
<p>JD<sub>TT</sub> = JD<sub>UT</sub> + (<span class="tai_offset">?</span> + 32.184) / 86,400</p>
</div>
<div class="explanation" id="j2000-explanation">
<div class="clock">
<h3>Days Since J2000 Epoch</h3>
<span class="time j2000"></span>
</div>
<p>
This is the number we're going to use as the input to many of our Mars calculations.
It's the number of (fractional) days since<br>12:00 on 1 January 2000<br>in Terrestrial Time.
</p>
<p>
We know what JD<sub>TT</sub> was at the J2000 epoch (2,451,545.0) so it's trivial to convert.
</p>
<p>
Δt<sub>J2000</sub> = JD<sub>TT</sub> - 2,451,545.0
</p>
</div>
<div class="explanation" id="msd-explanation">
<div class="clock">
<h3>Mars Sol Date</h3>
<div class="time msd"></div>
</div>
<p>
The equivalent of the Julian Date for Mars is the Mars Sol Date.
</p>
<p>
At midnight on the 6th January 2000 (Δt<sub>J2000</sub> = 4.5) it was midnight at the Martian
prime meridian, so our starting point for Mars Sol Date is Δt<sub>J2000</sub> − 4.5.
</p>
<p>
The length of a Martian day and Earth (Julian) day differ by a ratio of 1.027491252 so we divide by that.
</p>
<p>
By convention, to keep the MSD positive going back to midday December 29th 1873, we add 44,796.
</p>
<p>
There is a slight adjustment as the midnights weren't perfectly aligned. Allison, M., and M. McEwen 2000 has −0.00072 but
the Mars24 site gives a more up-to-date −0.00096.
</p>
<p>
MSD = ([(Δt<sub>J2000</sub> − 4.5) / 1.027491252] + 44,796.0 − 0.00096)
</p>
</div>
<div class="explanation" id="mtc-explanation">
<div class="clock">
<h3>Coordinated Mars Time</h3>
<div class="time mtc"></div>
</div>
<p>
<i>Coordinated Mars Time</i> (or MTC) is like UTC but for Mars. Because it is just a mean time,
it can be calculated directly from the Mars Sol Date as follows:
</p>
<p>
MTC = (24 h × MSD) mod 24
</p>
</div>
<div class="explanation" id="m-explanation">
<div class="clock">
<h3>Mars Mean Anomaly</h3>
<span class="time"><span class="m"></span>°</span>
</div>
<p>
The mean anomaly is a measure of where an orbiting body is in its orbit. More precisely,
it's a measure of how far into the full orbit the body is since its last periapsis (the point
in the ellipse closest to the focus).
</p>
<p>
The mean anomaly is the ratio (time-wise) into the full orbit, multiplied by 2π (radians) or 360° although the value doesn't truly correspond to any angle. The mean anomaly is proportional to time (and
hence area swept) rather that the actual angle of the body from the
focus (which would be the <i>true anomaly</i>).
</p>
<p>
So the mean anomaly can be calculated from Δt<sub>J2000</sub> if we know the mean
anomaly at the J2000 epoch (19.3870°) and the mean daily motion (360° / length of anomalistic orbit in days).
</p>
<p>
This gives us:
</p>
<p>
M = 19.3870° + 0.52402075°Δt<sub>J2000</sub>
</p>
<p>
for Mars.
</p>
</div>
<div class="explanation" id="alpha_fms-explanation">
<div class="clock">
<h3>Angle of Fictitious Mean Sun</h3>
<span class="time"><span class="alpha_fms"></span>°</span>
</div>
<p>
Mars goes around the Sun, but viewed from Mars's point of view, the Sun goes around Mars.
I'm not talking about the daily motion of the Sun caused by Mars's rotation, but the year-long
motion of the Sun viewed from Mars.
</p>
<p>
Because the orbit is an ellipse, the Sun will go faster some times than others. Imagine a
fictitious Sun, though, that took the same Martian year to go around Mars but which orbited at a
constant angular velocity (the mean of the real Sun). This is the <i>fictitious mean Sun</i>
and it's easier to calculate its angle first because, like the mean anomaly, it is proportional
to time.
</p>
<p>
Based on observations, Allison and McEwen give the angle at J2000 and the daily change (based on
tropical orbit period) as 270.3863° and 0.52403840° / day respectively.
</p>
<p>This gives us:
<p>
α<sub>FMS</sub> = 270.3863° + 0.52403840°Δt<sub>J2000</sub>
</p>
</div>
<div class="explanation" id="e-explanation">
<div class="clock">
<h3>Eccentricity</h3>
<span class="time"><span class="e"></span></span>
</div>
<p>
The eccentricity is the deviation of the orbit's ellipse from being a perfect circle. It varies
ever so slightly over time and for Mars is given by <i>e</i> = 0.09340 + 2.477 × 10<sup>-9</sup> / day Δt<sub>J2000</sub> = <span class="e"></span>.
</p>
</div>
<div class="explanation" id="nu_m-explanation">
<div class="clock">
<h3>Equation of Center</h3>
<span class="time"><span class="nu_m"></span>°</span>
</div>
<p>
The difference between the actual position of the Sun and the fictitious mean Sun is the same as
the difference between the true anomaly and mean anomaly. This is called the <i>Equation of Center</i>.
</p>
<p>
For a two-body Kepler orbit, this difference can be approximated using a Fourier-Bessel series given
the mean anomaly M and eccentricity <i>e</i>. This results in:
</p>
<p>
(10.691° + 3° × 10<sup>-7</sup> Δ<i>t</i><sub>J2000</sub>) sin <i>M</i>
<br>+ 0.623° sin 2<i>M</i>
<br>+ 0.050° sin 3<i>M</i>
<br>+ 0.005° sin 4<i>M</i>
<br>+ 0.0005° sin 5<i>M</i>
</p>
<p>
We're not quite done yet as the above assumes a two-body Kepler motion and we need to include the
perturbations caused by other planets previously calculated.
</p>
<p>Once they have been added, we have our equation of center.</p>
<p>
By adding this to our mean anomaly, M, we also get our true anomaly ν = <span class="nu"></span>°
</p>
</div>
<div class="explanation" id="l_s-explanation">
<div class="clock">
<h3>Areocentric Solar Longitude</h3>
<span class="time"><span class="l_s"></span>°</span>
</div>
<p>
We can now calculate the actual position of the Sun as follows:
</p>
<p>
<i>L</i><sub>S</sub> = α<sub>FMS</sub> + (ν − M)
</p>
<p>
Remember, this is not the daily motion of the Sun caused by Mars's rotation,
but the year-long motion of the Sun viewed from Mars. Think of it as where Mars is in its
orbit around the Sun, flipped around to be from Mars's perspective (hence "areocentric").
</p>
</div>
</div>
<div class="clear"></div>
<div class="credits">
Formulae from
Allison, M., and M. McEwen 2000. <a href="http://pubs.giss.nasa.gov/abs/al05000n.html">A post-Pathfinder evaluation of aerocentric solar coordinates with improved timing recipes for Mars seasonal/diurnal climate studies.</a> <i>Planet. Space Sci.</i> <b>48</b>, 215-235.
and <a href="http://www.giss.nasa.gov/tools/mars24/help/algorithm.html">Mars24 Algorithm and Worked Examples</a>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function cos(deg) {
return Math.cos(deg * Math.PI / 180);
}
function sin(deg) {
return Math.sin(deg * Math.PI / 180);
}
function h_to_hms(h) {
var x = h * 3600;
var hh = Math.floor(x / 3600);
if (hh < 10) hh = "0" + hh;
var y = x % 3600;
var mm = Math.floor(y / 60);
if (mm < 10) mm = "0" + mm;
var ss = Math.round(y % 60);
if (ss < 10) ss = "0" + ss;
return hh + ":" + mm + ":" + ss;
}
function add_commas(n) {
n += "";
var x = n.split(".");
var x1 = x[0];
var x2 = x.length > 1 ? "." + x[1] : "";
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, "$1" + "," + "$2");
}
return x1 + x2;
}
function within_24(n) {
if (n < 0) {
n += 24;
} else if (n >= 24) {
n -= 24;
}
return n;
}
function update() {
var input_date = $(".custom-datetime").val();
if (input_date) {
// Slightly evil but mostly functional date parsing from human input.
// Works reasonably well in most browsers :)
var d = new Date(input_date);
} else {
var d = new Date();
}
if (d.getTime()) {
$(".manual-input-invalid").hide();
$(".date-conversion-results").show();
} else {
$(".manual-input-invalid").show();
$(".date-conversion-results").hide();
}
$(".utc-time").text(d.toUTCString());
var millis = d.getTime();
var jd_ut = 2440587.5 + (millis / 8.64E7);
var jd_tt = jd_ut + (tai_offset + 32.184) / 86400;
var j2000 = jd_tt - 2451545.0;
var m = (19.3870 + 0.52402075 * j2000) % 360;
var alpha_fms = (270.3863 + 0.52403840 * j2000) % 360;
var e = (0.09340 + 2.477E-9 * j2000);
var pbs =
0.0071 * cos((0.985626 * j2000 / 2.2353) + 49.409) +
0.0057 * cos((0.985626 * j2000 / 2.7543) + 168.173) +
0.0039 * cos((0.985626 * j2000 / 1.1177) + 191.837) +
0.0037 * cos((0.985626 * j2000 / 15.7866) + 21.736) +
0.0021 * cos((0.985626 * j2000 / 2.1354) + 15.704) +
0.0020 * cos((0.985626 * j2000 / 2.4694) + 95.528) +
0.0018 * cos((0.985626 * j2000 / 32.8493) + 49.095);
var nu_m = (10.691 + 3.0E-7 * j2000) * sin(m) +
0.623 * sin(2 * m) +
0.050 * sin(3 * m) +
0.005 * sin(4 * m) +
0.0005 * sin(5 * m) +
pbs;
var nu = nu_m + m;
var l_s = (alpha_fms + nu_m) % 360;
var eot = 2.861 * sin(2 * l_s) - 0.071 * sin(4 * l_s) + 0.002 * sin(6 * l_s) - nu_m;
var eot_h = eot * 24 / 360;
var msd = (((j2000 - 4.5) / 1.027491252) + 44796.0 - 0.00096);
var mtc = (24 * msd) % 24;
var curiosity_lambda = 360 - 137.4;
var curiosity_sol = Math.floor(msd - curiosity_lambda / 360) - 49268;
var curiosity_lmst = within_24(mtc - curiosity_lambda * 24 / 360);
var curiosity_ltst = within_24(curiosity_lmst + eot * 24 / 360);
var opportunity_sol_date = msd - 46235 - 0.042431;
var opportunity_sol = Math.floor(opportunity_sol_date);
var opportunity_mission = (24 * opportunity_sol_date) % 24;
var opportunity_ltst = within_24(opportunity_mission + eot * 24 / 360);
$(".millis").text(add_commas(millis));
$(".jd_ut").text(add_commas(jd_ut.toFixed(5)));
$(".jd_tt").text(add_commas(jd_tt.toFixed(5)));
$(".j2000").text(add_commas(j2000.toFixed(5)));
$(".m").text(m.toFixed(5));
$(".alpha_fms").text(alpha_fms.toFixed(5));
$(".pbs").text(pbs.toFixed(5));
$(".e").text(e.toFixed(5));
$(".nu_m").text(nu_m.toFixed(5));
$(".nu").text(nu.toFixed(5));
$(".l_s").text(l_s.toFixed(5));
$(".eot").text(eot.toFixed(5));
$(".eot_h").text(h_to_hms(eot_h.toFixed(5)));
$(".msd").text(add_commas(msd.toFixed(5)));
$(".mtc").text(h_to_hms(mtc));
$(".curiosity_lmst").text(h_to_hms(curiosity_lmst));
$(".curiosity_ltst").text(h_to_hms(curiosity_ltst));
$(".curiosity_sol").text(curiosity_sol);
$(".opportunity_mission").text(h_to_hms(opportunity_mission));
$(".opportunity_ltst").text(h_to_hms(opportunity_ltst));
$(".opportunity_sol").text(opportunity_sol);
}
$(function() {
$(".last_leap_second").text(last_leap_second);
$(".tai_offset").text(tai_offset);
update();
$(".explanation").hide();
setInterval(update, 10);
$(".explanation-link").hover(function() {
$(".explanation").hide();
$(this).css("font-weight", "bold");
$(".help").hide();
$($(this).data("explanation")).show();
}, function() {
$(this).css("font-weight", "300");
$(".help").show();
$($(this).data("explanation")).hide();
});
$('.automatic-input').mouseup(function() {
// Changing the contents of this element so frequently
// stops the click handler from firing, so we need to
// watch for mouseup instead
$('.automatic-input').hide();
$('.manual-input').show();
$('.custom-datetime').select();
});
$('.custom-datetime').blur(function() {
if (! $('.custom-datetime').val()) {
$('.manual-input').hide();
$('.automatic-input').show();
}
});
$('.earth-date-input .clear-button').click(function() {
$('.custom-datetime').val('');
$('.manual-input').hide();
$('.automatic-input').show();
});
});
</script>
<script type="text/javascript">
var _gauges = _gauges || [];
(function() {
var t = document.createElement('script');
t.type = 'text/javascript';
t.async = true;
t.id = 'gauges-tracker';
t.setAttribute('data-site-id', '4f7c4470613f5d112800015d');
t.src = '//secure.gaug.es/track.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(t, s);
})();
</script>
</body>
</html>