org.hermit.astro
Class Instant

java.lang.Object
  extended by org.hermit.astro.Instant
All Implemented Interfaces:
AstroConstants

public class Instant
extends java.lang.Object
implements AstroConstants

A representation of a particular moment in time, with methods to convert between the numerous time systems used in astronomy.

Author:
Ian Cameron Smith

Field Summary
 
Fields inherited from interface org.hermit.astro.AstroConstants
ABERRATION, AU, HALFPI, J1900, J1990, J2000, JD_UNIX, REFRACTION, SECS_PER_DAY, SIDEREAL_RATIO, SIDEREAL_YEAR, TROPICAL_YEAR, TWILIGHT, TWOPI, ε_2000
 
Constructor Summary
Instant(double jd)
          Create an instant from a Julian day number in UT.
Instant(int y, int m, double d)
          Create an instant from a date / time in UT.
Instant(int y, int m, int d, int ho, int mn, int se)
          Create an instant from a date / time in UT.
Instant(long time)
          Create an instant from a Java time in ms since 1 Jan 1970 UTC.
 
Method Summary
static double calculateDeltaT(int year, double month)
          Calculate an estimate of the value of ΔT, ie TD - UT in seconds, for a given moment in time.
static Instant fromTd(double td)
          Create an instant from a Julian day in TD.
static Instant fromTd(int y, int m, double d)
          Create an instant from a date / time in TD.
 double getGmst()
          Get the Greenwich mean sideral time represented by this Instant.
 long getJavaTime()
          Get the Java time in ms since 1 Jan 1970 UTC represented by this Instant.
 double getTd()
          Get the Julian date in TD represented by this Instant.
 double getUt()
          Get the Julian day number in UT represented by this Instant.
 double[] getYmd()
          Convert this instant to year / month / day.
 double getΔT()
          Get the ΔT value for this Instant.
static double gstToLst(double GST, double Λ)
          Deprecated. 
static double gstToUt(double JD, double GST)
          Deprecated. 
static double javaToJulian(long time)
          Convert a date/time in Java notation -- milliseconds since 1 Jan, 1970 -- to the Julian day relative to the astronomical epoch of 4713 BC.
static long julianToJava(double julian)
          Convert a Julian day relative to the astronomical epoch of 4713 BC to the date/time in Java notation -- milliseconds since 1 Jan, 1970.
static double[] julianToYmd(double jd)
          Convert a given Julian day relative to the astronomical epoch of 4713 BC to year / month / day.
static double lstToGst(double LST, double Λ)
          Deprecated. 
static double tdToUt(double jd)
          Convert a given Julian date from TD to UT.
static java.lang.String timeAsHm(java.lang.Double hv)
          Format a decimal time as a string in hours and minutes.
static java.lang.String timeAsHms(java.lang.Double hv)
          Format a decimal time as a string in hours, minutes and seconds.
static double utToGmst(double jd)
          Deprecated. 
static double utToTd(double jd)
          Convert a given Julian date from UT to TD.
static double ymdToJulian(int y, int m, double d)
          Convert a given year / month / day to the Julian day relative to the astronomical epoch of 4713 BC.
static double ymdToJulian(int y, int m, double d, int ho, int mn, int se)
          Convert a given year / month / day to the Julian day relative to the astronomical epoch of 4713 BC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Instant

public Instant(double jd)
Create an instant from a Julian day number in UT.

Parameters:
jd - The date to set as a fractional Julian day number relative to the astronomical epoch of 4713 BC UT.

Instant

public Instant(long time)
Create an instant from a Java time in ms since 1 Jan 1970 UTC. This is the Unix time * 1000.

Parameters:
time - Java-style time in milliseconds since 1 Jan, 1970 UTC.

Instant

public Instant(int y,
               int m,
               double d)
Create an instant from a date / time in UT.

Parameters:
y - Year number; BC years are in astronomical form, so 1 BC = 0, 2 BC = -1, ...
m - Month number; January = 1.
d - Day of the month, including the fraction of the day; e.g. 0.25 = 6 a.m.

Instant

public Instant(int y,
               int m,
               int d,
               int ho,
               int mn,
               int se)
Create an instant from a date / time in UT.

Parameters:
y - Year number; BC years in astronomical form.
m - Month number; January = 1.
d - Day of the month.
ho - Hour.
mn - Minute.
se - Second.
Method Detail

fromTd

public static Instant fromTd(double td)
Create an instant from a Julian day in TD.

Parameters:
td - The date to set as a Julian day number relative to the astronomical epoch of 4713 BC UT, in TD.
Returns:
The new Instant.

fromTd

public static Instant fromTd(int y,
                             int m,
                             double d)
Create an instant from a date / time in TD. THis is mainly useful for running test cases, some of which specify time in TD.

Parameters:
y - Year number; BC years in astronomical form.
m - Month number; January = 1.
d - Day of the month, including the fraction of the day; e.g. 0.25 = 6 a.m.
Returns:
The new Instant.

getUt

public double getUt()
Get the Julian day number in UT represented by this Instant.

Returns:
The Julian day number in UT.

getYmd

public double[] getYmd()
Convert this instant to year / month / day. From AA chapter 7.

Returns:
An array containing year, month, day, where the last value includes the fraction of the day; e.g. 0.25 = 6 a.m.

getTd

public double getTd()
Get the Julian date in TD represented by this Instant.

Note that we don't distinguish between TDT(TT) and TDB, which are always within 0.0017 seconds.

Returns:
The Julian date in TD, in days.

getGmst

public double getGmst()
Get the Greenwich mean sideral time represented by this Instant.

Returns:
The Greenwich mean sideral time in decimal hours.

getJavaTime

public long getJavaTime()
Get the Java time in ms since 1 Jan 1970 UTC represented by this Instant. This is the Unix time * 1000.

Returns:
The time in ms since 1 Jan 1970 UTC.

getΔT

public double getΔT()
Get the ΔT value for this Instant.

Returns:
ΔT in seconds.

utToTd

public static double utToTd(double jd)
Convert a given Julian date from UT to TD.

Note that we don't distinguish between TDT(TT) and TDB, which are always within 0.0017 seconds.

From AA chapter 10.

Parameters:
jd - The Julian date in UT.
Returns:
The Julian date in TD, based on an approximation of ΔT.

tdToUt

public static double tdToUt(double jd)
Convert a given Julian date from TD to UT.

Note that we don't distinguish between TDT(TT) and TDB, which are always within 0.0017 seconds.

From AA chapter 10.

Parameters:
jd - The Julian date in TD.
Returns:
The Julian date in UT, based on an approximation of ΔT.

ymdToJulian

public static double ymdToJulian(int y,
                                 int m,
                                 double d)
Convert a given year / month / day to the Julian day relative to the astronomical epoch of 4713 BC. From AA chapter 7.

Parameters:
y - Year number; BC years in astronomical form.
m - Month number; January = 1.
d - Day of the month, including the fraction of the day; e.g. 0.25 = 6 a.m.
Returns:
The Julian date of the given Y/M/D, relative to the astronomical epoch of 4713 BC.

ymdToJulian

public static double ymdToJulian(int y,
                                 int m,
                                 double d,
                                 int ho,
                                 int mn,
                                 int se)
Convert a given year / month / day to the Julian day relative to the astronomical epoch of 4713 BC. From AA chapter 7.

Parameters:
y - Year number; BC years in astronomical form.
m - Month number; January = 1.
d - Day of the month.
ho - Hour.
mn - Minute.
se - Second.
Returns:
The Julian date of the given Y/M/D, relative to the astronomical epoch of 4713 BC.

julianToYmd

public static double[] julianToYmd(double jd)
Convert a given Julian day relative to the astronomical epoch of 4713 BC to year / month / day. From AA chapter 7.

Parameters:
jd - The Julian date to convert, relative to the astronomical epoch of 4713 BC.
Returns:
An array containing year, month, day, where the last value includes the fraction of the day; e.g. 0.25 = 6 a.m.

javaToJulian

public static double javaToJulian(long time)
Convert a date/time in Java notation -- milliseconds since 1 Jan, 1970 -- to the Julian day relative to the astronomical epoch of 4713 BC.

Parameters:
time - Java-style time in milliseconds since 1 Jan, 1970.
Returns:
The equivalent Julian date relative to the astronomical epoch of 4713 BC.

julianToJava

public static long julianToJava(double julian)
Convert a Julian day relative to the astronomical epoch of 4713 BC to the date/time in Java notation -- milliseconds since 1 Jan, 1970.

Parameters:
julian - A Julian date relative to the astronomical epoch of 4713 BC.
Returns:
The equivalent Java-style time in milliseconds since 1 Jan, 1970.

utToGmst

@Deprecated
public static double utToGmst(double jd)
Deprecated. 

Convert a UT time to Greenwich mean sideral time. From AA chapter 12.

Parameters:
jd - The Julian day number, including fraction.
Returns:
The Greenwich mean sideral time in decimal hours.

gstToUt

@Deprecated
public static double gstToUt(double JD,
                                        double GST)
Deprecated. 

Convert a Greenwich sideral time to UT. NOTE: the sidereal day is shorter than the solar day, so some sidereal times (about the first 4 minutes) occur twice in a given day. This routine assumes that the GST is in the first interval, if it is ambiguous. From PAC section 13, GST to UT.

Parameters:
JD - The Julian date of midnight on the day of the given time.
GST - The Greenwich sideral time in decimal hours.
Returns:
The UT time in decimal hours.

gstToLst

@Deprecated
public static double gstToLst(double GST,
                                         double Λ)
Deprecated. 

Convert a Greenwich sidereal time to local sideral time. From PAC section 14, LST.

Parameters:
GST - The Greenwich sidereal time in decimal hours.
Λ - The observer's geographical longitude in radians; west longitudes negative, east positive.
Returns:
The local sideral time in decimal hours.

lstToGst

@Deprecated
public static double lstToGst(double LST,
                                         double Λ)
Deprecated. 

Convert a local sidereal time to Greenwich sideral time. From PAC section 15, LST to GST.

Parameters:
LST - The local sidereal time in decimal hours.
Λ - The observer's geographical longitude in radians; west longitudes negative, east positive.
Returns:
The Greenwich sideral time in decimal hours.

timeAsHm

public static java.lang.String timeAsHm(java.lang.Double hv)
Format a decimal time as a string in hours and minutes.

Parameters:
hv - The time to format, as fractional hours.
Returns:
The angle formatted in hours and minutes.

timeAsHms

public static java.lang.String timeAsHms(java.lang.Double hv)
Format a decimal time as a string in hours, minutes and seconds.

Parameters:
hv - The time to format, as decimal hours.
Returns:
The angle formatted in hours, minutes and seconds.

calculateDeltaT

public static double calculateDeltaT(int year,
                                     double month)
Calculate an estimate of the value of ΔT, ie TD - UT in seconds, for a given moment in time. This method gives a reasonably good value over the period -1999 to +3000. Reference: Polynomial Expressions for Delta T (ΔT) Espenak and Meeus http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html

Parameters:
year - The year for which we want ΔT.
month - The fractional month; 0.5 = mid-Jan. Does not have to be terribly accurate, given the precision to which the variation in ΔT is known.
Returns:
The value of ΔT for the given year and month.