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
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)
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