def _populateFrame(self, **kwargs):
        tStart = datetime.datetime.strptime(
            self.metadata['Start Time of Acquisition'], "%d-%b-%Y %H:%M:%S %Z")
        tStop = datetime.datetime.strptime(
            self.metadata['Stop Time of Acquisition'], "%d-%b-%Y %H:%M:%S %Z")
        dtMid = DTU.timeDeltaToSeconds(tStop - tStart) / 2.
        tMid = tStart + datetime.timedelta(microseconds=int(dtMid * 1e6))

        frame = self.frame
        frame.setSensingStart(tStart)
        frame.setSensingStop(tStop)
        frame.setSensingMid(tMid)
        frame.setNumberOfLines(int(self.metadata['slc_mag.set_rows']))
        frame.setNumberOfSamples(int(self.metadata['slc_mag.set_cols']))

        frame.C0 = self.metadata['slc_mag.col_addr']
        frame.S0 = self.metadata['slc_mag.row_addr']

        self.extractDoppler()
        frame.setStartingRange(self.startingRange)
        frame.platformHeight = self.platformHeight

        width = frame.getNumberOfSamples()
        deltaRange = frame.instrument.getRangePixelSize()
        nearRange = frame.getStartingRange()

        frame.setFarRange(nearRange + width * deltaRange)

        frame._ellipsoid = self.elp
        frame.peg = self.peg
        frame.procVelocity = self.velocity

        frame.terrainHeight = self.terrainHeight
        frame.upperLeftCorner = Coordinate()
        frame.upperLeftCorner.setLatitude(
            math.degrees(self.metadata['Approximate Upper Left Latitude']))
        frame.upperLeftCorner.setLongitude(
            math.degrees(self.metadata['Approximate Upper Left Longitude']))
        frame.upperLeftCorner.setHeight(self.terrainHeight)
        frame.upperRightCorner = Coordinate()
        frame.upperRightCorner.setLatitude(
            math.degrees(self.metadata['Approximate Upper Right Latitude']))
        frame.upperRightCorner.setLongitude(
            math.degrees(self.metadata['Approximate Upper Right Longitude']))
        frame.upperRightCorner.setHeight(self.terrainHeight)
        frame.lowerRightCorner = Coordinate()
        frame.lowerRightCorner.setLatitude(
            math.degrees(self.metadata['Approximate Lower Right Latitude']))
        frame.lowerRightCorner.setLongitude(
            math.degrees(self.metadata['Approximate Lower Right Longitude']))
        frame.lowerRightCorner.setHeight(self.terrainHeight)
        frame.lowerLeftCorner = Coordinate()
        frame.lowerLeftCorner.setLatitude(
            math.degrees(self.metadata['Approximate Lower Left Latitude']))
        frame.lowerLeftCorner.setLongitude(
            math.degrees(self.metadata['Approximate Lower Left Longitude']))
        frame.lowerLeftCorner.setHeight(self.terrainHeight)
Exemple #2
0
    def geolocate(self,
                  position=None,
                  velocity=None,
                  range=None,
                  squint=None,
                  side=-1):
        """
        Given a position and velocity vector, along with a range and squint angle,
        return the geolocated coordinate and look angle from the satellite to the ground.

        @param position the cartesian position vector of the satellite [m]
        @param velocity the cartesian velocity vector of the satellite [m/s]
        @param range the range from the satellite to the ground [m]
        @param squint the squint angle of the satellite [radians]
        @param side the look side of the satellite [-1 for right, +1 for left]
        @return (\a tuple) coordinate object, look angle, incidence angle
        """
        from ctypes import cdll, c_double, c_int
        for port in self._inputPorts:
            method = port.getMethod()
            method()

        libgeo = cdll.LoadLibrary(
            os.path.join(os.path.dirname(__file__), 'libgeolocate.so'))

        # inputs
        pos_c = (c_double * len(position))()
        pos_c[:] = position
        vel_c = (c_double * len(velocity))()
        vel_c[:] = velocity
        range_c = c_double(range)
        squint_c = c_double(squint)
        side_c = c_int(side)
        a_c = c_double(self.a)
        e2_c = c_double(self.e2)

        # outputs
        llh_c = (c_double * 3)()
        lookAngle_c = (c_double * 1)()
        incidenceAngle_c = (c_double * 1)()

        # call to c wrapper to fortran subroutine
        # need to modify fortran subroutine to also return lookDirection
        libgeo.geolocate_wrapper(pos_c, vel_c, range_c, squint_c, side_c, a_c,
                                 e2_c, llh_c, lookAngle_c, incidenceAngle_c)

        # extract outputs
        # any issue with float versus double?
        coordinate = Coordinate()
        coordinate.setLatitude(math.degrees(llh_c[0]))
        coordinate.setLongitude(math.degrees(llh_c[1]))
        coordinate.setHeight(llh_c[2])
        lookAngle = math.degrees(lookAngle_c[0])
        incidenceAngle = math.degrees(incidenceAngle_c[0])

        # return outputs
        # proper syntax for return statement?
        return coordinate, lookAngle, incidenceAngle
Exemple #3
0
    def calculatePegPoint(self, frame, orbit, planet):
        """
        Calculate the peg point used as the origin of the SCH coordinate system during focusing.

        @param frame (\a isceobj.Scene.Frame) the Frame object describing the unfocused SAR data
        @param orbit (\a isceobj.Orbit.Orbit) the orbit along which to calculate the peg point
        @param planet (\a isceobj.Planet.Planet) the planet around which the satellite is orbiting
        @return (\a isceobj.Location.Peg) the peg point
        """
        from isceobj.Location.Peg import PegFactory
        from isceobj.Location.Coordinate import Coordinate

        # First, get the orbit nadir location at mid-swath and the end of the scene
        midxyz = orbit.interpolateOrbit(frame.getSensingMid())
        endxyz = orbit.interpolateOrbit(frame.getSensingStop())
        # Next, calculate the satellite heading from the mid-point to the end of the scene
        ellipsoid = planet.get_elp()
        midllh = ellipsoid.xyz_to_llh(midxyz.getPosition())
        endllh = ellipsoid.xyz_to_llh(endxyz.getPosition())
        heading = math.degrees(ellipsoid.geo_hdg(midllh, endllh))
        # Then create a peg point from this data
        coord = Coordinate(latitude=midllh[0], longitude=midllh[1], height=0.0)
        peg = PegFactory.fromEllipsoid(coordinate=coord,
                                       heading=heading,
                                       ellipsoid=ellipsoid)
        self.logger.debug("Peg Point: %s" % (peg))
        return peg
Exemple #4
0
    def __init__(self,family=None,name=None,latitude=None,longitude=None,heading=None,radiusOfCurvature=None):
        """
        @param latitude: the latitude in degrees
        @param longitude: the longitude in degrees
        @param heading: the heading in degrees
        @param radiusOfCurvature: the radius of curvature at the specified coordinates
        """
        #Rember always init the Component class first since it will call the _parameter method
        #and set all defaults.    
        Component.__init__(self,family if family else  self.__class__.family, name=name)

        self._latitude = latitude
        self._longitude = longitude
        self._height = None
        self._heading = heading
        self._radiusOfCurvature = radiusOfCurvature        
        Coordinate.__init__(self,latitude=latitude,longitude=longitude,height=0.0)
Exemple #5
0
 def testFromEllipsoid(self):
     ans = 6356522.8174611665
     coord = Coordinate(latitude=33.5340581084,
                        longitude=-110.699177108,
                        height=0.0)
     peg = PegFactory.fromEllipsoid(coordinate=coord,
                                    heading=-166.483356977,
                                    ellipsoid=self.ellipsoid)
     self.assertAlmostEquals(ans, peg.radiusOfCurvature, 5)
Exemple #6
0
 def createPegInfo(band, track, dire, latS, latE, pegLat, pegLon, hdg):
     PI = PegInfo()
     PI._pegBandIndx = band
     PI._track = track
     PI._direction = dire
     PI._latStart = latS
     PI._latEnd = latE
     PI._peg = PegFactory.fromEllipsoid(Coordinate(pegLat, pegLon), hdg,
                                        PegInfoFactory._Planet.get_elp())
     return PI
Exemple #7
0
 def __init__(self,latitude=None,longitude=None,heading=None,radiusOfCurvature=None):
     """
     @param latitude: the latitude in degrees
     @param longitude: the longitude in degrees
     @param heading: the heading in degrees
     @param radiusOfCurvature: the radius of curvature at the specified coordinates
     """
     
     Component.__init__(self)
     Coordinate.__init__(self,latitude=latitude,longitude=longitude,height=0.0)                        
     self._heading = heading
     self._radiusOfCurvature = radiusOfCurvature
     self.descriptionOfVariables = {}
     self.dictionaryOfVariables = {'LATITUDE': ['_latitude','float','mandatory'],
                                   'LONGITUDE': ['_longitude','float','mandatory'],
                                   'HEIGHT': ['_height','float','mandatory'],
                                   'RADIUS_OF_CURVATURE': ['_radiusOfCurvature','float','mandatory'],
                                   'HEADING': ['_heading','float','mandatory']}
     self.initOptionalAndMandatoryLists()
Exemple #8
0
    def _populateFrame(self):
        #Get the Start, Mid, and Stop times
        import datetime
        tStart = datetime.datetime.strptime(
            self.metadata['Start Time of Acquisition'], "%d-%b-%Y %H:%M:%S %Z")
        tStop = datetime.datetime.strptime(
            self.metadata['Stop Time of Acquisition'], "%d-%b-%Y %H:%M:%S %Z")
        dtMid = DTU.timeDeltaToSeconds(tStop - tStart) / 2.
        tMid = tStart + datetime.timedelta(microseconds=int(dtMid * 1e6))

        frame = self.frame
        frame._frameNumber = 1
        frame._trackNumber = 1
        frame.setSensingStart(tStart)
        frame.setSensingStop(tStop)
        frame.setSensingMid(tMid)
        frame.setNumberOfLines(int(self.metadata['slc_1_1x1_mag.set_rows']))
        frame.setNumberOfSamples(int(self.metadata['slc_1_1x1_mag.set_cols']))
        frame.setPolarization(self.metadata['Polarization'])
        frame.C0 = self.metadata['slc_1_1x1_mag.col_addr']
        frame.S0 = self.metadata['Segment {} Data Starting Azimuth'.format(
            self.segment_index)]
        frame.nearLookAngle = self.metadata['Minimum Look Angle']
        frame.farLookAngle = self.metadata['Maximum Look Angle']
        frame.setStartingRange(self.startingRange)
        frame.platformHeight = self.platformHeight
        width = frame.getNumberOfSamples()
        deltaRange = frame.instrument.getRangePixelSize()
        nearRange = frame.getStartingRange()
        midRange = nearRange + (width / 2.) * deltaRange
        frame.setFarRange(nearRange + width * deltaRange)
        self.extractDoppler()
        frame._ellipsoid = self.elp
        frame.peg = self.peg
        frame.procVelocity = self.velocity

        from isceobj.Location.Coordinate import Coordinate
        frame.upperLeftCorner = Coordinate()

        #The corner latitude, longitudes are given as a pair
        #of values in degrees at each corner (without rdf unit specified)
        llC = []
        for ic in range(1, 5):
            key = 'Segment {0} Data Approximate Corner {1}'.format(
                self.segment_index, ic)
            self.logger.info("key = {}".format(key))
            self.logger.info("metadata[key] = {}".format(
                self.metadata[key], type(self.metadata[key])))
            llC.append(list(map(float, self.metadata[key].split(','))))

        frame.terrainHeight = self.terrainHeight
        frame.upperLeftCorner.setLatitude(llC[0][0])
        frame.upperLeftCorner.setLongitude(llC[0][1])
        frame.upperLeftCorner.setHeight(self.terrainHeight)

        frame.upperRightCorner = Coordinate()
        frame.upperRightCorner.setLatitude(llC[1][0])
        frame.upperRightCorner.setLongitude(llC[1][1])
        frame.upperRightCorner.setHeight(self.terrainHeight)

        frame.lowerRightCorner = Coordinate()
        frame.lowerRightCorner.setLatitude(llC[2][0])
        frame.lowerRightCorner.setLongitude(llC[2][1])
        frame.lowerRightCorner.setHeight(self.terrainHeight)

        frame.lowerLeftCorner = Coordinate()
        frame.lowerLeftCorner.setLatitude(llC[3][0])
        frame.lowerLeftCorner.setLongitude(llC[3][1])
        frame.lowerLeftCorner.setHeight(self.terrainHeight)

        frame.nearLookAngle = math.degrees(self.metadata['Minimum Look Angle'])
        frame.farLookAngle = math.degrees(self.metadata['Maximum Look Angle'])

        return
Exemple #9
0
    def _populateFrameFromPair(self, sip1):
        #        print("UAVSAR_RPI._populateFrameFromPair: metadatafile = ",
        #            self.metadataFile)

        #Get the Start, Mid, and Stop times
        import datetime
        tStart = datetime.datetime.strptime(
            self.metadata['Start Time of Acquisition for Pass ' + sip1],
            "%d-%b-%Y %H:%M:%S %Z")
        tStop = datetime.datetime.strptime(
            self.metadata['Stop Time of Acquisition for Pass ' + sip1],
            "%d-%b-%Y %H:%M:%S %Z")
        dtMid = DTU.timeDeltaToSeconds(tStop - tStart) / 2.
        #        print("dtMid = ", dtMid)
        tMid = tStart + datetime.timedelta(microseconds=int(dtMid * 1e6))
        #        print("tStart = ", tStart)
        #        print("tMid   = ", tMid)
        #        print("tStop  = ", tStop)
        frame = self.frame
        frame.setSensingStart(tStart)
        frame.setSensingStop(tStop)
        frame.setSensingMid(tMid)
        frame.setNumberOfLines(
            int(self.metadata['Single Look Complex Data Azimuth Lines']))
        frame.setNumberOfSamples(
            int(self.metadata['Single Look Complex Data Range Samples']))
        frame.setPolarization(self.metadata['Polarization'])
        frame.C0 = self.metadata['Single Look Complex Data at Near Range']
        frame.S0 = self.metadata['Single Look Complex Data Starting Azimuth']
        frame.nearLookAngle = self.metadata['Average Look Angle in Near Range']
        frame.farLookAngle = self.metadata['Average Look Angle in Far Range']
        #        print("frame.nearLookAngle = ", math.degrees(frame.nearLookAngle))
        #        frame.setStartingAzimuth(frame.S0)
        self.extractDoppler()
        frame.setStartingRange(self.startingRange)
        frame.platformHeight = self.platformHeight
        #        print("platformHeight, startingRange = ", self.platformHeight, frame.getStartingRange())
        width = frame.getNumberOfSamples()
        deltaRange = frame.instrument.getRangePixelSize()
        nearRange = frame.getStartingRange()
        midRange = nearRange + (width / 2.) * deltaRange
        frame.setFarRange(nearRange + width * deltaRange)

        frame.peg = self.peg
        #        print("frame.peg = ", frame.peg)
        frame.procVelocity = self.velocity
        #        print("frame.procVelocity = ", frame.procVelocity)

        from isceobj.Location.Coordinate import Coordinate
        frame.terrainHeight = self.terrainHeight
        frame.upperLeftCorner = Coordinate()
        frame.upperLeftCorner.setLatitude(
            math.degrees(self.metadata['Approximate Upper Left Latitude']))
        frame.upperLeftCorner.setLongitude(
            math.degrees(self.metadata['Approximate Upper Left Longitude']))
        frame.upperLeftCorner.setHeight(self.terrainHeight)
        frame.upperRightCorner = Coordinate()
        frame.upperRightCorner.setLatitude(
            math.degrees(self.metadata['Approximate Upper Right Latitude']))
        frame.upperRightCorner.setLongitude(
            math.degrees(self.metadata['Approximate Upper Right Longitude']))
        frame.upperRightCorner.setHeight(self.terrainHeight)
        frame.lowerRightCorner = Coordinate()
        frame.lowerRightCorner.setLatitude(
            math.degrees(self.metadata['Approximate Lower Right Latitude']))
        frame.lowerRightCorner.setLongitude(
            math.degrees(self.metadata['Approximate Lower Right Longitude']))
        frame.lowerRightCorner.setHeight(self.terrainHeight)
        frame.lowerLeftCorner = Coordinate()
        frame.lowerLeftCorner.setLatitude(
            math.degrees(self.metadata['Approximate Lower Left Latitude']))
        frame.lowerLeftCorner.setLongitude(
            math.degrees(self.metadata['Approximate Lower Left Longitude']))
        frame.lowerLeftCorner.setHeight(self.terrainHeight)

        frame.nearLookAngle = math.degrees(
            self.metadata['Average Look Angle in Near Range'])
        frame.farLookAngle = math.degrees(
            self.metadata['Average Look Angle in Far Range'])

        return