Astrex.Astro.Dates (Astrex v0.4.1)

View Source

This module provides high accuracy functions to calculate key date values for further astronomical calculations.

  • Greenwhich Mean Standard Time
  • Local Sidereal Time
  • Julian Day with decimal precision (if decimals not required, Timex.to_julian can be used instead)
  • Julian Century

Algorithms and coefficients to calculate GMST and LST have been taken form the following articles:

https://astronomy.stackexchange.com/questions/24859/local-sidereal-time
https://squarewidget.com/astronomical-calculations-sidereal-time/

Summary

Functions

returns the number of the specified date from 31.12.2000

Greenwitch Mean Sidereal Time for a given day/time

returns the julian centuries from 1.1.2000

returns julian day for the given date/time.

Local Sidereal Time for a given day/time receives longitude in DEGREES and date and time as NaiveDateTime struct returns sidereal time expressed in HOURS

Functions

day_number(day)

@spec day_number(%NaiveDateTime{
  calendar: term(),
  day: term(),
  hour: term(),
  microsecond: term(),
  minute: term(),
  month: term(),
  second: term(),
  year: term()
}) :: float()

returns the number of the specified date from 31.12.2000

reference: calculations according to Jean Meeus "Astronomical Algorithms"

         chapter 7 - Julian Day

gmst(dt)

@spec gmst(%NaiveDateTime{
  calendar: term(),
  day: term(),
  hour: term(),
  microsecond: term(),
  minute: term(),
  month: term(),
  second: term(),
  year: term()
}) :: float()

Greenwitch Mean Sidereal Time for a given day/time

site where to confirm the calculation for arbitrary location and current time https://astro.subhashbose.com/siderealtime/?longitude=9.15

julian_century(day)

@spec julian_century(%NaiveDateTime{
  calendar: term(),
  day: term(),
  hour: term(),
  microsecond: term(),
  minute: term(),
  month: term(),
  second: term(),
  year: term()
}) :: float()

returns the julian centuries from 1.1.2000

julian_day(day)

@spec julian_day(%NaiveDateTime{
  calendar: term(),
  day: term(),
  hour: term(),
  microsecond: term(),
  minute: term(),
  month: term(),
  second: term(),
  year: term()
}) :: float()

returns julian day for the given date/time.

reference: calculations according to Jean Meeus "Astronomical Algorithms"

         chapter 7 - Julian Day

receives a NaiveDateTime struct returns a float day.decimals

if decimals are not necessary this can be easily replaced by the function: Timex.to_julian/1

local_sidereal_time(long, dt)

@spec local_sidereal_time(float(), %NaiveDateTime{
  calendar: term(),
  day: term(),
  hour: term(),
  microsecond: term(),
  minute: term(),
  month: term(),
  second: term(),
  year: term()
}) :: float()

Local Sidereal Time for a given day/time receives longitude in DEGREES and date and time as NaiveDateTime struct returns sidereal time expressed in HOURS

Conventions: Longitude is negative east of Greenwich

The following example are time dependent and will return the shown results only in testing environment

Examples

iex> Astrex.Astro.Dates.local_sidereal_time(9.15, Astrex.Common.ndt_now()) |> Astrex.Common.hours2hms
"00:08:11"