Class TtScaler

java.lang.Object
uk.ac.bristol.star.cdf.TtScaler

public abstract class TtScaler extends 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 final double
    Date of the J2000 epoch (2000-01-01T12:00:00) as a Unix time.
    static final String
    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

    Modifier and Type
    Method
    Description
    int
    compareTt2kMillis(long tt2kMillis)
    Assesses validity of this scaler for a given time.
    long
    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
    Returns the end of the validity range of this scaler in TT milliseconds since J2000.
    static TtScaler[]
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • J2000_UNIXMILLIS

      public static final double J2000_UNIXMILLIS
      Date of the J2000 epoch (2000-01-01T12:00:00) as a Unix time.
      See Also:
    • LEAP_FILE_ENV

      public static final 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:
  • Constructor Details

    • TtScaler

      public TtScaler(double fixOffset, double scaleBase, double scaleFactor, long fromTt2kMillis, long toTt2kMillis)
      Constructor.
      Parameters:
      fixOffset - fixed offset of UTC in seconds from TAI
      scaleBase - MJD base for scaling
      scaleFactor - factor for scaling
      fromTt2kMillis - start of validity range in TT milliseconds since J2000
      toTt2kMillis - end of validity range in TT milliseconds since J2000
  • Method Details

    • 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 of getTtScalers() is suitable and most likely what you want to use here.
      Parameters:
      tt2kMillis - TT time in milliseconds since J2000
      orderedScalers - list of TtScaler instances ordered in time
      i0 - 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 the compareTt2kMillis(long) method; every long tt2kMillis value will be valid for one of the list.
      Returns:
      ordered list of time scalers