Published
Edited
Dec 22, 2020
Insert cell
md`# Suncalc test

This is an example to demonstrate some issues with the suncalc moon illumination algorithm`
Insert cell
suncalc = require("suncalc@1")
Insert cell
//https://www.timeanddate.com/moon/phases/timezone/utc
// Also verified against the US Naval Observatory list
// Jan 2020 UTC time zone
// 2020-01-03T04:45 first quarter
// 2020-01-10T19:21 full
// 2020-01-17T12:58 last quarter
// 2020-01-24T21:42 new
// Jan 2021
// 2021-01-06T09:37 third quarter
// 2021-01-13T05:00 new
// 2021-01-20T21:01 first quarter
// 2021-01-28T19:16 full

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2020-01-03T04:45'));
let b=suncalc.getMoonIllumination(new Date('2020-01-02T22:15'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2020-01-10T19:21'));
let b=suncalc.getMoonIllumination(new Date('2020-01-10T15:35'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2020-01-17T12:58'));
let b=suncalc.getMoonIllumination(new Date('2020-01-17T09:27'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2020-01-24T21:42'));
let b=suncalc.getMoonIllumination(new Date('2020-01-24T12:50'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2021-01-06T09:37'));
let b=suncalc.getMoonIllumination(new Date('2021-01-06T03:05:58.020'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2021-01-13T05:00'));
let b=suncalc.getMoonIllumination(new Date('2021-01-12T20:19:29.934'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
{
let a=suncalc.getMoonIllumination(new Date('2021-01-20T21:01'));
let b=suncalc.getMoonIllumination(new Date('2021-01-20T15:13:19.914'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell
// 2021-01-06T09:37 third quarter
// 2021-01-13T05:00 new
// 2021-01-20T21:01 first quarter
// 2021-01-28T19:16 full
{
let a=suncalc.getMoonIllumination(new Date('2021-01-28T19:16'));
let b=suncalc.getMoonIllumination(new Date('2021-01-28T15:25'));
return `fraction/phase at USNO time: ${a.fraction} / ${a.phase} \n fraction/phase at time I found: ${b.fraction} / ${b.phase}`;
}

Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more