示例#1
0
def massage_qth(qth):
    """ Function for getting correct qth data format. """
    try:
        assert len(qth) == 3, "%s must consist of exactly three elements: (lat(N), long(W), alt(m))" % qth
        return (float(qth[0]), float(qth[1]), int(qth[2]))
    except ValueError as e:
        raise PredictException("Unable to convert '%s' (%s)" % (qth, e))
    except Exception as e:
        raise PredictException(e)
示例#2
0
def host_qth(path="~/.predict/predict.qth"):
    path = os.path.abspath(os.path.expanduser(path))
    try:
        with open(path) as qthfile:
            raw = [l.strip() for l in qthfile.readlines()]
            assert len(
                raw) == 4, "must match:\nname\nlat(N)\nlong(W)\nalt" % path
            return massage_qth(raw[1:])
    except Exception as e:
        raise PredictException("Unable to process qth '%s' (%s)" % (path, e))
示例#3
0
def massage_tle(tle):
    """ Function for getting correct tle data format. """
    try:
        # If tle has not been split yet
        if isinstance(tle, str):
            tle = tle.rstrip().split('\n')
        assert len(tle) == 3, "TLE must be 3 lines, not %d: %s" % (len(tle), tle)
        return tle
    except Exception as e:
        raise PredictException(e)
示例#4
0
def massage_tle(tle):
    try:
        # TLE may or may not have been split into lines already
        if isinstance(tle, basestring):
            tle = tle.rstrip().split('\n')
        assert len(tle) == 3, "TLE must be 3 lines, not %d: %s" % (len(tle),
                                                                   tle)
        return tle
        #TODO: print a warning if TLE is 'too' old
    except Exception as e:
        raise PredictException(e)
示例#5
0
 def at(self, t):
     """ Function to return azimuth and elevation at certain time. """
     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)
示例#6
0
 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)
示例#7
0
 def at(self, t, epsilon=0.001):
     if t < (self.start - epsilon) or t > (self.end + epsilon):
         raise PredictException("time %f outside transit [%f, %f]" %
                                (t, self.start, self.end))
     return observe(self.tle, self.qth, t)