Ejemplo n.º 1
0
    def testGeodeticConversionsArray(self):
        lat, lon = np.mgrid[-89:89:5, -179:179:5]
        x, y, z = geodetic2EcefZero(np.deg2rad(lat), np.deg2rad(lon))

        r = ecef2Geodetic(x, y, z)
        #print np.rad2deg(r)
        assert_array_almost_equal(np.rad2deg(r), [lat, lon], 11)
Ejemplo n.º 2
0
def reproject(latLonASI, latsRef, lonsRef, heightRef, heightNew):
    """
    
    :param latLonASI: tuple of latitude,longitude of ASI
    :param latsRef: latitudes of pixel corners for reference height in degrees
    :param lonsRef: longitudes of pixel corners for reference height in degrees
    :param heightRef: reference height in km (above ground)
    :param heightNew: new height in km (above ground)
    :rtype: tuple of reprojected latitudes and longitudes 
    """
    latASI, lonASI = latLonASI
    xASI, yASI, zASI = geodetic2EcefZero(np.deg2rad(latASI),
                                         np.deg2rad(lonASI))

    # reconstruct direction vector as seen from ASI
    x, y, z = geodetic2Ecef(np.deg2rad(latsRef), np.deg2rad(lonsRef),
                            heightRef)
    x -= xASI
    y -= yASI
    z -= zASI

    # reproject
    a = wgs84A + heightNew
    b = wgs84B + heightNew
    direction = np.transpose([x, y, z])
    intersection = ellipsoidLineIntersection(a, b, [xASI, yASI, zASI],
                                             direction.reshape(-1, 3))
    intersection = intersection.reshape(direction.shape)
    x, y, z = intersection.transpose()
    latsNew, lonsNew = ecef2Geodetic(x, y, z, wgs84A, wgs84B)
    np.rad2deg(latsNew, latsNew)
    np.rad2deg(lonsNew, lonsNew)
    return latsNew, lonsNew
Ejemplo n.º 3
0
 def testGeodeticConversionsArray(self):
     lat, lon = np.mgrid[-89:89:5,-179:179:5]
     x, y, z = geodetic2EcefZero(np.deg2rad(lat), np.deg2rad(lon))
 
     r = ecef2Geodetic(x, y, z)
     #print np.rad2deg(r)
     assert_array_almost_equal(np.rad2deg(r),[lat,lon], 11)
Ejemplo n.º 4
0
def reproject(latLonASI, latsRef, lonsRef, heightRef, heightNew):
    """
    
    :param latLonASI: tuple of latitude,longitude of ASI
    :param latsRef: latitudes of pixel corners for reference height in degrees
    :param lonsRef: longitudes of pixel corners for reference height in degrees
    :param heightRef: reference height in km (above ground)
    :param heightNew: new height in km (above ground)
    :rtype: tuple of reprojected latitudes and longitudes 
    """
    latASI, lonASI = latLonASI
    xASI,yASI,zASI = geodetic2EcefZero(np.deg2rad(latASI), np.deg2rad(lonASI))
    
    # reconstruct direction vector as seen from ASI
    x,y,z = geodetic2Ecef(np.deg2rad(latsRef), np.deg2rad(lonsRef), heightRef)
    x -= xASI
    y -= yASI
    z -= zASI
    
    # reproject
    a = wgs84A + heightNew
    b = wgs84B + heightNew
    direction = np.transpose([x,y,z])
    intersection = ellipsoidLineIntersection(a, b, [xASI,yASI,zASI], direction.reshape(-1,3))
    intersection = intersection.reshape(direction.shape)
    x, y, z = intersection.transpose()
    latsNew, lonsNew = ecef2Geodetic(x, y, z, wgs84A, wgs84B)
    np.rad2deg(latsNew, latsNew)
    np.rad2deg(lonsNew, lonsNew)
    return latsNew, lonsNew
Ejemplo n.º 5
0
 def _calculateLatsLons(self, center=True):
     if self._simple:
         bb = self._calData.boundingBoxSimple
         
         deltaLat = (bb.latNorth - bb.latSouth)/self.img.shape[0]
         deltaLon = (bb.lonEast - bb.lonWest)/self.img.shape[1]
         
         if center:
             latSpace = np.linspace(bb.latNorth-deltaLat/2, bb.latSouth+deltaLat/2, self.img.shape[0])
             lonSpace = np.linspace(bb.lonWest+deltaLon/2, bb.lonEast-deltaLon/2, self.img.shape[0])
         else:
             latSpace = np.linspace(bb.latNorth, bb.latSouth, self.img.shape[0]+1)
             lonSpace = np.linspace(bb.lonWest, bb.lonEast, self.img.shape[0]+1)
             
         #lats, lons = np.meshgrid(latSpace, lonSpace, indexing='ij') # 'indexing' not supported in np 1.6
         lats, lons = np.dstack(np.meshgrid(latSpace, lonSpace)).T
     else:
         intersectionInflated = self.intersectionInflatedCenter if center else self.intersectionInflatedCorner
         xyz = intersectionInflated.reshape(-1,3)
         lats, lons = ecef2Geodetic(xyz[:,0], xyz[:,1], xyz[:,2], wgs84A, wgs84B)
         np.rad2deg(lats, lats)
         np.rad2deg(lons, lons)
         lats = lats.reshape(intersectionInflated.shape[0], intersectionInflated.shape[1])
         lons = lons.reshape(intersectionInflated.shape[0], intersectionInflated.shape[1])
     
     return lats, lons
Ejemplo n.º 6
0
 def testGeodeticConversions(self):
     for lat in np.linspace(-89.9, 89.9):
         for lon in np.linspace(-179.9, 179.9):
             x, y, z = geodetic2EcefZero(np.deg2rad(lat), np.deg2rad(lon))
             r = np.rad2deg(ecef2Geodetic(x, y, z))
             assert_array_almost_equal(r, [lat, lon], 11)
Ejemplo n.º 7
0
 def testGeodeticConversions(self):
     for lat in np.linspace(-89.9,89.9):
         for lon in np.linspace(-179.9,179.9):
             x, y, z = geodetic2EcefZero(np.deg2rad(lat), np.deg2rad(lon))
             r = np.rad2deg(ecef2Geodetic(x, y, z))
             assert_array_almost_equal(r,[lat,lon], 11)