Skip to content

Commit

Permalink
Merge pull request #39 from shbhuk/v0.3.7_MinorFormatting
Browse files Browse the repository at this point in the history
V0.3.7 minor formatting
  • Loading branch information
shbhuk authored Mar 2, 2021
2 parents 0d99f3c + e7899a0 commit 401bed2
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# barycorrpy (v0.3.6)
# barycorrpy (v0.3.7)

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

Expand Down
22 changes: 14 additions & 8 deletions barycorrpy/SolarSystemBC.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def SolarBarycentricCorrection(JDUTC, loc, zmeas=0, ephemeris='de430', leap_dir=
##### EPHEMERIDES #####

earth_geo = get_body_barycentric_posvel('earth', JDTDB, ephemeris=ephemeris) # [km]
PosVector_EarthSSB = r_eci + earth_geo[0].xyz.value*1000. # [m]
v_geo = earth_geo[1].xyz.value*1000./86400. # [m/s]
r_geo = np.reshape(earth_geo[0].xyz.value*1000., 3) # [m]
v_geo = np.reshape(earth_geo[1].xyz.value*1000./86400., 3) # [m/s]

PosVector_EarthSSB = r_eci + r_geo # [m]

# Relativistic Addition of Velocities
VelVector_EarthSSB = (v_eci+v_geo) / (1.+ np.sum(v_eci*v_geo)/c**2) # [m/s]
Expand All @@ -90,8 +92,8 @@ def SolarBarycentricCorrection(JDUTC, loc, zmeas=0, ephemeris='de430', leap_dir=

solar_ephem = get_body_barycentric_posvel('sun', JDTDB, ephemeris=ephemeris)

PosVector_SolSSB = solar_ephem[0].xyz.value*1000. #[m]
VelVector_SolSSB = solar_ephem[1].xyz.value*1000./86400. # [m/s]
PosVector_SolSSB = np.reshape(solar_ephem[0].xyz.value*1000., 3) #[m]
VelVector_SolSSB = np.reshape(solar_ephem[1].xyz.value*1000./86400., 3) # [m/s]
BetaSolar = VelVector_SolSSB / c

GammaSolar = 1. / np.sqrt(1.- np.sum(BetaSolar**2))
Expand Down Expand Up @@ -263,12 +265,16 @@ def ReflectedLightBarycentricCorrection(SolSystemTarget, JDUTC, loc, zmeas=0, Ho
v_eci = v_pint[0] # [m/s]

earth_geo = get_body_barycentric_posvel('earth', JDTDB, ephemeris=ephemeris) # [km]
PosVector_EarthSSB = r_eci + earth_geo[0].xyz.value*1000. # [m]
v_geo = earth_geo[1].xyz.value*1000./86400. # [m/s]
VelVector_EarthSSB = (v_eci+v_geo) / (1.+ np.sum(v_eci*v_geo)/c**2) # [m/s]
r_geo = np.reshape(earth_geo[0].xyz.value*1000., 3) # [m]
v_geo = np.reshape(earth_geo[1].xyz.value*1000./86400., 3) # [m/s]

PosVector_EarthSSB = r_eci + r_geo # [m]

# Relativistic Addition of Velocities
VelVector_EarthSSB = (v_eci+v_geo) / (1.+ np.sum(v_eci*v_geo)/c**2) # [m/s]
BetaEarth = VelVector_EarthSSB / c
GammaEarth = 1. / np.sqrt(1. - np.sum(BetaEarth**2))

GammaEarth = 1. / np.sqrt(1.- np.sum(BetaEarth**2))


PosVector_SolEarth, PosMag_SolEarth, PosHat_SolEarth = CalculatePositionVector(r1=PosVector_SolSSB, r2=PosVector_EarthSSB)
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.6'
__version__ = '0.3.7'
8 changes: 5 additions & 3 deletions barycorrpy/barycorrpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ def BCPy(JDUTC,
##### EPHEMERIDES #####

earth_geo = get_body_barycentric_posvel('earth', JDTDB, ephemeris=ephemeris) # [km]
PosVector_EarthSSB = r_eci + earth_geo[0].xyz.value*1000. # [m]
v_geo = earth_geo[1].xyz.value*1000./86400. # [m/s]
r_geo = np.reshape(earth_geo[0].xyz.value*1000., 3) # [m]
v_geo = np.reshape(earth_geo[1].xyz.value*1000./86400., 3) # [m/s]

PosVector_EarthSSB = r_eci + r_geo # [m]

# Relativistic Addition of Velocities
VelVector_EarthSSB = (v_eci+v_geo) / (1.+np.sum(v_eci*v_geo)/c**2) # [m/s]
Expand Down Expand Up @@ -339,7 +341,7 @@ def BCPy(JDUTC,
PosVector_SSObject = earth_geo[0].xyz.value*1000. # [m]
else:
jplephem = get_body_barycentric(ss_body, JDTDB, ephemeris=ephemeris)
PosVector_SSObject = jplephem.xyz.value*1000. # [m]
PosVector_SSObject = np.reshape(jplephem.xyz.value*1000., 3) # [m]

# Vector from object barycenter to Observatory
PosVector_EarthSSObject, PosMag_EarthSSObject, PosHat_EarthSSObject = CalculatePositionVector(r1=PosVector_EarthSSB, r2=PosVector_SSObject)
Expand Down
2 changes: 1 addition & 1 deletion barycorrpy/sample_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run_sample():
a.append('result6')
b+=1

result7 = utc_tdb.JDUTC_to_SolarEmissionTDB(JDUTC=2458000, obsname='KPNO')
result7 = utc_tdb.JDUTC_to_HJDTDB(JDUTC=2458000, obsname='KPNO')

if np.isclose(a=result7[0], b=2457999.99497543, atol=1e-7, rtol=0):
a.append('result7')
Expand Down
4 changes: 2 additions & 2 deletions barycorrpy/tests/test_barycorrpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def test_SolarBC(self):
result6 = get_BC_vel(JDUTC=2458000, lat=-30.169138888, longi=-70.805888, alt=2379.5, zmeas=0.0, SolSystemTarget='Sun')
self.assertTrue(np.isclose(a = result6[0], b = 819.4474, atol = 1e-2, rtol = 0))

def test_SolarEmissionTDB(self):
def test_HJDTDB(self):

result7 = utc_tdb.JDUTC_to_SolarEmissionTDB(JDUTC=2458000, obsname='KPNO')
result7 = utc_tdb.JDUTC_to_HJDTDB(JDUTC=2458000, obsname='KPNO')
self.assertTrue(np.isclose(a=result7[0], b=2457999.99497543, atol=1e-7, rtol=0))


Expand Down
18 changes: 7 additions & 11 deletions barycorrpy/utc_tdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _JDUTC_to_BJDTDB(JDUTC,
return result, warning, error


def JDUTC_to_SolarEmissionTDB(JDUTC,
def JDUTC_to_HJDTDB(JDUTC,
obsname='', lat=0., longi=0., alt=0.,
ephemeris='de430', leap_dir=os.path.join(os.path.dirname(__file__),'data'), leap_update=True):

Expand All @@ -428,16 +428,12 @@ def JDUTC_to_SolarEmissionTDB(JDUTC,
Precision has not been explicity tested.
Calling procedure for JDUTC_to_SolarEmissionTDB. Accepts vector time object (i.e., multiple observation JD values).
Calling procedure for JDUTC_to_HJDTDB. Accepts vector time object (i.e., multiple observation JD values).
INPUT:
JDUTC : Can enter multiple times in Astropy Time object or as float. Will loop through and find barycentric velocity correction corresponding to those times.
In UTC Scale. If using float, be careful about format and scale used.
starname : Name of target. Will query SIMBAD database.
OR / AND
hip_id : Hipparcos Catalog ID. (Integer) . Epoch will be taken to be Catalogue Epoch or J1991.25
If specified then ra,dec,pmra,pmdec,px, and epoch need not be specified.
OR / AND
obsname : Name of Observatory as defined in Astropy EarthLocation routine. Can check list by EarthLocation.get_site_names().
If obsname is not used, then can enter lat,long,alt.
Expand Down Expand Up @@ -466,7 +462,7 @@ def JDUTC_to_SolarEmissionTDB(JDUTC,
Example:
>>> from astropy.time import Time
>>> JDUTC = Time(2458000, format='jd', scale='utc')
>>> utc_tdb.JDUTC_to_SolarEmissionTDB(JDUTC,lat=-30.169283, longi=-70.806789, alt=2241.9)
>>> utc_tdb.JDUTC_to_HJDTDB(JDUTC,lat=-30.169283, longi=-70.806789, alt=2241.9)
(array([ 2458000.00662602]), [[], []], 0)
'''
Expand Down Expand Up @@ -494,7 +490,7 @@ def JDUTC_to_SolarEmissionTDB(JDUTC,
loc = EarthLocation.from_geodetic(longi, lat, height=alt)

for jdutc in JDUTC:
a = _JDUTC_to_SolarEmissionTDB(JDUTC=jdutc,
a = _JDUTC_to_HJDTDB(JDUTC=jdutc,
loc=loc,
ephemeris=ephemeris, leap_dir=leap_dir, leap_update=leap_update)
corr_time.append(a[0])
Expand All @@ -513,7 +509,7 @@ def JDUTC_to_SolarEmissionTDB(JDUTC,



def _JDUTC_to_SolarEmissionTDB(JDUTC, loc,
def _JDUTC_to_HJDTDB(JDUTC, loc,
ephemeris='de430', leap_dir=os.path.join(os.path.dirname(__file__),'data'), leap_update=True):

'''
Expand All @@ -526,7 +522,7 @@ def _JDUTC_to_SolarEmissionTDB(JDUTC, loc,
Precision has not been explicity tested.
See JDUTC_to_BJDTDB() for parameter description.
See JDUTC_to_HJDTDB() for parameter description.
'''

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def readme():


setup(name='barycorrpy',
version='0.3.6',
version='0.3.7',
description='Barycentric Velocity correction at 1 cm/s level',
long_description=readme(),
url='https://github.com/shbhuk/barycorrpy',
Expand Down

0 comments on commit 401bed2

Please sign in to comment.