Ejemplo n.º 1
0
    def getPegAndHeading(self, orbit, midTime, delta=5000):
        '''Compute the heading of the satellite and peg lat, lon'''

        refElp = Ellipsoid(a=self._planet.ellipsoid.a,
                           e2=self._planet.ellipsoid.e2,
                           model='WGS84')

        #Position just before mid Time
        t1 = midTime - datetime.timedelta(microseconds=delta)
        vec1 = orbit.interpolate(t1, method='hermite')

        #Position just after midTime
        t2 = midTime + datetime.timedelta(microseconds=delta)
        vec2 = orbit.interpolate(t2, method='hermite')

        pos = vec1.getPosition()
        pt1 = refElp.ECEF(pos[0], pos[1], pos[2])
        pos = vec2.getPosition()
        pt2 = refElp.ECEF(pos[0], pos[1], pos[2])

        llh1 = pt1.llh()
        llh2 = pt2.llh()

        #Heading
        hdg = pt1.bearing(pt2)

        #Average lat lon
        peg = refElp.LLH(0.5 * (llh1.lat + llh2.lat),
                         0.5 * (llh1.lon + llh2.lon),
                         0.5 * (llh1.hgt + llh2.hgt))
        return peg, hdg
Ejemplo n.º 2
0
 def getIncidenceAngle(self, zrange=[-200,4000]):
     '''
     Dummy.
     '''
     import numpy as np
     import datetime
     from osgeo import osr,gdal
     from isceobj.Util.geo.ellipsoid import Ellipsoid
     from isceobj.Planet.Planet import Planet
     
     planet = Planet(pname='Earth')
     refElp = Ellipsoid(a=planet.ellipsoid.a, e2=planet.ellipsoid.e2, model='WGS84')
     
     deg2rad = np.pi/180.0
     
     thetas = []
     
     midrng = self.startingRange + (np.floor(self.numberOfSamples/2)-1) * self.rangePixelSize
     midsensing = self.sensingStart + datetime.timedelta(seconds = (np.floor(self.numberOfLines/2)-1) / self.prf)
     masterSV = self.orbit.interpolateOrbit(midsensing, method='hermite')
     mxyz = np.array(masterSV.getPosition())
     
     for zz in zrange:
         llh = self.orbit.rdr2geo(midsensing, midrng, side=self.lookSide, height=zz)
         targxyz = np.array(refElp.LLH(llh[0], llh[1], llh[2]).ecef().tolist())
         los = (mxyz-targxyz) / np.linalg.norm(mxyz-targxyz)
         n_vec = np.array([np.cos(llh[0]*deg2rad)*np.cos(llh[1]*deg2rad), np.cos(llh[0]*deg2rad)*np.sin(llh[1]*deg2rad), np.sin(llh[0]*deg2rad)])
         theta = np.arccos(np.dot(los, n_vec))
         thetas.append([theta])
     
     thetas = np.array(thetas)
     
     self.incidenceAngle = np.mean(thetas)
Ejemplo n.º 3
0
def extractInfoFromPickle(pckfile, inps):
    '''
    Extract required information from pickle file.
    '''
    from isceobj.Planet.Planet import Planet
    from isceobj.Util.geo.ellipsoid import Ellipsoid

    # with open(pckfile, 'rb') as f:
    #    frame = pickle.load(f)

    with shelve.open(pckfile, flag='r') as db:
        # frame = db['swath']
        burst = db['frame']

    #burst = frame.bursts[0]
    planet = Planet(pname='Earth')
    elp = Ellipsoid(planet.ellipsoid.a, planet.ellipsoid.e2, 'WGS84')

    data = {}
    data['wavelength'] = burst.radarWavelegth

    sv = burst.orbit.interpolateOrbit(burst.sensingMid, method='hermite')
    pos = sv.getPosition()
    llh = elp.ECEF(pos[0], pos[1], pos[2]).llh()

    data['altitude'] = llh.hgt

    hdg = burst.orbit.getHeading()
    data['earthRadius'] = elp.local_radius_of_curvature(llh.lat, hdg)

    #azspacing  = burst.azimuthTimeInterval * sv.getScalarVelocity()
    #azres = 20.0
    azspacing = sv.getScalarVelocity() / burst.PRF
    azres = burst.platform.antennaLength / 2.0
    azfact = azres / azspacing

    burst.getInstrument()
    rgBandwidth = burst.instrument.pulseLength * burst.instrument.chirpSlope
    rgres = abs(SPEED_OF_LIGHT / (2.0 * rgBandwidth))
    rgspacing = burst.instrument.rangePixelSize
    rgfact = rgres / rgspacing

    #data['corrlooks'] = inps.rglooks * inps.azlooks * azspacing / azres
    data['corrlooks'] = inps.rglooks * inps.azlooks / (azfact * rgfact)
    data['rglooks'] = inps.rglooks
    data['azlooks'] = inps.azlooks

    return data
Ejemplo n.º 4
0
def extractInfo(xmlName, inps):
    '''
    Extract required information from pickle file.
    '''
    from isceobj.Planet.Planet import Planet
    from isceobj.Util.geo.ellipsoid import Ellipsoid

    frame = ut.loadProduct(xmlName)

    burst = frame.bursts[0]
    planet = Planet(pname='Earth')
    elp = Ellipsoid(planet.ellipsoid.a, planet.ellipsoid.e2, 'WGS84')

    data = {}
    data['wavelength'] = burst.radarWavelength

    tstart = frame.bursts[0].sensingStart
    tend   = frame.bursts[-1].sensingStop
    #tmid = tstart + 0.5*(tend - tstart)
    tmid = tstart


    orbit = burst.orbit
    peg = orbit.interpolateOrbit(tmid, method='hermite')

    refElp = Planet(pname='Earth').ellipsoid
    llh = refElp.xyz_to_llh(peg.getPosition())
    hdg = orbit.getENUHeading(tmid)
    refElp.setSCH(llh[0], llh[1], hdg)

    earthRadius = refElp.pegRadCur

    altitude   = llh[2]


    #sv = burst.orbit.interpolateOrbit(tmid, method='hermite')
    #pos = sv.getPosition()
    #llh = elp.ECEF(pos[0], pos[1], pos[2]).llh()

    data['altitude'] = altitude  #llh.hgt

    #hdg = burst.orbit.getHeading()
    data['earthRadius'] = earthRadius  #elp.local_radius_of_curvature(llh.lat, hdg)
    
    #azspacing  = burst.azimuthTimeInterval * sv.getScalarVelocity()
    #azres = 20.0 

    #corrfile  = os.path.join(self._insar.mergedDirname, self._insar.coherenceFilename)
    rangeLooks = inps.rglooks
    azimuthLooks = inps.azlooks
    azfact = 0.8
    rngfact = 0.8

    corrLooks = rangeLooks * azimuthLooks/(azfact*rngfact)

    data['corrlooks'] = corrLooks  #inps.rglooks * inps.azlooks * azspacing / azres
    data['rglooks'] = inps.rglooks
    data['azlooks'] = inps.azlooks

    return data
Ejemplo n.º 5
0
def extractInfoFromPickle(pckfile, inps):
    '''
    Extract required information from pickle file.
    '''
    from isceobj.Planet.Planet import Planet
    from isceobj.Util.geo.ellipsoid import Ellipsoid

    # with open(pckfile, 'rb') as f:
    #    frame = pickle.load(f)

    with shelve.open(pckfile, flag='r') as db:
        # frame = db['swath']
        burst = db['frame']

    #burst = frame.bursts[0]
    planet = Planet(pname='Earth')
    elp = Ellipsoid(planet.ellipsoid.a, planet.ellipsoid.e2, 'WGS84')

    data = {}
    data['wavelength'] = burst.radarWavelegth

    sv = burst.orbit.interpolateOrbit(burst.sensingMid, method='hermite')
    pos = sv.getPosition()
    llh = elp.ECEF(pos[0], pos[1], pos[2]).llh()

    data['altitude'] = llh.hgt

    hdg = burst.orbit.getHeading()
    data['earthRadius'] = elp.local_radius_of_curvature(llh.lat, hdg)

    #azspacing  = burst.azimuthTimeInterval * sv.getScalarVelocity()
    azres = 20.0

    #data['corrlooks'] = inps.rglooks * inps.azlooks * azspacing / azres
    data['rglooks'] = inps.rglooks
    data['azlooks'] = inps.azlooks

    return data
Ejemplo n.º 6
0
def extractInfo(inps):
    '''
    Extract required information
    '''
    from isceobj.Planet.Planet import Planet
    from isceobj.Util.geo.ellipsoid import Ellipsoid


    planet = Planet(pname='Earth')
    elp = Ellipsoid(planet.ellipsoid.a, planet.ellipsoid.e2, 'WGS84')

    # for now hard-code default..., can be set to zero for deformation but for height related work needs to be actuals...
    hgt = 0
    lat = 0
    hdg = 0
    wavelength = 0.056   
    data ={}
    data['wavelength'] = wavelength
    data['altitude'] = hgt
    data['earthRadius'] = elp.local_radius_of_curvature(lat, hdg)
    data['rglooks'] = inps.rglooks
    data['azlooks'] = inps.azlooks

    return data
Ejemplo n.º 7
0
def extractInfo(inps):
    '''
    Extract required information from pickle file.
    '''
    from isceobj.Planet.Planet import Planet
    from isceobj.Util.geo.ellipsoid import Ellipsoid
    from iscesys.Component.ProductManager import ProductManager as PM

    pm = PM()
    #pm.configure
    frame = pm.loadProduct(inps.xmlFile)

    burst = frame.bursts[0]
    planet = Planet(pname='Earth')
    elp = Ellipsoid(planet.ellipsoid.a, planet.ellipsoid.e2, 'WGS84')

    data = {}
    data['wavelength'] = burst.radarWavelength

    tstart = frame.bursts[0].sensingStart
    #tend   = frame.bursts[-1].sensingStop
    #tmid = tstart + 0.5*(tend - tstart)
    tmid = tstart

    orbit = burst.orbit
    peg = orbit.interpolateOrbit(tmid, method='hermite')

    refElp = Planet(pname='Earth').ellipsoid
    llh = refElp.xyz_to_llh(peg.getPosition())
    hdg = orbit.getENUHeading(tmid)
    refElp.setSCH(llh[0], llh[1], hdg)

    earthRadius = refElp.pegRadCur

    altitude = llh[2]

    #sv = burst.orbit.interpolateOrbit(tmid, method='hermite')
    #pos = sv.getPosition()
    #llh = elp.ECEF(pos[0], pos[1], pos[2]).llh()

    data['altitude'] = altitude  #llh.hgt

    #hdg = burst.orbit.getHeading()
    data[
        'earthRadius'] = earthRadius  #elp.local_radius_of_curvature(llh.lat, hdg)
    return data
Ejemplo n.º 8
0
    def baseline(self):

        from isceobj.Util.geo.ellipsoid import Ellipsoid
        from isceobj.Planet.Planet import Planet
        for port in self.inputPorts:
            port()

        planet = Planet(pname='Earth')
        refElp = Ellipsoid(a=planet.ellipsoid.a,
                           e2=planet.ellipsoid.e2,
                           model='WGS84')

        if self.baselineLocation.lower() == 'all':
            print('Using entire span of image for estimating baselines')
            masterTime = [
                self.masterFrame.getSensingStart(),
                self.masterFrame.getSensingMid(),
                self.masterFrame.getSensingStop()
            ]
        elif self.baselineLocation.lower() == 'middle':
            print('Estimating baselines around center of master image')
            masterTime = [
                self.masterFrame.getSensingMid() -
                datetime.timedelta(seconds=1.0),
                self.masterFrame.getSensingMid(),
                self.masterFrame.getSensingMid() +
                datetime.timedelta(seconds=1.0)
            ]

        elif self.baselineLocation.lower() == 'top':
            print('Estimating baselines at top of master image')
            masterTime = [
                self.masterFrame.getSensingStart(),
                self.masterFrame.getSensingStart() +
                datetime.timedelta(seconds=1.0),
                self.masterFrame.getSensingStart() +
                datetime.timedelta(seconds=2.0)
            ]
        elif self.baselineLocation.lower() == 'bottom':
            print('Estimating baselines at bottom of master image')
            masterTime = [
                self.masterFrame.getSensingStop() -
                datetime.timedelta(seconds=2.0),
                self.masterFrame.getSensingStop() -
                datetime.timedelta(seconds=1.0),
                self.masterFrame.getSensingStop()
            ]
        else:
            raise Exception('Unknown baseline location: {0}'.format(
                self.baselineLocation))

        s = [0., 0., 0.]
        bpar = []
        bperp = []
        azoff = []
        rgoff = []

        for i in range(3):
            # Calculate the Baseline at the start of the scene, mid-scene, and the end of the scene
            # First, get the position and velocity at the start of the scene
            # Calculate the distance moved since the last baseline point
            s[i] = (masterTime[i] - masterTime[0]).total_seconds()

            masterSV = self.masterOrbit.interpolateOrbit(masterTime[i],
                                                         method='hermite')
            rng = self.startingRange1
            target = self.masterOrbit.pointOnGround(
                masterTime[i],
                rng,
                side=self.masterFrame.getInstrument().getPlatform(
                ).pointingDirection)

            slaveTime, slvrng = self.slaveOrbit.geo2rdr(target)
            slaveSV = self.slaveOrbit.interpolateOrbit(slaveTime,
                                                       method='hermite')

            targxyz = np.array(
                refElp.LLH(target[0], target[1], target[2]).ecef().tolist())
            mxyz = np.array(masterSV.getPosition())
            mvel = np.array(masterSV.getVelocity())
            sxyz = np.array(slaveSV.getPosition())
            mvelunit = mvel / np.linalg.norm(mvel)
            sxyz = sxyz - np.dot(sxyz - mxyz, mvelunit) * mvelunit

            aa = np.linalg.norm(sxyz - mxyz)

            costheta = (rng * rng + aa * aa - slvrng * slvrng) / (2. * rng *
                                                                  aa)

            #            print(aa, costheta)
            bpar.append(aa * costheta)

            perp = aa * np.sqrt(1 - costheta * costheta)
            direction = np.sign(
                np.dot(np.cross(targxyz - mxyz, sxyz - mxyz), mvel))
            bperp.append(direction * perp)

            ####Azimuth offset
            slvaz = (slaveTime -
                     self.slaveFrame.sensingStart).total_seconds() * self.prf2
            masaz = s[i] * self.prf1
            azoff.append(slvaz - masaz)

            ####Range offset
            slvrg = (slvrng - self.startingRange2) / self.rangePixelSize2
            masrg = (rng - self.startingRange1) / self.rangePixelSize1
            rgoff.append(slvrg - masrg)

#        print(bpar)
#        print(bperp)

#Calculating baseline
        parBaselinePolynomialCoefficients = np.polyfit(s, bpar, 2)
        perpBaselinePolynomialCoefficients = np.polyfit(s, bperp, 2)

        # Populate class attributes
        self.BparMean = parBaselinePolynomialCoefficients[-1]
        self.BparRate = parBaselinePolynomialCoefficients[1]
        self.BparAcc = parBaselinePolynomialCoefficients[0]
        self.BperpMean = perpBaselinePolynomialCoefficients[-1]
        self.BperpRate = perpBaselinePolynomialCoefficients[1]
        self.BperpAcc = perpBaselinePolynomialCoefficients[0]

        delta = (self.masterFrame.getSensingStart() -
                 masterTime[0]).total_seconds()
        self.BparTop = np.polyval(parBaselinePolynomialCoefficients, delta)
        self.BperpTop = np.polyval(perpBaselinePolynomialCoefficients, delta)

        delta = (self.masterFrame.getSensingStop() -
                 masterTime[0]).total_seconds()
        self.BparBottom = np.polyval(parBaselinePolynomialCoefficients, delta)
        self.BperpBottom = np.polyval(perpBaselinePolynomialCoefficients,
                                      delta)

        return azoff, rgoff