예제 #1
0
def footprintFromPickle():
    insar = pickle.load(open('PICKLE/preprocess', 'rb'))
    planet = insar.masterFrame.getInstrument().getPlatform().getPlanet()
    earlySquint = insar.masterFrame._squintAngle
    orbit = insar.masterFrame.getOrbit()
    lookSide = int(
        insar.masterFrame.getInstrument().getPlatform().pointingDirection)
    geolocate = Geolocate()
    geolocate.wireInputPort(name='planet', object=planet)
    nearRange = insar.masterFrame.getStartingRange()
    farRange = insar.masterFrame.getFarRange()
    earlyStateVector = orbit.interpolateOrbit(
        insar.masterFrame.getSensingStart())
    lateStateVector = orbit.interpolateOrbit(
        insar.masterFrame.getSensingStop())
    nearEarlyCorner, nearEarlyLookAngle, nearEarlyIncAngle = geolocate.geolocate(
        earlyStateVector.getPosition(), earlyStateVector.getVelocity(),
        nearRange, earlySquint, lookSide)
    farEarlyCorner, farEarlyLookAngle, farEarlyIncAngle = geolocate.geolocate(
        earlyStateVector.getPosition(), earlyStateVector.getVelocity(),
        farRange, earlySquint, lookSide)
    nearLateCorner, nearLateLookAngle, nearLateIncAngle = geolocate.geolocate(
        lateStateVector.getPosition(), lateStateVector.getVelocity(),
        nearRange, earlySquint, lookSide)
    farLateCorner, farLateLookAngle, farLateIncAngle = geolocate.geolocate(
        lateStateVector.getPosition(), lateStateVector.getVelocity(), farRange,
        earlySquint, lookSide)
    wkt = "POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))" % (
        nearEarlyCorner.getLongitude(), nearEarlyCorner.getLatitude(),
        farEarlyCorner.getLongitude(), farEarlyCorner.getLatitude(),
        farLateCorner.getLongitude(), farLateCorner.getLatitude(),
        nearLateCorner.getLongitude(), nearLateCorner.getLatitude(),
        nearEarlyCorner.getLongitude(), nearEarlyCorner.getLatitude())
    return wkt
예제 #2
0
class test_geolocate(unittest.TestCase):
    def setUp(self):
        # These are the state vectors for ERS-1 track 113 frame 2745 from 1993 01 09 near the scene start time
        self.pos = [-2503782.263, -4652987.799, 4829281.081]
        self.vel = [-4002.34200000018, -3450.91900000069, -5392.36600000039]
        self.range = 831929.866545593
        self.squint = 0.298143953340833
        planet = Planet(pname='Earth')

        self.geolocate = Geolocate()
        self.geolocate.wireInputPort(name='planet', object=planet)

    def tearDown(self):
        pass

    def testGeolocate(self):
        ans = [42.457487, -121.276432]

        loc, lla, lia = self.geolocate.geolocate(self.pos, self.vel,
                                                 self.range, self.squint)

        lat = loc.getLatitude()
        lon = loc.getLongitude()
        self.assertAlmostEquals(lat, ans[0], 5)
        self.assertAlmostEquals(lon, ans[1], 5)

    def testLookAngle(self):
        ans = 17.2150393
        loc, lla, lia = self.geolocate.geolocate(self.pos, self.vel,
                                                 self.range, self.squint)

        self.assertAlmostEquals(lla, ans, 5)
예제 #3
0
    def calculateCorners(self):
        """
        Calculate the approximate geographic coordinates of corners of the SAR image.

        @return (\a tuple) a list with the corner coordinates and a list with the look angles to these coordinates
        """
        # Extract the planet from the hh object
        planet = self.hhObj.getFrame().getInstrument().getPlatform().getPlanet(
        )
        # Wire up the geolocation object
        geolocate = Geolocate()
        geolocate.wireInputPort(name='planet', object=planet)

        # Get the ranges, squints and state vectors that defined the boundaries of the frame
        orbit = self.hhObj.getFrame().getOrbit()
        nearRange = self.hhObj.getFrame().getStartingRange()
        farRange = self.hhObj.getFrame().getFarRange()
        earlyStateVector = orbit.interpolateOrbit(
            self.hhObj.getFrame().getSensingStart())
        lateStateVector = orbit.interpolateOrbit(
            self.hhObj.getFrame().getSensingStop())
        earlySquint = 0.0  # assume a zero squint angle
        nearEarlyCorner, nearEarlyLookAngle, nearEarlyIncAngle = geolocate.geolocate(
            earlyStateVector.getPosition(), earlyStateVector.getVelocity(),
            nearRange, earlySquint)
        farEarlyCorner, farEarlyLookAngle, farEarlyIncAngle = geolocate.geolocate(
            earlyStateVector.getPosition(), earlyStateVector.getVelocity(),
            farRange, earlySquint)
        nearLateCorner, nearLateLookAngle, nearLateIncAngle = geolocate.geolocate(
            lateStateVector.getPosition(), lateStateVector.getVelocity(),
            nearRange, earlySquint)
        farLateCorner, farLateLookAngle, farLateIncAngle = geolocate.geolocate(
            lateStateVector.getPosition(), lateStateVector.getVelocity(),
            farRange, earlySquint)
        self.logger.debug("Near Early Corner: %s" % nearEarlyCorner)
        self.logger.debug("Near Early Look Angle: %s" % nearEarlyLookAngle)
        self.logger.debug("Near Early Incidence Angle: %s " %
                          nearEarlyIncAngle)

        self.logger.debug("Far Early Corner: %s" % farEarlyCorner)
        self.logger.debug("Far Early Look Angle: %s" % farEarlyLookAngle)
        self.logger.debug("Far Early Incidence Angle: %s" % farEarlyIncAngle)

        self.logger.debug("Near Late Corner: %s" % nearLateCorner)
        self.logger.debug("Near Late Look Angle: %s" % nearLateLookAngle)
        self.logger.debug("Near Late Incidence Angle: %s" % nearLateIncAngle)

        self.logger.debug("Far Late Corner: %s" % farLateCorner)
        self.logger.debug("Far Late Look Angle: %s" % farLateLookAngle)
        self.logger.debug("Far Late Incidence Angle: %s" % farLateIncAngle)

        corners = [
            nearEarlyCorner, farEarlyCorner, nearLateCorner, farLateCorner
        ]
        lookAngles = [
            nearEarlyLookAngle, farEarlyLookAngle, nearLateLookAngle,
            farLateLookAngle
        ]
        return corners, lookAngles
예제 #4
0
    def makeLookIncidenceFiles(self):
        """
        Make files containing the look and incidence angles to test the antenna pattern calibration
        """
        import array
        import datetime
        # Extract the planet from the hh object
        planet = self.hhObj.getFrame().getInstrument().getPlatform().getPlanet(
        )

        # Wire up the geolocation object
        geolocate = Geolocate()
        geolocate.wireInputPort(name='planet', object=planet)
        # Get the ranges, squints and state vectors that defined the boundaries of the frame
        orbit = self.hhObj.getFrame().getOrbit()
        nearRange = self.hhObj.getFrame().getStartingRange()
        deltaR = self.hhObj.getFrame().getInstrument().getRangePixelSize()
        prf = self.hhObj.getFrame().getInstrument(
        ).getPulseRepetitionFrequency()
        pri = 1.0 / prf
        squint = 0.0  # assume a zero squint angle

        lookFP = open('look.dat', 'wb')
        incFP = open('inc.dat', 'wb')

        # Calculate the variation in look angle and incidence angle for the first range line
        time = self.hhObj.getFrame().getSensingStart(
        )  # + datetime.timedelta(microseconds=int(j*pri*1e6))
        sv = orbit.interpolateOrbit(time=time)
        look = array.array('f')
        inc = array.array('f')
        for i in range(self.width):
            rangeDistance = nearRange + i * deltaR
            coordinate, lookAngle, incidenceAngle = geolocate.geolocate(
                sv.getPosition(), sv.getVelocity(), rangeDistance, squint)
            look.append(lookAngle)
            inc.append(incidenceAngle)

        # Use the first range line as a proxy for the remaining lines
        for j in range(self.length):
            look.tofile(lookFP)
            inc.tofile(incFP)

        lookFP.close()
        incFP.close()
예제 #5
0
def footprintFromPickle():
    insar = pickle.load(open('PICKLE/preprocess','rb'))
    planet = insar.masterFrame.getInstrument().getPlatform().getPlanet()
    earlySquint = insar.masterFrame._squintAngle
    orbit = insar.masterFrame.getOrbit()
    lookSide = int(insar.masterFrame.getInstrument().getPlatform().pointingDirection)
    geolocate = Geolocate()
    geolocate.wireInputPort(name='planet',object=planet)
    nearRange = insar.masterFrame.getStartingRange()
    farRange = insar.masterFrame.getFarRange()
    earlyStateVector = orbit.interpolateOrbit(insar.masterFrame.getSensingStart())
    lateStateVector = orbit.interpolateOrbit(insar.masterFrame.getSensingStop())
    nearEarlyCorner,nearEarlyLookAngle,nearEarlyIncAngle =geolocate.geolocate(earlyStateVector.getPosition(),earlyStateVector.getVelocity(),nearRange,earlySquint,lookSide)
    farEarlyCorner,farEarlyLookAngle,farEarlyIncAngle = geolocate.geolocate(earlyStateVector.getPosition(),earlyStateVector.getVelocity(),farRange,earlySquint,lookSide)
    nearLateCorner,nearLateLookAngle,nearLateIncAngle = geolocate.geolocate(lateStateVector.getPosition(),lateStateVector.getVelocity(),nearRange,earlySquint,lookSide)
    farLateCorner,farLateLookAngle,farLateIncAngle = geolocate.geolocate(lateStateVector.getPosition(),lateStateVector.getVelocity(),farRange,earlySquint,lookSide)
    wkt = "POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))" % ( nearEarlyCorner.getLongitude(),nearEarlyCorner.getLatitude(),farEarlyCorner.getLongitude(),farEarlyCorner.getLatitude(),farLateCorner.getLongitude(),farLateCorner.getLatitude(), nearLateCorner.getLongitude(),nearLateCorner.getLatitude(),nearEarlyCorner.getLongitude(),nearEarlyCorner.getLatitude() )
    return wkt