Esempio n. 1
0
    def calculateBasisOffset(self,x1,x2,basis):
        dx = [(x2[j] - x1[j]) for j in range(len(x1))] # Calculate the difference between the master and slave position vectors
        z_offset = MM.dotProduct(dx,basis.getVelocityVector()) # Calculate the length of the projection of the difference in position and the "velocity" component
        v_offset = MM.dotProduct(dx,basis.getPositionVector())
        c_offset = MM.dotProduct(dx,basis.getCrossTrackVector())

        return z_offset,v_offset,c_offset
Esempio n. 2
0
   def fitDoppler(self):
       """Read in a Doppler file, remove outliers and then perform a quadratic fit"""
       self._wrap()
       unw = self._unwrap()
       self.pixelIndex = range(len(self.fractionalDoppler))
       (self.linear['a'], self.linear['b'], self.linear['stdDev']) = MathModule.linearFit(self.pixelIndex, unw)        
       (pixels, unw) = self._cullPoints(self.pixelIndex,unw)
       (self.linear['a'], self.linear['b'], self.linear['stdDev']) = MathModule.linearFit(pixels, unw)        
       (pixels, unw) = self._cullPoints(pixels,unw)
 
       (a,b,c) = MathModule.quadraticFit(pixels,unw)
       self.quadratic['a'] = a  
       self.quadratic['b'] = b  
       self.quadratic['c'] = c
Esempio n. 3
0
    def parameterize(self):
        """
        Read in Doppler estimates, remove outliers and then perform a quadratic fit
        """
        self.pixelIndex = range(len(self.fractionalDoppler))
        (self.linear['a'], self.linear['b'],
         self.linear['stdDev']) = MathModule.linearFit(self.pixelIndex,
                                                       self.unw)
        (pixels, self.unw) = self._cullPoints(self.pixelIndex, self.unw)
        (self.linear['a'], self.linear['b'],
         self.linear['stdDev']) = MathModule.linearFit(pixels, self.unw)
        (pixels, self.unw) = self._cullPoints(pixels, self.unw)

        (a, b, c) = MathModule.quadraticFit(pixels, self.unw)
        self.quadratic['a'] = a
        self.quadratic['b'] = b
        self.quadratic['c'] = c
Esempio n. 4
0
    def __initialize(self):
        s = self.sch[0] / self.peg.getRadiusOfCurvature()
        c = self.sch[1] / self.peg.getRadiusOfCurvature()

        schxyzp = [[0 for i in range(3)] for j in range(3)]
        schxyzp[0][0] = -math.sin(s)
        schxyzp[0][1] = -math.sin(c) * math.cos(s)
        schxyzp[0][1] = math.cos(s) * math.cos(c)
        schxyzp[1][0] = math.cos(s)
        schxyzp[1][1] = -math.sin(c) * math.sin(s)
        schxyzp[1][2] = math.sin(s) * math.cos(c)
        schxyzp[2][0] = 0.0
        schxyzp[2][1] = math.cos(c)
        schxyzp[2][2] = math.sin(c)

        self.sch2xyz = MM.multiplyMatrices(self.M, schxyzp)
        self.xyz2sch = MM.matrixTranspose(self.sch2xyz)
Esempio n. 5
0
    def calculateBasis(self,orbit,time):

        sv = orbit.interpolateOrbit(time, method='hermite')
        x1 = sv.getPosition()
        v = sv.getVelocity()
        r = MM.normalizeVector(x1) # Turn the position vector into a unit vector
        v = MM.normalizeVector(v) # Turn the velocity vector into a unit vector
        c = MM.crossProduct(r,v) # Calculate the vector perpendicular to the platform position and velocity, this is the c, or cross-track vector
        c = MM.normalizeVector(c)
        v = MM.crossProduct(c,r) # Calculate a the "velocity" component that is perpendicular to the cross-track direction and position

        basis = BaselineBasis()
        basis.setPositionVector(r)
        basis.setVelocityVector(v)
        basis.setCrossTrackVector(c)

        return basis
Esempio n. 6
0
    def _integrateBVector(self, date, coordinate, k):
        """
        Integrate the B-field estimates through the ionosphere at the specified date and location

        @param date (\a datetime.datetime) date at which to calculate the B-field
        @param coordinate (\a isceobj.Location.Coordinate) the coordinate at which to calculate the B-field.
        @param k (\a list) the look vector of the radar
        @return (\a float) the integrated value of the B-field at the specified date and location in gauss
        """

        kdotb = []
        n_altitude = int((self.top - self.bottom) / self.step) + 1
        altitude = [self.bottom + i * self.step for i in range(n_altitude)]
        for h in altitude:
            coordinate.setHeight(h)
            bvector = self._calculateBVector(date, coordinate)
            kdotb.append(MM.dotProduct(k, bvector))

        meankdotb = MM.mean(kdotb)

        return meankdotb
Esempio n. 7
0
    def sch_to_xyz(self, sch):
        radcur = self.peg.getRadiusOfCurvature(
        )  # Get the radius of curvature at the peg point
        ellipsoid = Ellipsoid(a=radcur, e2=0.0)

        xyz = [0 for i in range(3)]
        llh = [0 for i in range(3)]

        llh[0] = math.degrees(sch[1] / radcur)
        llh[1] = math.degrees(sch[0] / radcur)
        llh[2] = sch[2]

        schv = ellipsoid.llh_to_xyz(llh)
        schvt = MM.matrixVectorProduct(self.M, schv)

        for i in range(3):
            xyz[i] = schvt[i] + self.r_ov[i]

        return xyz
Esempio n. 8
0
    def xyz_to_sch(self, xyz):
        radcur = self.peg.getRadiusOfCurvature(
        )  # Get the radius of curvature at the peg point
        ellipsoid = Ellipsoid(a=radcur, e2=0.0)

        schvt = [0 for i in range(3)]
        rschv = [0 for i in range(3)]

        for i in range(3):
            schvt[i] = xyz[i] - self.r_ov[i]

        schv = MM.matrixVectorProduct(self.invM, schvt)
        llh = ellipsoid.xyz_to_llh(schv)

        rschv[0] = radcur * math.radians(llh[1])
        rschv[1] = radcur * math.radians(llh[0])
        rschv[2] = llh[2]

        return rschv
Esempio n. 9
0
    def frToTEC(self, date, corners, lookAngle, lookDirection, fc):
        """
        Given a list of geodetic coordinates, a list of lookAngles and a list of lookDirections,
        calculate the average value of the B-field in the radar line-of-sight. Look angles are
        calculated in degrees from the nadir and look directions are calculated in degrees from
        the perpendicular to the flight direction.

        @param date (\a datetime.datetime) the date on which to calculate the B-field
        @param corners (\a list) a list of Location.Coordinate objects specifying the corners of the radar image
        @param lookAngle (\a list) a list of the look angles (in degrees) to each corner of the radar image
        @param lookDirection (\a list) a list of the look directions (in degrees) to each corner of the radar image
        @param fc (\a float) the radar carrier frequency in Hz
        @return (\a float) the mean value of the B-field in the look direction of the radar in gauss
        """
        kdotb = []
        # Calculate the integrated B vector for each of the four corners of the interferogram
        # Need to get the date from any of the Frame objects associated with one of the polarities
        for i, coordinate in enumerate(corners):
            k = self._calculateLookVector(lookAngle[i], lookDirection[i])
            kdotb.append(self._integrateBVector(date, coordinate, k))

        # Use this value to convert from Faraday rotation to TEC
        meankdotb = MM.mean(kdotb)
        self.logger.info("Creating TEC Map")
        self._scaleFRToTEC(meankdotb, fc)

        # Create a resource file for the TEC output file
        rsc = ResourceFile(self.tecOutput + '.rsc')
        rsc.write('WIDTH', self.samples)
        rsc.write('FILE_LENGTH', self.lines)
        rsc.write('MEAN_K_DOT_B', meankdotb)
        rsc.write('LOOK_DIRECTION', lookDirection[0])
        for i in range(len(corners)):
            lattag = 'LAT_CORNER_' + str((i + 1))
            lontag = 'LON_CORNER_' + str((i + 1))
            looktag = 'LOOK_ANGLE_' + str((i + 1))
            rsc.write(lattag, corners[i].getLatitude())
            rsc.write(lontag, corners[i].getLongitude())
            rsc.write(looktag, lookAngle[i])
        rsc.close()

        return meankdotb
Esempio n. 10
0
    def initializeRotationMatrix(self):
        lat = math.radians(self.peg.getLatitude())
        lon = math.radians(self.peg.getLongitude())
        heading = math.radians(self.peg.getHeading())

        self.M[0][0] = math.cos(lat) * math.cos(lon)
        self.M[0][1] = -math.sin(heading) * math.sin(lon) - math.sin(
            lat) * math.cos(lon) * math.cos(heading)
        self.M[0][2] = math.sin(lon) * math.cos(heading) - math.sin(
            lat) * math.cos(lon) * math.sin(heading)
        self.M[1][0] = math.cos(lat) * math.sin(lon)
        self.M[1][1] = math.cos(lon) * math.sin(heading) - math.sin(
            lat) * math.sin(lon) * math.cos(heading)
        self.M[1][2] = -math.cos(lon) * math.cos(heading) - math.sin(
            lat) * math.sin(lon) * math.sin(heading)
        self.M[2][0] = math.sin(lat)
        self.M[2][1] = math.cos(lat) * math.cos(heading)
        self.M[2][2] = math.cos(lat) * math.sin(heading)

        self.invM = MM.matrixTranspose(self.M)
Esempio n. 11
0
    def polynomialFit(self, xRef, yRef):
        size = len(xRef)
        if not (len(xRef) == len(yRef)):
            print("Error. Expecting input vectors of same length.")
            raise Exception
        if not (size == 3):
            print("Error. Expecting input vectors of length 3.")
            raise Exception
        Y = [0] * size
        A = [0] * size
        M = [[0 for i in range(size)] for j in range(size)]
        for j in range(size):
            for i in range(size):
                M[j][i] = math.pow(xRef[j], i)
            Y[j] = yRef[j]
        MInv = MM.invertMatrix(M)
        for i in range(size):
            for j in range(size):
                A[i] += MInv[i][j] * Y[j]

        return A
Esempio n. 12
0
 def testMean(self):
     ans = 2
     mean = MM.mean(self.V)
     self.assertAlmostEquals(mean, ans)
Esempio n. 13
0
 def testMatrixVectorProduct(self):
     ans = [14, 32, 50]
     mV = MM.matrixVectorProduct(self.M, self.V)
     for i in range(3):
         self.assertAlmostEquals(mV[i], ans[i], 5)
Esempio n. 14
0
 def testMatrixTranspose(self):
     ans = [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
     mT = MM.matrixTranspose(self.M)
     for i in range(3):
         for j in range(3):
             self.assertAlmostEquals(mT[i][j], ans[i][j], 5)
Esempio n. 15
0
 def testMultiplyMatrices(self):
     ans = [[6, 12, 18], [15, 30, 45], [24, 48, 72]]
     mM = MM.multiplyMatrices(self.M, self.N)
     for i in range(3):
         for j in range(3):
             self.assertAlmostEquals(mM[i][j], ans[i][j], 5)
Esempio n. 16
0
    def xyz_to_localsch(self, xyz):
        sch = MM.matrixVectorProduct(self.xyz2sch, xyz)

        return sch
Esempio n. 17
0
    def calculateScalarVelocity(self, orbit, time):
        sv = orbit.interpolateOrbit(time)
        v = sv.getVelocity()
        normV = MM.norm(v)

        return normV
Esempio n. 18
0
    def localsch_to_xyz(self, sch):
        xyz = MM.matrixVectorProduct(self.sch2xyz, sch)

        return xyz