Time
The Time submodule contains common time transformations such as converting between different date representations or converting a specific instant in time between different time systems.
The module also defines the Epoch
class which provides the standard representation of instants in time used throughout the module.
Most of the transformations are make backend calls to the SOFA C-library functions provide the package SOFA.jl
SatelliteDynamics.caldate_to_mjd
— FunctionConvert a Gregorian calendar date to the equivalent Modified Julian Date representation of that time instant.
Aguments:
year::Integer
Yearyear::Integer
Monthyear::Integer
Dayhour::Integer
Hourminute::Integer
Minutesecond::Real
Secondsnanoseconds::Real
Nanoseconds
Returns:
mjd::Float64
Modified Julian Date of Epoch
SatelliteDynamics.mjd_to_caldate
— FunctionConvert a Modified Julian Date to the equivalent Gregorian calendar date representation of the same instant in time.
Aguments:
mjd::Real
: Modified Julian Date of Epoch
Returns:
year::Int
: Yearyear::Int
: Monthyear::Int
: Dayhour::Int
: Hourminute::Int
: Minutesecond::Float64
: Secondsnanoseconds::Float64
: Nanoseconds
SatelliteDynamics.caldate_to_jd
— FunctionConvert a Gregorian calendar date to the equivalent Julian Date representation of that time instant.
Aguments:
year::Integer
: Yearyear::Integer
: Monthyear::Integer
: Dayhour::Integer
: Hourminute::Integer
: Minutesecond::Real
: Secondsnanoseconds::Real
: Nanoseconds
Returns:
mjd::Float64
: Julian Date of Epoch
SatelliteDynamics.jd_to_caldate
— FunctionConvert a Julian Date to the equivalent Gregorian calendar date representation of the same instant in time.
Aguments:
jd::Real
: Julian Date of Epoch
Returns:
year::Int
: Yearyear::Int
: Monthyear::Int
: Dayhour::Int
: Hourminute::Int
: Minutesecond::Float64
: Secondsmicrosecond::Float64
: Nanoseconds
SatelliteDynamics.elapsed_from_epoch
— FunctionCompute the number of elapsed seconds since a given Epoch from the day number. Can be used to compute the elapsed time since a given Julian or Modified Julian Date.
Arguments:
day_number::Real
: Day number, can contain fractional days. Asummes all days are a uniform 86400.0 seconds in length.day_epoch::Real
: Modified Julian Date of Epoch
Returns:
t::Float
: Number of elapsed seconds between the Provided Modified Julian date and the epoch.
SatelliteDynamics.days_from_elapsed
— FunctionComputes the day number in a given time scale given the elapsed time since epoch and the epoch itself.
Assumes all days are counted using a uniform 86400.0 seconds over the time span.
Arguments:
t::Real
: Elapsed seconds since theday_epoch
.day_epoch::Real
: Day number of the epoch. Common values areSatelliteDynamics.MJD_ZERO
(to get the Julian Day number) orSatelliteDynamics.MJD2000
(to get Modified Julian Days if reckoning time from January 1, 2000 0H)
Returns:
days::Float
: Number of elapsed days in the time scale.
SatelliteDynamics.time_system_offset
— FunctionCompute the offset between two time systems at a given Epoch.
The offset (in seconds) is computed as:
time_system_offset = tsys_dest - tsys_src
The value returned is the number of seconds that musted be added to the source time system given the input epoch, to get the equivalent epoch.
Conversions are accomplished using SOFA C library calls. Epoch.
Arguments:
jd::Real
: Part 1 of two-part date (Julian days)fd::Real
: Part 2 of two-part date (Fractional days)tsys_src::String
: Base time systemtsys_dest::String
: Destination time system
Returns:
offset::Float
: Offset between soruce and destination time systems in seconds.
SatelliteDynamics.Epoch
— TypeThe Epoch
type represents a single instant in time. It is used throughout the SatelliteDynamics module. It is meant to provide a clear definition of moments in time and provide a convenient interface display time in various representations as well as in differrent time systems. The internal data members are also chosen such that the representation maintains nanosecond-precision in reprersenation of time and doesn't accumulate floating-point arithmetic errors larger than nanoseconds even after centuries.
Supports +
, +=
, -
, and -=
operators. Two Epoch's can be differenced to return the time difference between two Epochs. If adding a Real
number it is interpreted as an offset in seconds to add to the Epoch.
The class also supports all arithmetic operators: ==
, !=
, <
, <=
, >
, >=
Arguments:
year::Int
Yearyear::Int
Monthyear::Int
Dayhour::Int
Hour (optional)minute::Int
Minute (optional)second::Real
Seconds (optional)nanoseconds::Real
Nanoseconds (optional)tsys::String
: Time system of the epoch at initialization
The Epoch class can be also be initialized from a string. Examples of Valid String constructors are:
epc = Epoch("2018-12-20")
epc = Epoch("2018-12-20T16:22:19.0Z")
epc = Epoch("2018-12-20T16:22:19.123Z")
epc = Epoch("2018-12-20T16:22:19.123456789Z")
epc = Epoch("2018-12-20T16:22:19Z")
epc = Epoch("20181220T162219Z")
epc = Epoch("2018-12-01 16:22:19 GPS")
epc = Epoch("2018-12-01 16:22:19.0 GPS")
epc = Epoch("2018-12-01 16:22:19.123 GPS")
epc = Epoch("2018-12-01 16:22:19.123456789 GPS")
SatelliteDynamics.caldate
— FunctionReturn the Gregorian calendar date for a specific
Arguments:
epc::Epoch
: Input epochtsys::String
: Time system to compute output in.
Returns:
year::Int
: Year of epochmonth::Int
: Month of epochday::Int
: Day of epochhour::Int
: Hour of epochminute::Int
: Minute of epochsecond::Int
: Second of epochnanoseconds::Int
: Year of epoch
SatelliteDynamics.jd
— FunctionCompute the Julian Date for a specific epoch
Arguments:
epc::Epoch
: Epochtsys::String
: Time system to return output in
Returns:
jd::Real
: Julian date of the epoch in the requested time system
SatelliteDynamics.mjd
— FunctionCompute the Modified Julian Date for a specific epoch
Arguments:
epc::Epoch
: Epochtsys::String
: Time system to return output in
Returns:
mjd::Real
: Julian date of the epoch in the requested time system
SatelliteDynamics.day_of_year
— FunctionReturn the day-of-year number for a given Epoch
.
January 1 0h of each year will return 1.
Arguments:
epc::Epoch
: Epochtsys::String
: Time system to return output in
Returns:
doy::Real
: Day of year number.
SatelliteDynamics.gmst
— FunctionCompute the Greenwich Mean Sidereal Time for the given Epoch.
Arguments:
epc::Epoch
: Epochuse_degrees::Bool
: Return output in degrees (Default: false)
Returns:
gmst::Real
: Greenwich Mean Sidereal Time [rad/deg]
SatelliteDynamics.gast
— FunctionCompute the Greenwich Mean Sidereal Time for the given Epoch.
Arguments:
epc::Epoch
: Epochuse_degrees::Bool
: Return output in degrees (Default: false)
Returns:
gast::Real
: Greenwich Apparent Sidereal Time [rad/deg]
SatelliteDynamics.epoch_to_jdfd
— FunctionCompute the two-part date format used by SOFA.jl functions forr a given Epoch.
Arguments:
epc::Epoch
: Epochtsys::String
: Time system to return output in
Returns:
d1::Real
: First part of two part date. [days]d2::Real
: Second part of two part date. [days]