This page was created by the IDL library routine `mk_html_help2`.

Last modified: Wed Sep 10 18:16:51 2025.

# Directory Listing of Routines

# general/misc/time/TT2000

- ADD_TT2000_OFFSET
- CDF_LEAP_SECOND_INIT
- CRIB_TT2000
- TEST_UNIX_TO_TT2000_VECT
- TT2000_2_UNIX
  Converts TT2000 times to unix times. This function converts the input time
- TT2000_CONFIG_FILEDIR
- TT2000_READ_CONFIG
  Reads the tt2000_config file
- TT2000_WRITE_CONFIG
  Writes the tt2000_config file
- UNIX_TO_TT2000
  Converts unix times to TT2000 times.
- UNIX_TO_TT2000_VECT
  Converts unix times to TT2000 times, as a vectorized alternative to unix_to_tt2000.pro.

# Routine Descriptions

## ADD_TT2000_OFFSET

[Next Routine] [List of Routines]

    Procedure: add_tt2000_offset

    Purpose:
      Takes TDAS double timestamp and offsets date(s) using the data in the CDF 3.4(or later) leap second config file.
      Like time_string and time_double, it is vectorized and accepts array inputs of arbitrary dimensions

    Inputs:
      Dates: If /subtract is not set: double precision seconds since 1970 TAI (Unix timestamp)  Can be scalar or array values with any dimensions or ordering.
             If /subtract is set: double precision seconds since 1970 TT(timestamp TT 1970 epoch) can be scalar or array values with any dimensions or ordering

    Keywords:
      subtract:  If this keyword is set, this function will subtract leap seconds from a TT date that already includes them.

      Offsets: Set this to a named variable in which to return the offsets used for the calculation.  Note that these can differ in both sign and magnitude for
      a particular date, depending on whether you are adding or subtracting.

    Return Value:
      The data with leap seconds added(or removed).

    Notes:
      #1 This routine requires the CDF 3.4 leap second file.  One will be provided with the TDAS install, but it will be updated
      automatically when a new leap second occurs.

      #2 The IDL system variable "!CDF_LEAP_SECONDS" must be defined for this routine to work.  This variable is defined by
      calling cdf_leap_second_init.  Normally, the initialization routine for missions that use tt2000 should use this.

      #3 The calculation adds both leap seconds and the 32.184 second historical offset between TAI and TT

    Examples:
    THEMIS>  print,time_double('2007-03-23')-add_tt2000_offset(time_double('2007-03-23'))
          -65.183998
    THEMIS>  print,time_double('2007-03-23')-add_tt2000_offset(time_double('2007-03-23'),offsets=off_p)
          -65.183998
    THEMIS> print,off_p
          65.1840
    THEMIS>  print,time_double('2007-03-23')-add_tt2000_offset(time_double('2007-03-23'),offsets=off_s,/subtract)
           65.183998
    THEMIS> print,off_s
         -65.1840

     $LastChangedBy: egrimes $
     $LastChangedDate: 2019-03-21 10:47:10 -0700 (Thu, 21 Mar 2019) $
     $LastChangedRevision: 26870 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/add_tt2000_offset.pro $

(See general/misc/time/TT2000/add_tt2000_offset.pro)

## CDF_LEAP_SECOND_INIT

[Previous Routine] [Next Routine] [List of Routines]

    PROCEDURE:  cdf_leap_second_init
    PURPOSE:    CDF library 3.4.0 and later supports time formats
                the include leap seconds.  Specifically tt2000.
                This routine maintains the calibration file that is required
                by the CDF library and TDAS to perform the conversions.

    NOTES: #1 Missions that use tt2000 times in their CDFs should call this routine inside their mission init/
           config routines. (e.g. thm_init/thm_config)
           #2 Set !CDF_LEAP_SECOND.preserve_leap_seconds=1 if you want to keep leap seconds included in unix times after they're imported.
           This may mean that the data set will have a time dependent time skew with other data sets by ~35 seconds.(or more as additional
           leap seconds are added.)
           #3 This routine may modify the environment variable CDF_LEAPSECONDTABLE and update the CDF leap second table if a new version is found.

    $LastChangedBy: egrimes $
    $LastChangedDate: 2019-03-11 09:25:23 -0700 (Mon, 11 Mar 2019) $
    $LastChangedRevision: 26778 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/cdf_leap_second_init.pro $

(See general/misc/time/TT2000/cdf_leap_second_init.pro)

## CRIB_TT2000

[Previous Routine] [Next Routine] [List of Routines]

    Procedure: Crib TT2000

    Purpose:  Demonstrate how to use TT2000 times with TDAS.  Describe what operations are performed on import.

    Notes: Requires CDF 3.4.0 or newer

     $LastChangedBy: pcruce $
     $LastChangedDate: 2012-04-18 15:14:40 -0700 (Wed, 18 Apr 2012) $
     $LastChangedRevision: 10350 $
     $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/crib_tt2000.pro $

(See general/misc/time/TT2000/crib_tt2000.pro)

## TEST_UNIX_TO_TT2000_VECT

[Previous Routine] [Next Routine] [List of Routines]

(See general/misc/time/TT2000/test_unix_to_tt2000_vect.pro)

## TT2000_2_UNIX

[Previous Routine] [Next Routine] [List of Routines]

     FUNCTION:
             tt2000_2_unix

     PURPOSE:
             Converts TT2000 times to unix times. This function converts the input time
               to a 64-bit integer prior to calling time_double (the input is required to
               be a 64-bit integer if the /tt2000 keyword is specified)

     INPUT:
             time: time values in TT2000

     EXAMPLE:
             IDL> unix_time = tt2000_2_unix(4.98e17)
             IDL> unix_time
                   1444727946.6781905

    $LastChangedBy: egrimes $
    $LastChangedDate: 2017-01-03 08:27:35 -0800 (Tue, 03 Jan 2017) $
    $LastChangedRevision: 22472 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/tt2000_2_unix.pro $

(See general/misc/time/TT2000/tt2000_2_unix.pro)

## TT2000_CONFIG_FILEDIR

[Previous Routine] [Next Routine] [List of Routines]

    Function: tt2000_config_filedir.pro
    Purpose: Get the applications user directory for TT2000 leapsecond table

    $LastChangedBy: pcruce $
    $LastChangedDate: 2012-04-18 15:14:40 -0700 (Wed, 18 Apr 2012) $
    $LastChangedRevision: 10350 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/tt2000_config_filedir.pro $

(See general/misc/time/TT2000/tt2000_config_filedir.pro)

## TT2000_READ_CONFIG

[Previous Routine] [Next Routine] [List of Routines]

    NAME:
     tt2000_read_config
    PURPOSE:
     Reads the tt2000_config file
    CALLING SEQUENCE:
     cstruct = tt2000_read_config()
    INPUT:
     none, the filename is hardcoded, 'tt2000_config.txt',and is s put in a
     folder given by the routine tt200_config_filedir, that uses the IDL
     routine app_user_dir to create/obtain it: my linux example:
     /disks/ice/home/jimm/.idl/tt2000/tt2000_config-4-linux
    OUTPUT:
     cstruct = a structure with the changeable fields of the !CDF_LEAP_SECONDS
               structure
    HISTORY:
     Copied shamelessly from thm_read_config by pcruce on 2012/04/18

    $LastChangedBy: nikos $
    $LastChangedDate: 2015-11-18 14:03:31 -0800 (Wed, 18 Nov 2015) $
    $LastChangedRevision: 19411 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/tt2000_read_config.pro $

(See general/misc/time/TT2000/tt2000_read_config.pro)

## TT2000_WRITE_CONFIG

[Previous Routine] [Next Routine] [List of Routines]

    NAME:
     tt2000_write_config
    PURPOSE:
     Writes the tt2000_config file
    CALLING SEQUENCE:
     tt2000_write_config, copy=copy
    INPUT:
     none, the filename is hardcoded, 'tt2000_config.txt',and is s put in a
     folder given by the routine tt2000_config_filedir, that uses the IDL
     routine app_user_dir to create/obtain it: my linux example:
     /disks/ice/home/jimm/.idl/tt2000/tt2000_config-4-linux
    OUTPUT:
     the file is written, and a copy of any old file is generated
    KEYWORD:
     copy = if set, the file is read in and a copy with the !stime
            appended is written out
    HISTORY:
     Copied shamelessly from thm_write_config by pcruce on 2012/04/18
    $LastChangedBy: nikos $
    $LastChangedDate: 2013-06-17 16:29:26 -0700 (Mon, 17 Jun 2013) $
    $LastChangedRevision: 12548 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/tt2000_write_config.pro $

(See general/misc/time/TT2000/tt2000_write_config.pro)

## UNIX_TO_TT2000

[Previous Routine] [Next Routine] [List of Routines]

     FUNCTION:
             unix_to_tt2000

     PURPOSE:
             Converts unix times to TT2000 times.

     INPUT:
             unix_times: unix time values

     EXAMPLE:
             IDL> tt2000_time = unix_to_tt2000(1.4501376e+09)
             IDL> tt2000_time
                   503409664183998107

              convert back:
             IDL> print, tt2000_2_unix(503409664183998107ll)
                   1.4501376e+09

    $LastChangedBy: egrimes $
    $LastChangedDate: 2020-08-10 09:13:29 -0700 (Mon, 10 Aug 2020) $
    $LastChangedRevision: 29011 $
    $URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/trunk/general/misc/time/TT2000/unix_to_tt2000.pro $

(See general/misc/time/TT2000/unix_to_tt2000.pro)

## UNIX_TO_TT2000_VECT

[Previous Routine] [List of Routines]

     FUNCTION:
             unix_to_tt2000_vect

     PURPOSE:
             Converts unix times to TT2000 times, as a vectorized alternative to unix_to_tt2000.pro.
     Notes:
             Code run time could be reduced if method introduced to bypass loop to populate

     INPUT:
             unix_times: unix time values

     EXAMPLE:
             IDL> tt2000_time = unix_to_tt2000(1.4501376e+09)
             IDL> tt2000_time
                   503409664183998107

              convert back:
             IDL> print, tt2000_2_unix(503409664183998107ll)
                   1.4501376e+09

    $LastChangedBy: dcarpenter $
    $LastChangedDate: 2025-08-14 17:03:01 -0700 (Thu, 14 Aug 2025) $
    $LastChangedRevision: 33546 $
    $URL (NEEDS COMMIT): svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/spdsoft/tags/spedas_6_1/general/misc/time/TT2000/unix_to_tt2000_vect.pro $

(See general/misc/time/TT2000/unix_to_tt2000_vect.pro)