Skip to content

Commit 1bcf66b

Browse files
committed
Add from_ongc() to starlib
Signed-off-by: Mattia Verga <mattia.verga@tiscali.it>
1 parent 33aec1a commit 1bcf66b

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ numpy==1.15.4
77
matplotlib==3.3.0
88
pandas==1.0.0
99
pyflakes==2.1.1
10+
pyongc
1011
python-dateutil>=2.5.0
1112
pytz
1213
sphinx==1.7.2

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ def make_distribution(self):
6060
'numpy',
6161
'sgp4>=2.2',
6262
],
63+
extras_require={
64+
'ongc': ['pyongc'],
65+
},
6366
)

skyfield/starlib.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ def from_dataframe(cls, df):
106106
epoch=epoch,
107107
)
108108

109+
@classmethod
110+
def from_ongc(cls, identifier):
111+
from pyongc import ongc
112+
deepsky = ongc.Dso(identifier)
113+
return cls(
114+
ra = Angle(radians=deepsky.rad_coords[0]),
115+
dec = Angle(radians=deepsky.rad_coords[1]),
116+
ra_mas_per_year = deepsky.pm_ra or 0,
117+
dec_mas_per_year = deepsky.pm_dec or 0,
118+
parallax_mas = deepsky.parallax or 0,
119+
)
120+
109121
def _observe_from_bcrs(self, observer):
110122
position, velocity = self._position_au, self._velocity_au_per_d
111123
t = observer.t

skyfield/tests/test_stars.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ def test_dataframe():
66
df = load_dataframe(f)
77
star = api.Star.from_dataframe(df)
88
assert repr(star) == 'Star(ra shape=9933, dec shape=9933, ra_mas_per_year shape=9933, dec_mas_per_year shape=9933, parallax_mas shape=9933, epoch shape=9933)'
9+
10+
def test_from_ongc():
11+
hercules = api.Star.from_ongc('M13')
12+
assert repr(hercules) == (
13+
'Star(ra=250.42345833333337, dec=36.46130555555556, ra_mas_per_year=-3.18, '
14+
'dec_mas_per_year=-2.56, parallax_mas=0.0813, epoch=2451545.0)'
15+
)

0 commit comments

Comments
 (0)