How to use the sgp4.io.compute_checksum function in sgp4

To help you get started, we’ve selected a few sgp4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brandon-rhodes / python-sgp4 / sgp4 / tests.py View on Github external
def test_good_tle_checksum():
    for line in LINE1, LINE2:
        checksum = int(line[-1])
        assertEqual(io.compute_checksum(line), checksum)
        assertEqual(io.fix_checksum(line[:68]), line)
        io.verify_checksum(line)
github brandon-rhodes / python-sgp4 / sgp4 / exporter.py View on Github external
# Add the Argument of Perigee (deg)
    append("{0:8.4f}".format(satrec.argpo / _deg2rad).rjust(8, " ") + " ")

    # Add the Mean Anomaly (deg)
    append("{0:8.4f}".format(satrec.mo / _deg2rad).rjust(8, " ") + " ")

    # Add the Mean Motion (revs/day)
    append("{0:11.8f}".format(satrec.no_kozai * _xpdotp).rjust(8, " "))

    # Add the rev number at epoch
    append(str(satrec.revnum).rjust(5))

    # Join all the parts and add the Checksum
    line2 = ''.join(pieces)
    line2 += str(compute_checksum(line2))

    return line1, line2
github brandon-rhodes / python-sgp4 / sgp4 / exporter.py View on Github external
# Add Second Time Derivative of Mean Motion (don't use "+")
    # Multiplication with 10 is a hack to get the exponent right
    append("{0: 4.4e}".format((satrec.nddot * (_xpdotp * 1440.0 * 1440)) * 10).replace(".", "")
                        .replace("e+00", "-0").replace("e-0", "-") + " ")

    # Add BSTAR
    # Multiplication with 10 is a hack to get the exponent right
    append("{0: 4.4e}".format(satrec.bstar * 10).replace(".", "").replace("e+00", "+0").replace("e-0", "-") + " ")

    # Add Ephemeris Type and Element Number
    append("{} ".format(satrec.ephtype) + str(satrec.elnum).rjust(4, " "))

    # Join all the parts and add the Checksum
    line1 = ''.join(pieces)
    line1 += str(compute_checksum(line1))

    # --------------------- Start generating line 2 ---------------------

    # Reset the str array
    pieces = ["2 "]
    append = pieces.append

    # Pad the `satnum` entry with zeros
    if len(str(satrec.satnum)) <= 5:
        append(str(satrec.satnum).zfill(5) + " ")

    # Add the inclination (deg)
    append("{0:8.4f}".format(satrec.inclo / _deg2rad).rjust(8, " ") + " ")

    # Add the RAAN (deg)
    append("{0:8.4f}".format(satrec.nodeo / _deg2rad).rjust(8, " ") + " ")