def calc(pos, bearing): segments = [pos] lastPos = pos for index in range(0, len(satelliteInfos)-1): pingInterval = satelliteInfos[index]['NextPingTimeOffset'] newPos = Geo.greatCircleDestination(lastPos, bearing, Geo.nmToKm((pingInterval/60.0)*aircraftGroundSpeed)) satelliteRange = Geo.greatCircleDistance(newPos, satelliteInfos[index+1]['LatLon']) if math.fabs(satelliteRange - satelliteInfos[index+1]['PingRadius']) < pingRingDiffError * satelliteInfos[index+1]['PingRadius']: if filterUsingDoppler: aircraftECEF = Geo.sphericalToECEF(newPos) aircraftECEFVel = Geo.ecefVelocities(newPos, Geo.knotsToKms(aircraftGroundSpeed), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index+1]['XYZ'], satelliteInfos[index+1]['Velocity'], aircraftECEF, aircraftECEFVel) * -1.0 if math.fabs(LOSSpeed - satelliteInfos[index+1]['LOSSpeed']) < math.fabs(dopplerDiffError * satelliteInfos[index+1]['LOSSpeed']): segments.append(newPos) lastPos = newPos else: break else: segments.append(newPos) lastPos = newPos else: break if len(segments) == 5: for index in range(1, len(satelliteInfos)): segmentPos = segments[index] ax.scatter(segmentPos[1], segmentPos[0], c=satelliteInfos[index]['Color']) prevSegmentPos = segments[index-1] ax.plot([prevSegmentPos[1], segmentPos[1]], [prevSegmentPos[0], segmentPos[0]])
def check(groundspeed, bearing, positions): print("Aircraft groundspeed: %f Bearing: %f" % (groundspeed, bearing)) for index, aircraftPos in enumerate(positions): aircraftECEF = Geo.sphericalToECEF(aircraftPos) aircraftECEFVel = Geo.ecefVelocities(aircraftPos, Geo.knotsToKms(groundspeed), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index]['XYZ'], satelliteInfos[index]['Velocity'], aircraftECEF, aircraftECEFVel) pingRadius = Geo.greatCircleDistance(aircraftPos, satelliteInfos[index]['LatLon']) print(aircraftPos, Geo.KmsToKmh(LOSSpeed), Geo.KmsToKnots(LOSSpeed), Geo.kmToNm(pingRadius))
def groundCheckGeoSat(groundspeed, bearing, aircraftPos): aircraftECEF = Geo.sphericalToECEF(aircraftPos) aircraftECEFVel = Geo.ecefVelocities(aircraftPos, groundspeed, bearing) LOSSpeed = Geo.LOSSpeed(satelliteGeo['XYZ'], satelliteGeo['Velocity'], aircraftECEF, aircraftECEFVel) print(Geo.KmsToKnots(LOSSpeed), Geo.KmsToKnots(LOSSpeed) * 2.82)
track4 = [(11.743,95.841), (16.006,96.291), (20.271,96.740), (24.536,97.190), (31.008,97.873)] check(257.4, 6.02, track4) # GlobusMax digitized southern track print('GlobusMax 454 Southern Check') track5 = [(-3.28,93.25), (-10.67,91.68), (-18.18,90.72), (-25.71,90.10), (-37.13,88.91)] lastBearing = 0.0 for index, pos in enumerate(track5): if index < len(track5)-1: bearing = Geo.bearing(pos, track5[index+1]) lastBearing = bearing else: bearing = lastBearing aircraftECEF = Geo.sphericalToECEF(pos) aircraftECEFVel = Geo.ecefVelocities(pos, Geo.knotsToKms(454), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index]['XYZ'], satelliteInfos[index]['Velocity'], aircraftECEF, aircraftECEFVel) * -1.0 print(pos, bearing, Geo.kmToNm(Geo.greatCircleDistance(pos,satelliteInfos[index]['LatLon'])), Geo.KmsToKnots(LOSSpeed)) print('GlobusMax 394 Southern Check') track6 = [(0.63,93.47), (-5.92,93.69), (-12.47,94.01), (-18.73,96.02), (-28.28,99.06)] lastBearing = 0.0 for index, pos in enumerate(track6): if index < len(track6)-1: bearing = Geo.bearing(pos, track6[index+1]) lastBearing = bearing else: bearing = lastBearing aircraftECEF = Geo.sphericalToECEF(pos)
# Iterate over the starting points for pos in startingPoints: for bearing in matplotlib.mlab.frange(0, 359, bearingIncrement): #for bearing in range(90, 270, 1): segments = [pos] lastPos = pos sog = float(aircraftGroundSpeed) for index in range(0, len(satelliteInfos)-1): pingInterval = satelliteInfos[index]['NextPingTimeOffset'] newPos = Geo.greatCircleDestination(lastPos, bearing, Geo.nmToKm((pingInterval/60.0)*sog)) satelliteRange = Geo.greatCircleDistance(newPos, satelliteInfos[index+1]['LatLon']) if math.fabs(satelliteRange - satelliteInfos[index+1]['PingRadius']) < pingRingDiffError * satelliteInfos[index+1]['PingRadius']: if filterUsingDoppler: aircraftECEF = Geo.sphericalToECEF(newPos) aircraftECEFVel = Geo.ecefVelocities(newPos, Geo.knotsToKms(sog), bearing) LOSSpeed = Geo.LOSSpeed(satelliteInfos[index+1]['XYZ'], satelliteInfos[index+1]['Velocity'], aircraftECEF, aircraftECEFVel) * -1.0 if math.fabs(LOSSpeed - satelliteInfos[index+1]['LOSSpeed']) < math.fabs(dopplerDiffError * satelliteInfos[index+1]['LOSSpeed']): segments.append(newPos) lastPos = newPos else: break else: segments.append(newPos) lastPos = newPos else: break sog *= speed_accelerator if len(segments) == 5: for index in range(1, len(satelliteInfos)): segmentPos = segments[index]