Astrex.Astro.Transforms (Astrex v0.5.1)
View SourceThe module exports functions to convert from different coordinates systems
AltAzimuth to Equatorial
Equatorial to AltAzimuth
Ecliptic to Equatorial
Equatorial to Ecliptical
Unless otherwise stated the formulas are implemented according to the Jean Meeus book: "Astronomical Algorithms"
Chapter 13 - Transformation of Coordinates
The following conventions apply:
Longitudes East of Greenwich is POSITIVE: 0° to 180°
Longitudes West of Greenwich is NEGATIVE: 0° to -180°
Azimuth North is 0°
Azimuth East is 90°
Azimuth South is 180°
Azimuth West is 270°
All data need to be expressed in radians, not in degrees or hours
Summary
Functions
Converts from AltAzimth coordinates to Equatorial Celestial coordinates
Converts ecliptical latitude and logitude to equatorial AR / DEC at a given time
Converts from Equatorial Celestial coordinates to AltAzimth coordinates
Converts equatorial AR / DEC to ecliptical latitude and logitude at a given time
Functions
Converts from AltAzimth coordinates to Equatorial Celestial coordinates
according to algorithms from "Practical Astronomy with your calculator"
by Peter Duffet and Jonathan Zwart
Receives: map: Altitude, Azimuth in DEGREES
map: Latitude, Longitude in DEGREES
NaiveDateTime
Returns : map: Right Ascension, Declination in DEGREES
Note: does NOT take refraction into account
Converts ecliptical latitude and logitude to equatorial AR / DEC at a given time
Opposite to eq2ecl, there are no reliable test numbers available Therefore this function can only be tested via round trip together with eq2ecl
Examples
iex> test = %{dec: 25.989, ra: 277.892} # or whatever coordinates
iex> date = Astrex.Common.ndt_now()
iex> Astrex.Astro.Transforms.eq2ecl(test, date) |> Astrex.Astro.Transforms.ecl2eq(date)
%{dec: 25.989000000000008, ra: 277.89199999999994}
PASSES with float operations approximation
Converts from Equatorial Celestial coordinates to AltAzimth coordinates
according to algorithms from "Practical Astronomy with your calculator"
by Peter Duffet and Jonathan Zwart
Receives: map: Right Ascension and Declination in DEGREES
map: Latitude, Longitude in DEGREES
NaiveDateTime
Returns : map: Altitude and Azimuth in DEGREES
Examples:
iex> site = %{lat: 45.52, long: 9.21}
iex> obj = %{ra: 97.3792, dec: 23.1486}
iex> date = ~N[2025-07-09 17:22:00]
iex> Astrex.Astro.Transforms.eq2az(obj, site, date)
%{alt: 9.55870765323566, az: 293.42107862051745}
Note: the example from the book returns az: 68.037813189937 because the azimuth convention
is 0° South. We use 180° for south.
Converts equatorial AR / DEC to ecliptical latitude and logitude at a given time
Receives: RA/DEC expressed in DEGREES Returns: Longitude/Latitude (ecliptical) expressed in DEGREES
Examples
iex> date = ~N[1987-04-10 00:00:00]
iex> obj = %{ra: 116.328942, dec: 28.026183}
iex> Astrex.Astro.Transforms.eq2ecl(obj, date)
%{longitude: 113.215630, latitude: 6.68417} # in degrees
PASSES with float operations approximation