Ticktock class holding various time coordinate systems (TAI, UTC, ISO, JD, MJD, UNX, RDT, CDF, DOY, eDOY)
Possible input data types: ISO: ISO standard format like ‘2002-02-25T12:20:30’ UTC: datetime object with UTC time TAI: elapsed seconds since 1958/1/1 (includes leap seconds) UNX: elapsed seconds since 1970/1/1 (all days have 86400 secs sometimes unequal lenghts) JD: Julian days elapsed MJD: Modified Julian days RDT: Rata Die days elapsed since 1/1/1 CDF: CDF epoch: milliseconds since 1/1/0000
Possible output data types: All those listed above, plus DOY: Integer day of year, starts with day 1 eDOY: Fractional day of year, starts at day 0
Parameters: | data : array_like (int, datetime, float, string)
dtype : string {CDF, ISO, UTC, TAI, UNX, JD, MJD, RDT} or function
|
---|---|
Returns: | out : Ticktock
|
Examples
>>> x = Ticktock([2452331.0142361112, 2452332.0142361112], 'JD')
>>> x.ISO
dmarray(['2002-02-25T12:20:30', '2002-02-26T12:20:30'], dtype='|S19')
>>> x.DOY # Day of year
dmarray([ 56., 57.])
>>> y = Ticktock(['01-01-2013', '20-03-2013'], lambda x: datetime.datetime.strptime(x, '%d-%m-%Y'))
>>> y.UTC
dmarray([2013-01-01 00:00:00, 2013-03-20 00:00:00], dtype=object)
>>> y.DOY # Day of year
dmarray([ 1., 79.])
append(other) | Will be called when another Ticktock instance has to be appended to the current one |
argsort() | This will return the indices that would sort the Ticktock values |
convert(dtype) | convert a Ticktock instance into a new time coordinate system provided in dtype |
getCDF() | a.getCDF() or a.CDF |
getDOY() | a.DOY or a.getDOY() |
getGPS() | a.GPS or a.getGPS() |
getISO() | a.ISO or a.getISO() |
getJD() | a.JD or a.getJD() |
getMJD() | a.MJD or a.getMJD() |
getRDT() | a.RDT or a.RDT() |
getTAI() | a.TAI or a.getTAI() |
getUNX() | a.UNX or a.getUNX() |
getUTC() | a.UTC or a.getUTC() |
geteDOY() | a.eDOY or a.geteDOY() |
getleapsecs() | a.leaps or a.getleapsecs() |
isoformat(b, attrib) | This changes the self.__isofmt attribute by and subsequently this function will update the ISO attribute. |
now() | Creates a Ticktock object with the current time, equivalent to datetime.now() |
sort() | This will sort the Ticktock values in place |
update_items(b, attrib) | After changing the self.data attribute by either __setitem__ or __add__ etc this function will update all other attributes. |
Will be called when another Ticktock instance has to be appended to the current one
Parameters: | other : Ticktock
|
---|
This will return the indices that would sort the Ticktock values
Returns: | out : list
|
---|
convert a Ticktock instance into a new time coordinate system provided in dtype
Parameters: | dtype : string
|
---|---|
Returns: | out : Ticktock
|
See also
CDF, ISO, UTC
Examples
>>> a = Ticktock(['2002-02-02T12:00:00', '2002-02-02T12:00:00'], 'ISO')
>>> s = a.convert('TAI')
>>> type(s)
<class 'time.Ticktock'>
>>> s
Ticktock( [1391342432 1391342432] ), dtype=TAI
a.getCDF() or a.CDF
Return CDF time which is milliseconds since 01-Jan-0000 00:00:00.000. “Year zero” is a convention chosen by NSSDC to measure epoch values. This date is more commonly referred to as 1 BC. Remember that 1 BC was a leap year. The CDF date/time calculations do not take into account the changes to the Gregorian calendar, and cannot be directly converted into Julian date/times.
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.CDF
array([ 6.31798704e+13])
a.DOY or a.getDOY()
extract DOY (days since January 1st of given year)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.DOY
array([ 33])
a.GPS or a.getGPS()
return GPS epoch (0000 UT (midnight) on January 6, 1980)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.GPS
array([])
a.ISO or a.getISO()
convert dtype data into ISO string
Returns: | out : list of strings
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.ISO
dmarray(['2002-02-02T12:00:00'])
a.JD or a.getJD()
convert dtype data into Julian Date (JD)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.JD
array([ 2452308.])
a.MJD or a.getMJD()
convert dtype data into MJD (modified Julian date)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.MJD
array([ 52307.5])
a.RDT or a.RDT()
convert dtype data into Rata Die (lat.) Time (days since 1/1/0001)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.RDT
array([ 730883.5])
a.TAI or a.getTAI()
return TAI (International Atomic Time)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.TAI
array([1391342432])
a.UNX or a.getUNX()
convert dtype data into Unix Time (Posix Time) seconds since 1970-Jan-1 (not counting leap seconds)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.UNX
array([ 1.01265120e+09])
a.UTC or a.getUTC()
convert dtype data into UTC object a la datetime()
Returns: | out : list of datetime objects
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.UTC
[datetime.datetime(2002, 2, 2, 12, 0)]
a.eDOY or a.geteDOY()
extract eDOY (elapsed days since midnight January 1st of given year)
Returns: | out : numpy array
|
---|
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.eDOY
array([ 32.5])
a.leaps or a.getleapsecs()
retrieve leapseconds from lookup table, used in getTAI
Returns: | out : numpy array
|
---|
See also
Examples
>>> a = Ticktock('2002-02-02T12:00:00', 'ISO')
>>> a.leaps
array([32])
This changes the self.__isofmt attribute by and subsequently this function will update the ISO attribute.
Parameters: | fmt : string, optional |
---|
Creates a Ticktock object with the current time, equivalent to datetime.now()
Returns: | out : ticktock
|
---|
See also
After changing the self.data attribute by either __setitem__ or __add__ etc this function will update all other attributes. This function is called automatically in __add__ and __setitem__
Parameters: | cls : Ticktock attrib : string
|
---|
See also
spacepy.Ticktock.__setitem__, spacepy.Ticktock.__add__, spacepy.Ticktock.__sub__