edu.wisc.ssec.mcidasv.data.adde.sgp4
Class Time

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.data.adde.sgp4.Time
All Implemented Interfaces:
Serializable

public class Time
extends Object
implements Serializable

Used to keep track of a time and convert to multiple formats.

Author:
Shawn E. Gano
See Also:
Serialized Form

Field Summary
private  GregorianCalendar currentTime
           
static int DATE
          date type
private  DateFormat dateFormat
           
private static DecimalFormat fmt2Dig
           
private static DecimalFormat fmt4Dig
           
static int HOUR
          hour type
static int HOUR_OF_DAY
          Hour type
static int MILLISECOND
          Millisecond type
static int MINUTE
          Minute type
private  double mjd
           
private  double mjde
           
static int MONTH
          month type
static int SECOND
          Second type
private static TimeZone tz
           
private  TimeZone tzStringFormat
           
static int YEAR
          year type
 
Constructor Summary
Time()
          Default Constructor
Time(int year, int month, int day, int hour, int min, double sec)
          Constructor with given calendar date (UT)
 
Method Summary
 void add(int unit, int val)
          Add specified value in specified time unit to current time
 void addSeconds(double seconds)
          Add specified seconds to current time
static double calcMjd(Calendar cal)
          Calculate Modified Julian Date from calendar object
static double calcMjd(int year, int month, int day, int hour, int min, double sec)
          Calculate Modified Julian Date from calendar date and time elements
static GregorianCalendar convertJD2Calendar(double jd)
           
 String convertJD2String(double jd)
           
static double deltaT(double givenMJD)
          Return TT minus UT.
 int get(int field)
          Returns the specified field
 GregorianCalendar getCurrentGregorianCalendar()
           
 DateFormat getDateFormat()
          Gets the date format
 String getDateTimeStr()
           
 double getJulianDate()
          Gets the Julian Date (UT)
 double getMJD()
          Gets the Modified Julian Date (Julian date minus 2400000.5) (UT)
 double getMJDE()
          Gets the Modified Julian Ephemeris Date (Julian date minus 2400000.5) (TT)
static void main(String[] args)
           
 void set(long milliseconds)
          Set the current time (UT) to the number of milliseconds
 void setDateFormat(SimpleDateFormat dateFormat)
          Set SimpleDateFormat for displaying date/time string
 void setDateFormat(String formatStr)
          Set SimpleDateFormat string ISSUE - only valid after Jan 1, 1970
 void setTzStringFormat(TimeZone aTzStringFormat)
          Sets timezone for the output string to use via the function getDateTimeStr()
 void update2CurrentTime()
          Updates the time to current system time
private  void updateTimeMeasures()
          Updates the Julian and Julian Epehermis Dates using Current GregorianCalendar
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YEAR

public static final int YEAR
year type

See Also:
Constant Field Values

MONTH

public static final int MONTH
month type

See Also:
Constant Field Values

DATE

public static final int DATE
date type

See Also:
Constant Field Values

HOUR

public static final int HOUR
hour type

See Also:
Constant Field Values

HOUR_OF_DAY

public static final int HOUR_OF_DAY
Hour type

See Also:
Constant Field Values

MINUTE

public static final int MINUTE
Minute type

See Also:
Constant Field Values

SECOND

public static final int SECOND
Second type

See Also:
Constant Field Values

MILLISECOND

public static final int MILLISECOND
Millisecond type

See Also:
Constant Field Values

currentTime

private GregorianCalendar currentTime

mjd

private double mjd

mjde

private double mjde

fmt4Dig

private static final DecimalFormat fmt4Dig

fmt2Dig

private static final DecimalFormat fmt2Dig

dateFormat

private DateFormat dateFormat

tz

private static final TimeZone tz

tzStringFormat

private TimeZone tzStringFormat
Constructor Detail

Time

public Time()
Default Constructor


Time

public Time(int year,
            int month,
            int day,
            int hour,
            int min,
            double sec)
Constructor with given calendar date (UT)

Parameters:
year - year
month - month (1-12)
day - day of month
hour - hour 0-24
min - minute
sec - second and fraction of second (accurate up to 1 millisecond)
Method Detail

main

public static void main(String[] args)

update2CurrentTime

public void update2CurrentTime()
Updates the time to current system time


set

public void set(long milliseconds)
Set the current time (UT) to the number of milliseconds

Parameters:
milliseconds - number of millisconds as in from the function Calendar.getTimeInMillis()

add

public void add(int unit,
                int val)
Add specified value in specified time unit to current time

Parameters:
unit - int Time unit
val - int Time increment

addSeconds

public void addSeconds(double seconds)
Add specified seconds to current time

Parameters:
seconds - number of seconds to add to current time (can be fractional)

updateTimeMeasures

private void updateTimeMeasures()
Updates the Julian and Julian Epehermis Dates using Current GregorianCalendar


getJulianDate

public double getJulianDate()
Gets the Julian Date (UT)

Returns:
Returns the Julian Date

getMJD

public double getMJD()
Gets the Modified Julian Date (Julian date minus 2400000.5) (UT)

Returns:
Returns the Modified Julian Date

getMJDE

public double getMJDE()
Gets the Modified Julian Ephemeris Date (Julian date minus 2400000.5) (TT)

Returns:
Returns the Modified Julian Ephemeris Date

setTzStringFormat

public void setTzStringFormat(TimeZone aTzStringFormat)
Sets timezone for the output string to use via the function getDateTimeStr()

Parameters:
aTzStringFormat - time zone to format output strings with

setDateFormat

public void setDateFormat(SimpleDateFormat dateFormat)
Set SimpleDateFormat for displaying date/time string

Parameters:
dateFormat - SimpleDateFormat

setDateFormat

public void setDateFormat(String formatStr)
Set SimpleDateFormat string ISSUE - only valid after Jan 1, 1970

Parameters:
formatStr - String format for simple date format to use for creating strings of the date

getDateFormat

public DateFormat getDateFormat()
Gets the date format

Returns:
date format

get

public final int get(int field)
Returns the specified field

Parameters:
field - int The specified field
Returns:
int The field value

getDateTimeStr

public String getDateTimeStr()

calcMjd

public static double calcMjd(Calendar cal)
Calculate Modified Julian Date from calendar object

Parameters:
cal - Calendar object
Returns:
Modified Julian Date (UT)

calcMjd

public static double calcMjd(int year,
                             int month,
                             int day,
                             int hour,
                             int min,
                             double sec)
Calculate Modified Julian Date from calendar date and time elements

Parameters:
year - calendar year
month - calendar month
day - calendar day
hour - calendar hour (0-24)
min - calendar min
sec - calendar sec
Returns:
Modified Julian Date (UT)

deltaT

public static double deltaT(double givenMJD)
Return TT minus UT.

Up to 1983 Ephemeris Time (ET) was used in place of TT, between 1984 and 2000 Temps Dynamique Terrestrial (TDT) was used in place of TT. The three time scales, while defined differently, form a continuous time scale for most purposes. TT has a fixed offset from TAI (Temps Atomique International).

This method returns the difference TT - UT in days. Usually this would be looked up in a table published after the fact. Here we use polynomial fits for the distant past, for the future and also for the time where the table exists. Except for 1987 to 2015, the expressions are taken from Jean Meeus, 1991, Astronomical Algorithms, Willmann-Bell, Richmond VA, p.73f. For the present (1987 to 2015 we use our own graphical linear fit to the data 1987 to 2001 from USNO/RAL, 2001, Astronomical Almanach 2003, U.S. Government Printing Office, Washington DC, Her Majesty's Stationery Office, London, p.K9:

t = Ep - 2002

DeltaT/s = 9.2 * t / 15 + 65

Close to the present (1900 to 1987) we use Schmadl and Zech:

t = (Ep - 1900) / 100

DeltaT/d = -0.000020 + 0.000297 * t + 0.025184 * t2 - 0.181133 * t3
+ 0.553040 * t4 - 0.861938 * t5 + 0.677066 * t6 - 0.212591 * t7

This work dates from 1988 and the equation is supposed to be valid only to 1987, but we extend its use into the near future. For the 19th century we use Schmadl and Zech:

t = (Ep - 1900) / 100

DeltaT/d = -0.000009 + 0.003844 * t + 0.083563 * t2 + 0.865736 * t3
+ 4.867575 * t4 + 15.845535 * t5 + 31.332267 * t6 + 38.291999 * t7
+ 28.316289 * t8 + 11.636204 * t9 + 2.043794 * t10

Stephenson and Houlden are credited with the equations for times before 1600. First for the period 948 to 1600:

t = (Ep - 1850) / 100

DeltaT/s = 22.5 * t2

and before 948:

t = (Ep - 948) / 100

DeltaT/s = 1830 - 405 * t + 46.5 * t2

This leaves no equation for times between 1600 and 1800 and beyond 2015. For such times we use the equation of Morrison and Stephenson:

t = Ep - 1810

DeltaT/s = -15 + 0.00325 * t2

Parameters:
givenMJD - Modified Julian Date (UT)
Returns:
TT minus UT in days

getCurrentGregorianCalendar

public GregorianCalendar getCurrentGregorianCalendar()

convertJD2Calendar

public static GregorianCalendar convertJD2Calendar(double jd)

convertJD2String

public String convertJD2String(double jd)