From 710a60f122b9f7fe8945630844b2a6d8efc4d327 Mon Sep 17 00:00:00 2001 From: Borden Liu Date: Tue, 2 Feb 2016 11:28:38 -0800 Subject: [PATCH] minor update * remove tle method * add newlines to output * remove epsilon check for predict --- predict.c | 8 ++++---- predict.py | 17 ++--------------- setup.py | 15 +++++++-------- test.py | 4 ++-- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/predict.c b/predict.c index 6c8e0b9..b643a9b 100644 --- a/predict.c +++ b/predict.c @@ -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 ((daynumnow+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; } @@ -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; } diff --git a/predict.py b/predict.py index 952af14..f2cee23 100644 --- a/predict.py +++ b/predict.py @@ -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: @@ -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 @@ -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) diff --git a/setup.py b/setup.py index c7f2709..5fd4b80 100755 --- a/setup.py +++ b/setup.py @@ -2,12 +2,11 @@ from distutils.core import setup, Extension setup( - name='pypredict', - version='1.1', - author="Jesse Trutna", - author_email="jesse@spire.com", - 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="jesse@spire.com", + url="https://github.com/nsat/pypredict", + py_modules=['predict'], + ext_modules=[Extension('cpredict', ['predict.c'])] ) - diff --git a/test.py b/test.py index d535ae3..7f79782 100755 --- a/test.py +++ b/test.py @@ -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 @@ -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)