******************************************************************************
SIMPLE LUNAR PHASE ANGLE TABLE FUNCTION DEMO
Built around the NASA/JPL Horizons API
PHP Program by Jay Tanner - 2025
This program is based on a custom function to generate a simple lunar phase
table over a given range from a single date to multiple dates spanning any
general interval at any given time step size.
This demo program generates a table of the simple geocentric lunar phase
angles for each date of the current month at 00:00:00 UTC on each date.
It is called the 'simple' lunar phase because it is geocentric and based on
the simple difference between the ecliptical longitudes of the moon and sun
at the same moment and excludes the tiny effects of librations, but still
results in a good enough lunar phase approximation for most practical pur-
poses and general small-scale graphical simulations.
-----------------
CALLING TEMPLATE:
PhaseTable = Lunar_Phase_Table (StartDateTimeStr, StopDateTimeStr, StepSize,
TimeZone, DaySumYN, HeaderYN)
*********************************************************
Geocentric Lunar Phase Table
Time Zone = UT+00:00 (dJDate = +0.0000000000)
Day/Summ Time = No
Table Header = Yes
START Date/Time = 2025-Sep-01 00:00:00 (Standard Time)
STOP Date/Time = 2025-Sep-30 00:00:00
Step Size = 1 day
=========================================================
Loc_Date Loc_Time Cnst Julian_Date_UT Phase_Ang
============ ======== ==== ================= =========
2025-Sep-01 00:00:00 Oph 2460919.500000000 98.09354
2025-Sep-02 00:00:00 Sgr 2460920.500000000 109.30849
2025-Sep-03 00:00:00 Sgr 2460921.500000000 120.77806
2025-Sep-04 00:00:00 Sgr 2460922.500000000 132.56036
2025-Sep-05 00:00:00 Cap 2460923.500000000 144.69556
2025-Sep-06 00:00:00 Cap 2460924.500000000 157.19999
2025-Sep-07 00:00:00 Aqr 2460925.500000000 170.06165
2025-Sep-08 00:00:00 Aqr 2460926.500000000 183.23852
2025-Sep-09 00:00:00 Psc 2460927.500000000 196.66112
2025-Sep-10 00:00:00 Psc 2460928.500000000 210.23968
2025-Sep-11 00:00:00 Ari 2460929.500000000 223.87499
2025-Sep-12 00:00:00 Ari 2460930.500000000 237.47055
2025-Sep-13 00:00:00 Tau 2460931.500000000 250.94323
2025-Sep-14 00:00:00 Tau 2460932.500000000 264.22994
2025-Sep-15 00:00:00 Aur 2460933.500000000 277.28969
2025-Sep-16 00:00:00 Gem 2460934.500000000 290.10141
2025-Sep-17 00:00:00 Gem 2460935.500000000 302.65937
2025-Sep-18 00:00:00 Cnc 2460936.500000000 314.96788
2025-Sep-19 00:00:00 Leo 2460937.500000000 327.03683
2025-Sep-20 00:00:00 Leo 2460938.500000000 338.87868
2025-Sep-21 00:00:00 Leo 2460939.500000000 350.50734
2025-Sep-22 00:00:00 Vir 2460940.500000000 1.93859
2025-Sep-23 00:00:00 Vir 2460941.500000000 13.19150
2025-Sep-24 00:00:00 Vir 2460942.500000000 24.29046
2025-Sep-25 00:00:00 Vir 2460943.500000000 35.26710
2025-Sep-26 00:00:00 Lib 2460944.500000000 46.16177
2025-Sep-27 00:00:00 Sco 2460945.500000000 57.02425
2025-Sep-28 00:00:00 Sco 2460946.500000000 67.91363
2025-Sep-29 00:00:00 Oph 2460947.500000000 78.89721
2025-Sep-30 00:00:00 Sgr 2460948.500000000 90.04823
*********************************************************
Table to help visualize the lunar phase angles:
PhaseAng Description
-------- -----------------
0° New Moon
45 Waxing Crescent
90 First Quarter
135 Waxing Gibbous
180 Full Moon
225 Waning Gibbous
270 Last Quarter
315 Waning Crescent
360/0 New Moon
******************************************************************************
To compute the simple geocentric lunar phase angle (0 to 360 deg) based on
the ecliptical longitudes of the moon and sun at the same moment also in the
the range from 0 to 360 degrees:
Let:
PhaseAng = Simple lunar phase angle (0 to 360 deg) based on the
difference between the ecliptical longitudes.
Given:
Lm = Geocentric ecliptical longitude of the moon (0 to 360 deg).
Ls = Geocentric ecliptical longitude of the sun (0 to 360 deg).
Then, the simple phase angle may be found
by one of the following simple algorithms:
----------------------------------------
w = 360 - Lm + Ls
if (w > 360) then w = w - 360
PhaseAng = 360 - w
----------------------------------------
Or, the alternate equivalent:
w = 360 - Lm + Ls
PhaseAng = 360 − (w −= (w > 360)? 360:0)
******************************************************************************