Skip to content

Commit

Permalink
Merge pull request #22 from nsat/bordicon_v_1_2
Browse files Browse the repository at this point in the history
minor point release update.
  • Loading branch information
bordicon committed Feb 2, 2016
2 parents 9362137 + 710a60f commit b3444a1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
8 changes: 4 additions & 4 deletions predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -3478,7 +3478,7 @@ static PyObject* quick_predict(PyObject* self, PyObject *args)
//TODO: Seems like this should be based on the freshness of the TLE, not wall clock.
if ((daynum<now-365.0) || (daynum>now+365.0))
{
sprintf(errbuff, "time %s too far from present", Daynum2String(daynum));
sprintf(errbuff, "time %s too far from present\n", Daynum2String(daynum));
PyErr_SetString(PredictException, errbuff);
goto cleanup_and_raise_exception;
}
Expand All @@ -3493,21 +3493,21 @@ static PyObject* quick_predict(PyObject* self, PyObject *args)

if (!AosHappens(0))
{
sprintf(errbuff, "%lu does not rise above horizon. No AOS.", sat.catnum);
sprintf(errbuff, "%lu does not rise above horizon. No AOS.\n", sat.catnum);
PyErr_SetString(PredictException, errbuff);
goto cleanup_and_raise_exception;
}

if (Geostationary(0)!=0)
{
sprintf(errbuff, "%lu is geostationary. Does not transit.", sat.catnum);
sprintf(errbuff, "%lu is geostationary. Does not transit.\n", sat.catnum);
PyErr_SetString(PredictException, errbuff);
goto cleanup_and_raise_exception;
}

if (Decayed(indx,daynum)!=0)
{
sprintf(errbuff, "%lu has decayed. Cannot calculate transit.", sat.catnum);
sprintf(errbuff, "%lu has decayed. Cannot calculate transit.\n", sat.catnum);
PyErr_SetString(PredictException, errbuff);
goto cleanup_and_raise_exception;
}
Expand Down
17 changes: 2 additions & 15 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
from copy import copy
from cpredict import quick_find, quick_predict, PredictException

def tle(tle_id):
url = "http://tle.nanosatisfi.com/%s"%tle_id
try:
res = urllib2.urlopen(url)
if res.getcode() != 200:
err = "Unable to retrieve TLE from %s (HTTP: %s)"%(url, res.getcode())
raise PredictException(err)
return res.read().rstrip()
except Exception as e:
raise PredictException("Unable to retrieve TLE from %s: (%s)"%(url,e))

def host_qth(path="~/.predict/predict.qth"):
path = os.path.abspath(os.path.expanduser(path))
try:
Expand Down Expand Up @@ -71,8 +60,6 @@ def transits(tle, qth, ending_after=None, ending_before=None):
# Transit is a convenience class representing a pass of a satellite over a groundstation.
class Transit():
def __init__(self, tle, qth, start, end):
if None in [tle, qth, start, end]:
raise TypeError("None is not a valid argument: Transit(*%s)"%[tle,qth,start,end])
self.tle = massage_tle(tle)
self.qth = massage_qth(qth)
self.start = start
Expand Down Expand Up @@ -155,7 +142,7 @@ def prune(self, fx, epsilon=0.1):
def duration(self):
return self.end - self.start

def at(self, t, epsilon = 0.1):
if t < (self.start-epsilon) or t > (self.end+epsilon):
def at(self, t):
if t < self.start or t > self.end:
raise PredictException("time %f outside transit [%f, %f]" % (t, self.start, self.end))
return observe(self.tle, self.qth, t)
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from distutils.core import setup, Extension
setup(
name='pypredict',
version='1.1',
author="Jesse Trutna",
author_email="[email protected]",
url="https://github.com/nsat/pypredict",
py_modules=['predict'],
ext_modules=[Extension('cpredict', ['predict.c'])]
name='pypredict',
version='1.2',
author="Jesse Trutna",
author_email="[email protected]",
url="https://github.com/nsat/pypredict",
py_modules=['predict'],
ext_modules=[Extension('cpredict', ['predict.c'])]
)

4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import predict
from cpredict import quick_find, quick_predict, PredictException

# fetched from http://tle.nanosatisfi.com/40044
# fetched from http://tle.spire.com/40044
TLE = "0 LEMUR 1\n1 40044U 14033AL 15013.74135905 .00002013 00000-0 31503-3 0 6119\n2 40044 097.9584 269.2923 0059425 258.2447 101.2095 14.72707190 30443"
QTH = "fuze-sfgs\n37.7727\n122.4070\n25"
STEP = 15
Expand All @@ -19,7 +19,7 @@ def test_transits_are_truncated_if_the_overlap_the_start_or_end_times(self):

tle = predict.massage_tle(TLE)
qth = predict.massage_qth(QTH)

at = T1_IN_TRANSIT
obs = predict.observe(tle, qth, at=at)
self.assertTrue(obs['elevation'] > 0)
Expand Down

0 comments on commit b3444a1

Please sign in to comment.