Skip to content

Commit

Permalink
Merge 9dfef07 into 717e4ad
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Feb 5, 2019
2 parents 717e4ad + 9dfef07 commit c3468be
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 209 deletions.
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ env:
- ASTROPY_VERSION=stable
- MAIN_CMD='python setup.py'
- SETUP_CMD='test'
#- PIP_DEPENDENCIES=''
- EVENT_TYPE='pull_request push'


# List other runtime dependencies for the package that are available as
# conda packages here.
- CONDA_DEPENDENCIES=''

# List other runtime dependencies for the package that are available as
# pip packages here.
- PIP_DEPENDENCIES='numpy matplotlib ads scipy synphot https://github.com/astropy/astroquery/archive/master.zip'
- PIP_DEPENDENCIES='pip==18.1 numpy matplotlib ads scipy synphot https://github.com/astropy/astroquery/archive/master.zip pytest pytest-dependency pytest-astropy'

# Conda packages for affiliated packages are hosted in channel
# "astropy" while builds for astropy LTS with recent numpy versions
Expand All @@ -59,10 +57,9 @@ env:

matrix:
# Make sure that egg_info works without dependencies
- PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
- PYTHON_VERSION=3.6 SETUP_CMD='egg_info'

- PYTHON_VERSION=3.7 SETUP_CMD='egg_info'
matrix:

# Don't wait for allowed failures
Expand Down Expand Up @@ -94,10 +91,12 @@ matrix:
# versions of Python, we can vary Python and Numpy versions at the same
# time.

- os: linux
env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.10
- os: linux
env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.11
- os: linux
env: PYTHON_VERSION=3.6 NUMPY_VERSION=1.11
- os: linux
env: PYTHON_VERSION=3.7 NUMPY_VERSION=1.11

# Try numpy pre-release
- os: linux
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Please note that this package is currently under heavy development.
Installation
------------

`sbpy` requires Python 3.x - compatibility with Python 2.x is not
`sbpy` requires Python 3.5+ - compatibility with Python 2.x is not
supported. We hence recommend that you install the latest version of
`Anaconda Python 3.x <https://www.anaconda.com/download/>`_ on your
system before installing `sbpy`. Make sure that Anaconda Python is
Expand All @@ -42,7 +42,7 @@ Requirements

`sbpy` has the following requirements (incomplete):

* Python 3
* Python 3.5 or later
* `numpy <https://www.numpy.org/>` 1.4.0 or later
* pytest 3.1 or later
* `astropy <https://www.astropy.org/>`
Expand Down
272 changes: 151 additions & 121 deletions docs/sbpy/data.rst

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pip=18.1
numpy>=1.4.0
astropy-helpers
matplotlib
Expand Down
38 changes: 0 additions & 38 deletions sbpy/conftest.py

This file was deleted.

4 changes: 2 additions & 2 deletions sbpy/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class Conf():
'CART': [None, 'au', 'au', 'au', 'au/d', 'au/d',
'au/d', None, 'd', None, 'mag', None]}

oorb_ephem_fields = ['MJD', 'RA', 'DEC', 'RA*cos(Dec)_rate', 'DEC_rate', 'alpha',
'elong', 'r', 'Delta', 'V', 'pa', 'TopEclLon',
oorb_ephem_fields = ['MJD', 'RA', 'DEC', 'RA*cos(Dec)_rate', 'DEC_rate',
'alpha', 'elong', 'r', 'Delta', 'V', 'pa', 'TopEclLon',
'TopEclLat', 'OppTopEclLon', 'OppTopEclLat',
'HelEclLon', 'HelEclLat', 'OppHelEclLon',
'OppHelEclLat', 'EL', 'ELsun', 'ELmoon',
Expand Down
50 changes: 27 additions & 23 deletions sbpy/data/ephem.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,28 +492,27 @@ def from_oo(self, orbit, epochs=None, location='500', scope='full',
>>> from sbpy.data import Orbit, Ephem
>>> from astropy.time import Time
>>> epochs = Time.now().jd + np.arange(0, 10, 1/24)
>>> ceres = Orbit.from_horizons('1') # doctest: +SKIP
>>> ceres = Orbit.from_horizons('1')
>>> eph = Ephem.from_oo(ceres, epochs=epochs, location='G37') # doctest: +SKIP
>>> print(eph.table) # doctest: +SKIP
targetname MJD [1] ... obsy [1] obsz [1]
d ... AU AU
---------- ------------------ ... --------------------- ----------------------
1 Ceres 58374.720415079966 ... -0.1640418731222332 1.3660753531152814e-05
1 Ceres 58374.76208174648 ... -0.16334416599555382 1.6732994041007698e-05
1 Ceres 58374.803748413455 ... -0.16264729902661218 2.0200328928084155e-05
1 Ceres 58374.845415079966 ... -0.16195072092478624 2.3823231905778508e-05
1 Ceres 58374.88708174648 ... -0.16125385509757997 2.735153478080482e-05
1 Ceres 58374.928748413455 ... -0.16055613920683476 3.0541568772989025e-05
... ... ... ... ...
1 Ceres 58384.428748413455 ... 0.0016096754330388497 9.924120661052244e-06
1 Ceres 58384.470415079966 ... 0.0023287044344341605 7.69766111133525e-06
1 Ceres 58384.51208174648 ... 0.0030458232636104473 6.300640241761616e-06
1 Ceres 58384.553748413455 ... 0.003760809893911351 5.8280310798125914e-06
1 Ceres 58384.595415079966 ... 0.004473588211662766 6.311456253324348e-06
1 Ceres 58384.63708174648 ... 0.005184233254950517 7.717021060406424e-06
1 Ceres 58384.678748413455 ... 0.005892966025131429 9.947635868821306e-06
Length = 240 rows
"""
>>> print(eph) # doctest: +SKIP
<QTable length=240>
targetname epoch ... obsz trueanom
d ... AU deg
str7 float64 ... float64 float64
---------- ------------------ ... ----------------------- -----------------
1 Ceres 2458519.316966272 ... 3.2083678848104924e-06 68.0863831954328
1 Ceres 2458519.3586329385 ... 2.7022422510736277e-07 68.09589266358881
1 Ceres 2458519.4002996054 ... -3.111046209036683e-06 68.10540191585879
1 Ceres 2458519.441966272 ... -6.700369254264427e-06 68.11491095202307
1 Ceres 2458519.4836329385 ... -1.0248419404668141e-05 68.12441977218093
1 Ceres 2458519.5252996054 ... -1.3508703580356052e-05 68.13392837643161
... ... ... ... ...
1 Ceres 2458529.066966272 ... 1.2522500440509399e-05 70.30569661787204
1 Ceres 2458529.1086329385 ... 1.4101698473351076e-05 70.31515536712485
1 Ceres 2458529.1502996054 ... 1.4771304981564537e-05 70.3246138990413
1 Ceres 2458529.191966272 ... 1.448582020449618e-05 70.33407221340468
1 Ceres 2458529.2336329385 ... 1.326517587380005e-05 70.34353031031534
1 Ceres 2458529.2752996054 ... 1.1193369555934085e-05 70.35298818987367 """

import pyoorb

Expand Down Expand Up @@ -570,6 +569,10 @@ def from_oo(self, orbit, epochs=None, location='500', scope='full',
epochs = [Time.now()]
elif isinstance(epochs, Time):
epochs = [Time(epochs)]
elif isinstance(epochs, (float, int)):
epochs = [Time(epochs, format='jd')]
elif isinstance(epochs, str):
epochs = [Time(epochs, format='iso')]
elif isinstance(epochs, (list, tuple, ndarray)):
new_epochs = [None] * len(epochs)
for i in range(len(epochs)):
Expand Down Expand Up @@ -616,8 +619,9 @@ def from_oo(self, orbit, epochs=None, location='500', scope='full',
name='targetname'),
index=0)

# remove trueanom column for now as it only holds a dummy value
ephem.table.remove_column('trueanom')
# convert MJD to Julian Date
ephem.add_column(ephem['MJD']+2400000.5*u.d, name='epoch', index=1)
ephem._table.remove_column('MJD')

if bib.status() is None or bib.status():
bib.register('sbpy.data.Ephem.from_oo',
Expand Down
40 changes: 24 additions & 16 deletions sbpy/data/orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
created on June 04, 2017
"""
import os
from numpy import array, ndarray, double, arange
from numpy import array, ndarray, double, arange, rad2deg
from astropy.time import Time
from astropy.table import vstack, Column
from astroquery.jplhorizons import Horizons
Expand Down Expand Up @@ -352,12 +352,13 @@ def oo_transform(self, orbittype, timescale=None, ephfile='de430'):
>>> from sbpy.data import Orbit
>>> ceres = Orbit.from_horizons('Ceres')
>>> statevec = ceres.oo_transform('CART') # doctest: +SKIP
>>> print(statevec.table) # doctest: +SKIP
id x y ... epoch_scale H G
AU AU ... mag
------- ------------------ -------------------- ... ----------- ---- ----
1 Ceres -2.525066589355839 -0.34964875372044524 ... UTC 3.34 0.12
>>> print(statevec) # doctest: +SKIP
<QTable length=1>
id x y ... H G timescale
AU AU ... mag
str7 float64 float64 ... float64 float64 str2
------- ------------------ ------------------- ... ------- ------- ---------
1 Ceres -1.967176101061908 -1.7891189971612211 ... 3.34 0.12 TT
"""
import pyoorb

Expand Down Expand Up @@ -400,8 +401,11 @@ def oo_transform(self, orbittype, timescale=None, ephfile='de430'):

orbits = self.from_array(oo_orbits.transpose(), names=columns)

# apply units
for i, col in enumerate(orbits.column_names):
# convert from radians to degrees where unit == deg
if conf.oorb_orbit_units[orbittype][i] == 'deg':
orbits._table[col] = rad2deg(orbits[col])
# apply units
orbits[col].unit = conf.oorb_orbit_units[orbittype][i]

# replace id column with actual target names from original orbits
Expand Down Expand Up @@ -484,13 +488,14 @@ def oo_propagate(self, epoch, timescale='UTC',
>>> from astropy.time import Time
>>> epoch = Time.now().jd + 100
>>> ceres = Orbit.from_horizons('Ceres')
>>> future_ceres = ceres.oo_propagate(epoch) # doctest: +SKIP
>>> print(future_ceres.table) # doctest: +SKIP
id a e ... epoch_scale H G
AU ... mag
------- ----------------- ------------------- ... ----------- ---- ----
1 Ceres 2.767911178119476 0.07574650026062148 ... UTC 3.34 0.12
"""
>>> future_ceres = ceres.oo_propagate(epoch) # doctest: +SKIP
>>> print(future_ceres) # doctest: +SKIP
<QTable length=1>
id a e ... H G timescale
AU ... mag
str7 float64 float64 ... float64 float64 str3
------- ----------------- ------------------- ... ------- ------- ---------
1 Ceres 2.769331727251861 0.07605371361208543 ... 3.34 0.12 UTC """

import pyoorb

Expand Down Expand Up @@ -550,8 +555,11 @@ def oo_propagate(self, epoch, timescale='UTC',

orbits = self.from_array(oo_orbits.transpose(), names=columns)

# apply units
for i, col in enumerate(orbits.column_names):
# convert from radians to degrees where unit == deg
if conf.oorb_orbit_units[orbittype][i] == 'deg':
orbits._table[col] = rad2deg(orbits[col])
# apply units
orbits[col].unit = conf.oorb_orbit_units[orbittype][i]

# replace id column with actual target names from original orbits
Expand Down

0 comments on commit c3468be

Please sign in to comment.