Example #1
0
    def test_bad_second_line(self):
        with self.assertRaisesRegex(
                ValueError,
                re.escape("""TLE format error

The Two-Line Element (TLE) format was designed for punch cards, and so
is very strict about the position of every period, space, and digit.
Your line does not quite match.  Here is the official format for line 2
with an N where each digit should go, followed by the line you provided:

2 NNNNN NNN.NNNN NNN.NNNN NNNNNNN NNN.NNNN NNN.NNNN NN.NNNNNNNNNNNNNN
2 00005 34 .268234 8.7242 1859667 331.7664  19.3264 10.82419157413667""")):
            io.twoline2rv(good1, good2.replace(' 34', '34 '), wgs72)
Example #2
0
    def test_bad_first_line(self):
        with self.assertRaisesRegex(
                ValueError,
                re.escape("""TLE format error

The Two-Line Element (TLE) format was designed for punch cards, and so
is very strict about the position of every period, space, and digit.
Your line does not quite match.  Here is the official format for line 1
with an N where each digit should go, followed by the line you provided:

1 NNNNNC NNNNNAAA NNNNN.NNNNNNNN +.NNNNNNNN +NNNNN-N +NNNNN-N N NNNNN
1 00005U 58002B   00179.78495062  .000000234 00000-0  28098-4 0  4753""")):
            io.twoline2rv(good1.replace('23 ', '234'), good2, wgs72)
Example #3
0
def generate_test_output(whichconst, error_list):
    """Generate lines like those in the test file tcppver.out.

    This iterates through the satellites in "SGP4-VER.TLE", which are
    each supplemented with a time start/stop/step over which we are
    supposed to print results.

    """
    whichconst = wgs72
    tlepath = os.path.join(thisdir, 'SGP4-VER.TLE')
    with open(tlepath) as tlefile:
        tlelines = iter(tlefile.readlines())

    for line1 in tlelines:

        if not line1.startswith('1'):
            continue

        line2 = next(tlelines)
        satrec = io.twoline2rv(line1, line2, whichconst)

        yield '%ld xx\n' % (satrec.satnum, )

        for line in generate_satellite_output(satrec, line2, error_list):
            yield line
Example #4
0
 def __init__(self, text, earth):
     lines = text.splitlines()
     sat = twoline2rv(*lines[-2:], whichconst=wgs72)
     self._sgp4_satellite = sat
     self._earth = earth
     self.epoch = JulianDate(utc=(sat.epochyr, 1, sat.epochdays - 1.0))
Example #5
0
 def test_mismatched_lines(self):
     msg = "Object numbers in lines 1 and 2 do not match"
     with self.assertRaisesRegex(ValueError, re.escape(msg)):
         io.twoline2rv(good1, bad2, wgs72)
Example #6
0
from earth_gravity import wgs72
from sgp4io import twoline2rv

line1 = (
    '1 43013U 17073A   19261.50913870  .00000008  00000-0  24702-4 0  9998')
line2 = (
    '2 43013  98.7245 198.2889 0001389  73.3480 286.7849 14.19543304 94932')

satellite = twoline2rv(line1, line2, wgs72)
position, velocity = satellite.propagate(2000, 6, 29, 12, 50, 19)

print(position)
print(velocity)