suncalc3 icon indicating copy to clipboard operation
suncalc3 copied to clipboard

Moon Illumination phaseValue is not continuous

Open jazztunes opened this issue 2 years ago • 2 comments

Problem

It appears that getMoonIllumination.phaseValue is not continuous.

As a test, I wrote a short program that prints out the phaseValue for each minute. Here you can see the phase value takes a big jump between 20:05 and 20:06. I would expect it to be a smooth transition from one minute to the next.

In terms of age, this about 3/4 of a day!

I hope I'm missing something.

--DH

Moon Phase Test Results

2023-01-06T20:01:00.000Z :: 0.4871753060126663 2023-01-06T20:02:00.000Z :: 0.4871768596219541 2023-01-06T20:03:00.000Z :: 0.4871783801686171 2023-01-06T20:04:00.000Z :: 0.4871798676416214 2023-01-06T20:05:00.000Z :: 0.4871813220302154 2023-01-06T20:06:00.000Z :: 0.5128172566761461 2023-01-06T20:07:00.000Z :: 0.5128158684877107 2023-01-06T20:08:00.000Z :: 0.5128145134145109 2023-01-06T20:09:00.000Z :: 0.5128131914662997 2023-01-06T20:10:00.000Z :: 0.5128119026517515

Steps to Reproduce

You can see my test program at: https://jsfiddle.net/jazztunes/6kaz81o7/

jazztunes avatar Dec 01 '23 19:12 jazztunes

Seems like phaseValue > angle changes from negative to +

const phaseValue = 0.5 + 0.5 * inc * (angle < 0 ? -1 : 1) / Math.PI;`

Needs different calculation?

petrospap avatar Jan 26 '24 13:01 petrospap

my test shows

2023-01-06T20:01:00.000Z :: 0.4871753060126663 : inc= 0.08057992883028949 : angle= -0.006864309966472515 phi 3.060794777247738

2023-01-06T20:02:00.000Z :: 0.4871768596219541 : inc= 0.0805701672152393 : angle= -0.0051863596624214855 phi 3.060804564707265

2023-01-06T20:03:00.000Z :: 0.48717838016861714 : inc= 0.08056061333878714 : angle= -0.0035080388833727575 phi 3.0608141438679413

2023-01-06T20:04:00.000Z :: 0.48717986764162136 : inc= 0.08055126727026235 : angle= -0.0018293557850178684 phi 3.060823514660245

2023-01-06T20:05:00.000Z :: 0.4871813220302154 : inc= 0.08054212907721703 : angle= -0.00015031851512667426 phi 3.060832677016437

2023-01-06T20:06:00.000Z :: 0.5128172566761461 : inc= 0.08053319882591041 : angle= 0.0015290647419691848 phi 3.060841630870074

2023-01-06T20:07:00.000Z :: 0.5128158684877107 : inc= 0.08052447658072927 : angle= 0.0032087858174714625 phi 3.0608503761565897

2023-01-06T20:08:00.000Z :: 0.5128145134145109 : inc= 0.08051596240471047 : angle= 0.004888836510851489 phi 3.0608589128127726

2023-01-06T20:09:00.000Z :: 0.5128131914662997 : inc= 0.080507656359133 : angle= 0.006569208629383839 phi 3.060867240777173

2023-01-06T20:10:00.000Z :: 0.5128119026517515 : inc= 0.08049955849849981 : angle= 0.008249895078669037 phi 3.0608753599951353

petrospap avatar Jan 27 '24 12:01 petrospap