Package uk.ac.bristol.star.cdf
Class TtScaler
- java.lang.Object
-
- uk.ac.bristol.star.cdf.TtScaler
-
public abstract class TtScaler extends java.lang.Object
Handles conversions between TT_TIME2000 (TT since J2000.0) and Unix (UTC since 1970-01-01) times. An instance of this class is valid for a certain range of TT2000 dates (one that does not straddle a leap second). To convert between TT_TIME2000 and Unix time, first acquire the right instance of this class for the given time, and then use it for the conversion.An external leap seconds table can be referenced with the "CDF_LEAPSECONDSTABLE" environment variable in exactly the same way as for the NASA library. Otherwise an internal leap seconds table will be used.
- Since:
- 8 Aug 2013
-
-
Field Summary
Fields Modifier and Type Field Description static double
J2000_UNIXMILLIS
Date of the J2000 epoch (2000-01-01T12:00:00) as a Unix time.static java.lang.String
LEAP_FILE_ENV
Environment variable to locate external leap seconds file ("CDF_LEAPSECONDSTABLE").
-
Constructor Summary
Constructors Constructor Description TtScaler(double fixOffset, double scaleBase, double scaleFactor, long fromTt2kMillis, long toTt2kMillis)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTt2kMillis(long tt2kMillis)
Assesses validity of this scaler for a given time.long
getFromTt2kMillis()
Returns the start of the validity range of this scaler in TT milliseconds since J2000.static int
getScalerIndex(long tt2kMillis, TtScaler[] orderedScalers, int i0)
Searches an ordered array of scaler instances for one that is applicable to a supplied TT time.long
getToTt2kMillis()
Returns the end of the validity range of this scaler in TT milliseconds since J2000.static TtScaler[]
getTtScalers()
Returns an ordered list of scalers covering the whole range of times.abstract int
millisIntoLeapSecond(long tt2kMillis)
Indicates whether and how far a given time is into the duration of a leap second.double
tt2kToUnixMillis(long tt2kMillis)
Converts time in milliseconds from TT since J2000 to UTC since 1970 for this scaler.
-
-
-
Field Detail
-
J2000_UNIXMILLIS
public static final double J2000_UNIXMILLIS
Date of the J2000 epoch (2000-01-01T12:00:00) as a Unix time.- See Also:
- Constant Field Values
-
LEAP_FILE_ENV
public static final java.lang.String LEAP_FILE_ENV
Environment variable to locate external leap seconds file ("CDF_LEAPSECONDSTABLE"). The environment variable name and file format are just the same as for the NASA CDF library.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TtScaler
public TtScaler(double fixOffset, double scaleBase, double scaleFactor, long fromTt2kMillis, long toTt2kMillis)
Constructor.- Parameters:
fixOffset
- fixed offset of UTC in seconds from TAIscaleBase
- MJD base for scalingscaleFactor
- factor for scalingfromTt2kMillis
- start of validity range in TT milliseconds since J2000toTt2kMillis
- end of validity range in TT milliseconds since J2000
-
-
Method Detail
-
tt2kToUnixMillis
public double tt2kToUnixMillis(long tt2kMillis)
Converts time in milliseconds from TT since J2000 to UTC since 1970 for this scaler.- Parameters:
tt2kMillis
- TT milliseconds since J2000- Returns:
- UTC milliseconds since Unix epoch
-
getFromTt2kMillis
public long getFromTt2kMillis()
Returns the start of the validity range of this scaler in TT milliseconds since J2000.- Returns:
- validity range start
-
getToTt2kMillis
public long getToTt2kMillis()
Returns the end of the validity range of this scaler in TT milliseconds since J2000.- Returns:
- validity range end
-
compareTt2kMillis
public int compareTt2kMillis(long tt2kMillis)
Assesses validity of this scaler for a given time. The result will be zero if this scaler is valid, negative if the given time is earlier than this scaler's range, and positive if the given time is later than this scaler's range.- Parameters:
tt2kMillis
- TT milliseconds since J2000- Returns:
- validity signum
-
millisIntoLeapSecond
public abstract int millisIntoLeapSecond(long tt2kMillis)
Indicates whether and how far a given time is into the duration of a leap second. If the supplied time falls during a leap second, the number of milliseconds elapsed since the leap second's start is returned. Otherwise (i.e. nearly always) -1 is returned.- Parameters:
tt2kMillis
- TT time in milliseconds since J2000- Returns:
- a value in the range 0...1000 if in a leap second, otherwise -1
-
getScalerIndex
public static int getScalerIndex(long tt2kMillis, TtScaler[] orderedScalers, int i0)
Searches an ordered array of scaler instances for one that is applicable to a supplied TT time. The supplied array of instances must be ordered and cover the supplied time value; the result ofgetTtScalers()
is suitable and most likely what you want to use here.- Parameters:
tt2kMillis
- TT time in milliseconds since J2000orderedScalers
- list of TtScaler instances ordered in timei0
- initial guess at index of the right answer; if negative no best guess is assumed
-
getTtScalers
public static TtScaler[] getTtScalers()
Returns an ordered list of scalers covering the whole range of times. Ordering is by time, as per thecompareTt2kMillis(long)
method; every longtt2kMillis
value will be valid for one of the list.- Returns:
- ordered list of time scalers
-
-