Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/python-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ name: Python on pull request

on:
pull_request:
paths:
- timescale/**
- test/**
- .github/workflows/python-request.yml
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 1 * *'
Expand Down
3 changes: 3 additions & 0 deletions test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ def test_timescale():
assert np.all(delta_time_epochs/np.timedelta64(1, 'ns') == 0)
SHORTCUT = timescale.from_datetime(atlas_sdp_epoch)
assert np.all(ATLAS.MJD == SHORTCUT.MJD)
# check year calculations
assert np.all(ATLAS.year == 2018.0)
assert np.isclose(ATLAS.nominal_year, 2018.0 + 0.5/365.25)
# from deltatime
ATLAS = timescale.time.Timescale().from_deltatime(0, epoch=(2018,1,1))
assert np.all(ATLAS.MJD == 58119)
Expand Down
18 changes: 13 additions & 5 deletions timescale/time.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
time.py
Written by Tyler Sutterley (07/2025)
Written by Tyler Sutterley (08/2025)
Utilities for calculating time operations

PYTHON DEPENDENCIES:
Expand All @@ -16,6 +16,7 @@
utilities.py: download and management utilities for syncing files

UPDATE HISTORY:
Updated 08/2025: add nominal years (365.25 days long) to Timescale class
Updated 07/2025: verify Bulletin-A entries are not already in merged file
add Besselian year conversion to Timescale class
Updated 03/2025: added attributes for ut1_utc and gps_utc
Expand Down Expand Up @@ -117,11 +118,12 @@
# number of days between the Julian day epoch and standard epochs
_jd_mjd = 2400000.5
_jd_serial = 1721058.5
_jd_gps = 2444244.5
# number of days between MJD and the standard (common) epochs
_mjd_ntp = 15020
_mjd_cnes = 33282
_mjd_unix = 40587
_mjd_gps = 44244
_mjd_gps = _jd_gps - _jd_mjd
_mjd_tide = 48622
_mjd_j2000 = 51544.5
_mjd_atlas_sdp = 58119
Expand Down Expand Up @@ -967,7 +969,7 @@ def gps(self):
"""Seconds since 1980-01-06T00:00:00
"""
# return the GPS time
return (self.utc - 2444244.5)*self.day + self.gps_utc
return (self.utc - _jd_gps)*self.day + self.gps_utc

@timescale.utilities.reify
def gps_utc(self):
Expand All @@ -978,7 +980,7 @@ def gps_utc(self):
# TAI time is ahead of GPS by 19 seconds
_tai_gps = 19.0
# convert from dynamic time to TAI
TAI = np.atleast_1d(self.tt - 2444244.5)*self.day - _tt_tai
TAI = np.atleast_1d(self.tt - _jd_gps)*self.day - _tt_tai
# calculate the number of leap seconds
return count_leap_seconds(TAI - _tai_gps)

Expand All @@ -990,7 +992,7 @@ def gps_week(self):

@timescale.utilities.reify
def J2000(self):
"""Seconds since 2000-01-01T12:00:00
"""Seconds (Terrestrial Time) since 2000-01-01T12:00:00
"""
_jd_j2000 = _jd_mjd + _mjd_j2000
return (self.tt - _jd_j2000)*self.day
Expand Down Expand Up @@ -1109,6 +1111,12 @@ def year(self):
"""
Y, M, D, h, m, s = convert_julian(self.utc, format='tuple')
return convert_calendar_decimal(Y, M, D, hour=h, minute=m, second=s)

@timescale.utilities.reify
def nominal_year(self):
"""Universal Time (UT) as nominal years of 365.25 days
"""
return 1992.0 + self.tide/365.25

def min(self):
"""Minimum time value as a ``Timescale`` object
Expand Down
Loading