Skip to content

Commit

Permalink
Merge pull request #41 from shbhuk/v0.4.0-UseAsropyLeapSeconds
Browse files Browse the repository at this point in the history
v0.4.0 use astropy leap seconds
  • Loading branch information
shbhuk authored Mar 3, 2021
2 parents 401bed2 + 2ba4bc4 commit f525508
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 79 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# barycorrpy (v0.3.7)
# barycorrpy (v0.4.0)

### Please join the google group for updates regarding bug reports, new versions etc:
To sign up for updates, please join the Google Group linked here -
https://groups.google.com/g/barycorrpy

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1115856.svg)](https://doi.org/10.5281/zenodo.1115856)

Expand Down
2 changes: 1 addition & 1 deletion barycorrpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .barycorrpy import get_BC_vel, BCPy, exposure_meter_BC_vel
from .SolarSystemBC import SolarBarycentricCorrection, ReflectedLightBarycentricCorrection

__version__ = '0.3.7'
__version__ = '0.4.0'
41 changes: 0 additions & 41 deletions barycorrpy/data/leap_sec.txt

This file was deleted.

1 change: 0 additions & 1 deletion barycorrpy/data/leapsec_log.txt

This file was deleted.

1 change: 1 addition & 0 deletions barycorrpy/sample_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from . import utc_tdb

def run_sample():
print("Please join our Google Group to keep abreast of the latest versions and bug fixes - https://groups.google.com/g/barycorrpy")
a=[]
b=0

Expand Down
52 changes: 19 additions & 33 deletions barycorrpy/utc_tdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def leap_download(ls_fpath, log_fpath):

def leap_manage(utctime,fpath,leap_update):
'''
DEPRECATED: v0.4.0 onwards
20210303
Using Astropy for leap seconds instead of maintaining/updating a separate files.
--------------------------------------------------------------------------------------
Calculates the offset between UTC and TAI from the leap second file.
Also, checks for 'staleness' (how old is the file) of the leap second file.
Expand Down Expand Up @@ -167,6 +172,11 @@ def leap_manage(utctime,fpath,leap_update):

def JDUTC_to_JDTDB(utctime,leap_update=True,fpath=fpath):
'''
v0.4.0 onwards
20210303
Using Astropy for leap seconds instead of maintaining/updating a separate files.
DEPRECATED
Convert JDUTC to JDTDB (Barycentric Dynamical Time)
INPUT:
utctime : Enter UTC time as Astropy Time Object. In UTC Scale.
Expand All @@ -183,39 +193,15 @@ def JDUTC_to_JDTDB(utctime,leap_update=True,fpath=fpath):
'''

JDUTC=utctime.jd
if JDUTC<2441317.5 :
return utctime.tdb,utctime.tt,['WARNING : JD = '+str(utctime.jd)+' : Precise leap second history is not maintained here for before 1972. Defaulting to Astropy for time conversion. Corrections maybe inaccurate.'],[]

# Call function to check leap second file and find offset between UTC and TAI.
tai_utc,warning,error=leap_manage(utctime=utctime,fpath=fpath,leap_update=leap_update)

if utctime.scale != 'utc':
error+['ERROR : JD = '+str(utctime.jd)+' : Please input time in UTC scale']
if utctime.scale == 'tdb':
return utctime.tdb,utctime.tt,['WARNING : JD = '+str(utctime.jd)+' : UTC Time scale not used. Defaulting to Astropy for time conversion. Corrections maybe inaccurate.'],[]

if tai_utc==0:
return utctime.tdb,utctime.tt,warning,error+['ERROR : JD = '+str(utctime.jd)+' : Unable to maintain leap second file. Defaulting to AstroPy version of leap seconds.']

check_time=utctime.datetime


# Add leap seconds to convert UTC to TAI
new_tai=check_time+datetime.timedelta(seconds=tai_utc) # Add offset and convert to TAI
new_tt=new_tai+datetime.timedelta(seconds=32.184) # Add 32.184 to convert TAI to TT

g=(357.53+0.9856003*( JDUTC - 2451545.0 ))*np.pi/180. # Earth's mean anomaly

TDB = new_tt+datetime.timedelta(seconds=0.001658*np.sin(g)+0.000014*np.sin(2*g)) # TT to TDB

JDTT=Time(new_tt,scale='tt',format='datetime')
JDTT.format='jd'
JDTDB = Time(TDB,scale='tdb',format='datetime')
JDTDB.format='jd'

return JDTDB,JDTT,warning,error
warning = []
error = []

if astropy.__version__ < '4.0.4':
error+=["ERROR: Using Astropy version < 4.0.4 might not have the latest leap second file. Please update to a newer Astropy version to ensure updated leap seconds. "]

return utctime.tdb,utctime.tt, warning, error





Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def readme():


setup(name='barycorrpy',
version='0.3.7',
version='0.4.0',
description='Barycentric Velocity correction at 1 cm/s level',
long_description=readme(),
url='https://github.com/shbhuk/barycorrpy',
author='Shubham Kanodia',
author_email='shbhuk@gmail.com',
install_requires=['astropy>=3.2.3','jplephem','numpy>=1.17.2','scipy','astroquery>=0.3.10'],
install_requires=['astropy>=4.0.4','jplephem','numpy>=1.17.2','scipy','astroquery>=0.3.10'],
packages=['barycorrpy', 'barycorrpy.tests'],
license='GPLv3',
classifiers=['Topic :: Scientific/Engineering :: Astronomy'],
Expand Down

0 comments on commit f525508

Please sign in to comment.