LunaZodiaco NuGet Package

LunaZodiaco is a F# NuGet package to calculate the moon phase and the moon’s zodiac (ecliptic longitude) at a given day.
It uses Conway’s method to calculate the moon age, which works in the 20th and 21th century and has an accuracy of about 1 day. The zodiac / ecliptic longitude ist calculated using an algorithm of Paul Schlyter - Computing planetary positions - a tutorial with worked examples.

So both values aren’t accurate enough for use in a serious astronomy program, but suitable for a calender like application - the position changes during one day anyway.

You can try LunaZodiaco interactively online using this Jupyter notebook at Binder.

Installation of the NuGet Package

Download an install the LunaZodiaco Nuget package using your IDE (Visual Studio or JetBrains Rider) or one of the command-line possibilities: LunaZodiaco Package at NuGet

In an interactive F# FSI session, you can use the command #r “nuget: LunaZodiaco” to download and use the NuGet package LunaZodiaco.

#r "nuget: LunaZodiaco"
Installed package LunaZodiaco version 0.9.2

Everything is located in the namespace RC.Moon, so lets open that.

To check if everything is working, we try to display the Unicode codepoint of a full moon:

open RC.Moon

MoonPhase.FullMoon.ToUnicode ()
    πŸŒ•οΈ

Module MoonPhase

Types and functions regarding the lunar phase are located in the module MoonPhase.

There is a discriminated union for all 8 lunar phases:

MoonPhase.NewMoon
    Luna nueva
MoonPhase.WaxingCrescent
    Luna creciente
MoonPhase.FirstQuarter
    Cuarto creciente
MoonPhase.WaxingGibbous
    Creciente gibosa
MoonPhase.FullMoon
    Luna Llena
MoonPhase.WaningGibbous
    Menguante gibosa
MoonPhase.LastQuarter
    Cuarto menguante
MoonPhase.WaningCrescent
    Luna menguante

The member ToString and the function MoonPhase.toString both return the Spanish name of the lunar phase.

MoonPhase.NewMoon.ToString ()
    Luna nueva
MoonPhase.toString MoonPhase.NewMoon
    Luna nueva

The member ToUnicode returns the Unicode codepoint of the lunar phase, a symbol. Same as the function MoonPhase.toUnicode.

MoonPhase.FirstQuarter.ToUnicode ()
    πŸŒ“οΈ
MoonPhase.toUnicode MoonPhase.FirstQuarter
    πŸŒ“οΈ

The member ToInt return an integer index of the lunar phase, where 0 is the new moon, 4 is the full moon and 7 waning crescent.

MoonPhase.WaxingGibbous.ToInt ()
    3

The member FromInt and function MoonPhase.fromInt convert an int to a moon phase option, it is the inverse of the function ToInt above.

MoonPhase.fromInt 3
               Value
    Creciente gibosa
MoonPhase.T.FromInt 3
               Value
    Creciente gibosa

Too big or small integers yield None.

MoonPhase.fromInt -6
    None

The function MoonPhase.getInterval and member Interval return the elongation interval of the phase.

The last quarter occures between an elongation angle (between the moon and the sun) of 270 degrees up to, but not including, 315 degrees.

MoonPhase.LastQuarter.Interval ()
    Item1  Item2
      270    315
MoonPhase.getInterval MoonPhase.LastQuarter
    Item1  Item2
      270    315

The inverse function of getInterval is fromAngle, the member function is named FromAngle. This returns the lunar phase to a given elongation angle. Angles in degrees need the measurement ``.

MoonPhase.fromAngle 346.
             Value
    Luna menguante
MoonPhase.T.FromAngle 346.
             Value
    Luna menguante

Module Zodiac

All zodiac related functions the the zodiac type are contained in the module Zodiac.

There is a discriminated union for all 12 zodiacs:

Zodiac.Aries
    Aries
Zodiac.Taurus
    Tauro
Zodiac.Gemini
    GΓ©minis

And so on, until

Zodiac.Aquarius
    Acuario
Zodiac.Pisces
    Piscis

The member ToString and the function Zodiac.toString both return the Spanish name of the lunar phase.

Zodiac.Aries.ToString ()
    Aries
Zodiac.toString Zodiac.Aries
    Aries

The member ToUnicode returns the Unicode codepoint of the zodiac, a symbol. Same as the function Zodiac.toUnicode.

Zodiac.Gemini.ToUnicode ()
    β™Š
Zodiac.toUnicode Zodiac.Gemini
    β™Š

The member ToInt return an integer index of the zodiac, where 0 is the Aries, … and 11 Pisces.

Zodiac.Capricorn.ToInt ()
    9

The member FromInt and function Zodiac.fromInt convert an int to a moon phase option, it is the inverse of the function ToInt above.

Zodiac.fromInt 5
    Value
    Virgo
Zodiac.T.FromInt 5
    Value
    Virgo

Too big or small integers yield None.

Zodiac.fromInt -6
    None

The function Zodiac.getInterval and member Interval return the ecliptic longitude interval of the phase.

Libra occurs in the ecliptic longitude angle of 180 to 210 degrees, including 180 but excluding 210.

Zodiac.Libra.Interval ()
    Item1  Item2
      180    210
Zodiac.getInterval Zodiac.Libra
    Item1  Item2
      180    210

The inverse function of getInterval is fromAngle, the member function is named FromAngle. This returns the zodiac to a given ecliptic longitude angle. Angles in degrees need the measurement ``.

Zodiac.fromAngle 346.
     Value
    Piscis
Zodiac.T.FromAngle 346.
     Value
    Piscis

Module LunaZodiaco

This module contains the moon phase and zodiac calculations and the type MoonDay, that holds the zodiac and lunar phase for a given date.

let moonDay = { LunaZodiaco.MoonDay.Phase = MoonPhase.WaningGibbous; LunaZodiaco.Zodiac = Zodiac.Capricorn }
moonDay
        Phase                Zodiac
    Menguante gibosa    Capricornio

MoonDay does have the member ToStrings and function LunaZodiaco.toStrings, that return a tuple of strings

LunaZodiaco.toStrings moonDay
            Item1             Item2
    Menguante gibosa    Capricornio
moonDay.ToStrings ()
            Item1             Item2
    Menguante gibosa    Capricornio

And the member ToString, that returns a single string.

moonDay.ToString ()
    { Phase = WaningGibbous
      Zodiac = Capricorn }

The function LunaZodiaco.toUnicode returns the moon phase and zodiac as a tuple of Unicode code points / symbols:

LunaZodiaco.toUnicode moonDay
       Item1  Item2
    πŸŒ–    β™‘
moonDay.ToUnicode ()
    Item1  Item2
       πŸŒ–    β™‘

The member ToIntervals and the function LunaZodiaco.toIntervals return the elongation angle and the ecliptic longitude angle interval of the moon phase and zodiac as a tuple.

LunaZodiaco.toIntervals moonDay
        Item1           Item2
    ( 225, 270 )    ( 270, 300 )
moonDay.ToIntervals ()
        Item1           Item2
    ( 225, 270 )    ( 270, 300 )

Calculation of Moon Age and Ecliptic Longitude

The function LunaZodiaco.computeMoonPhase returns the moon phase interval of the moon at a given date, with an accuracy of +/- one day. Attention: it only works in the 20th and 21st century, as it uses Conways algorithm to calculate the moon age (the day of the moon in one lunar cycle of 29 days).

open System
LunaZodiaco.computeMoonPhase (DateTime (2021, 05, 06))
    Item1  Item2
      315    360

THe function LunaZodiaco.computeLongitude calculates the ecliptic longitude of the moon at the given day (well, an angle that it has during the day).

LunaZodiaco.computeLongitude (DateTime (2021, 05, 06))
    340.9314455776453

To get the moon phase and moon zodiac of a day, use the function LunaZodiaco.getMoonDay, that returns the moon phase and the zodiac as a MoonDay record.

LunaZodiaco.getMoonDay (DateTime (2021, 05, 06))
         Phase        Zodiac
    Luna menguante    Piscis

© 2021 Roland Csaszar, licensed under the MIT license.