Example showing how the "native" longitude and latitude relate to the
    stereonet projection.
352048
def native_projection_explanation(ax):
    """"""
    ax.set_title('Longitude and Latitude', size=18, y=1.1)

    # Hide the azimuth labels
    ax.set_azimuth_ticklabels([])

    # Make the axis tick labels visible:
    ax.set_xticks(np.radians(np.arange(-80, 90, 10)))
    ax.tick_params(label1On=True)

    ax.set_xlabel('Longitude')

    xlabel_halo(ax)
    return ax
1361884
def plotSkymapCatalog(lon,lat,**kwargs):
    
    fig = plt.figure()
    ax = plt.subplot(111,projection=projection)
    drawSkymapCatalog(ax,lon,lat,**kwargs)
251917
def make_stereo(attrs_dict, globe):
    """"""
    attr_mapping = [('scale_factor', 'scale_factor_at_projection_origin')]
    kwargs = CFProjection.build_projection_kwargs(attrs_dict, attr_mapping)

    return ccrs.Stereographic(globe=globe, **kwargs)
180082
def interpolate(self):
        
        self.latitude = self._interp(self.lat_tiepoint)
        self.longitude = self._interp(self.lon_tiepoint)

        return self.latitude, self.longitude
845705
def localortho(lon, lat):
    
    local_srs = osr.SpatialReference()
    local_proj = '+proj=ortho +lat_0=%0.7f +lon_0=%0.7f +datum=WGS84 +units=m +no_defs ' % (lat, lon)
    local_srs.ImportFromProj4(local_proj)
    return local_srs
329950
def point
      unless @point
        # variable names correspond roughly to symbols in the OS algorithm, lowercased:
        # n0 = northing of true origin 
        # e0 = easting of true origin 
        # f0 = scale factor on central meridian
        # phi0 = latitude of true origin 
        # lambda0 = longitude of true origin and central meridian.
        # e2 = eccentricity squared
        # a = length of polar axis of ellipsoid
        # b = length of equatorial axis of ellipsoid
        # ning & eing are the northings and eastings of the supplied gridref
        # phi and lambda are the discovered latitude and longitude
      
        ning = northing
        eing = easting

        n0 = projection.n0
        e0 = projection.e0
        phi0 = projection.phi0
        l0 = projection.lambda0
        f0 = projection.scale
      
        a = ellipsoid.a
        b = ellipsoid.b
        e2 = ellipsoid.ecc
      
        # the rest is juste a transliteration of the OS equations

        n = (a - b) / (a + b)
        m = 0
        phi = phi0
    
        # iterate to within acceptable distance of solution
      
        count = 0
        while ((ning - n0 - m) >= 0.001) do
          raise RuntimeError "Demercatorising equation has not converged. Discrepancy after #{count} cycles is #{ning - n0 - m}" if count >= @@iteration_ceiling

          phi = ((ning - n0 - m) / (a * f0)) + phi
          ma = (1 + n + (1.25 * n**2) + (1.25 * n**3)) * (phi - phi0)
          mb = ((3 * n) + (3 * n**2) + (2.625 * n**3)) * Math.sin(phi - phi0) * Math.cos(phi + phi0)
          mc = ((1.875 * n**2) + (1.875 * n**3)) * Math.sin(2 * (phi - phi0)) * Math.cos(2 * (phi + phi0))
          md = (35/24) * (n**3) * Math.sin(3 * (phi - phi0)) * Math.cos(3 * (phi + phi0))
          m = b * f0 * (ma - mb + mc - md)
          count += 1
        end
      
        # engage alphabet soup
      
        nu = a * f0 * ((1-(e2) * ((Math.sin(phi)**2))) ** -0.5)
        rho = a * f0 * (1-(e2)) * ((1-(e2)*((Math.sin(phi)**2))) ** -1.5)
        eta2 = (nu/rho - 1)
      
        # fire
      
        vii = Math.tan(phi) / (2 * rho * nu)
        viii = (Math.tan(phi) / (24 * rho * (nu ** 3))) * (5 + (3 * (Math.tan(phi) ** 2)) + eta2 - 9 * eta2 * (Math.tan(phi) ** 2) )
        ix = (Math.tan(phi) / (720 * rho * (nu ** 5))) * (61 + (90 * (Math.tan(phi) ** 2)) + (45 * (Math.tan(phi) ** 4)) )
        x = sec(phi) / nu
        xi = (sec(phi) / (6 * nu ** 3)) * ((nu/rho) + 2 * (Math.tan(phi) ** 2))
        xii = (sec(phi) / (120 * nu ** 5)) * (5 + (28 * (Math.tan(phi) ** 2)) + (24 * (Math.tan(phi) ** 4)))
        xiia = (sec(phi) / (5040 * nu ** 7)) * (61 + (662 * (Math.tan(phi) ** 2)) + (1320 * (Math.tan(phi) ** 4)) + (720 * (Math.tan(phi) ** 6)))

        d = eing-e0

        # all of which was just to populate these last two equations:
      
        phi = phi - vii*(d**2) + viii*(d**4) - ix*(d**6)
        lambda = l0 + x*d - xi*(d**3) + xii*(d**5) - xiia*(d**7)

        @point = Osgb::Point.new(phi.to_degrees, lambda.to_degrees, :osgb36, precision)
      end
      @point
    end
1069917
def project(self, lng_lat):
        
        (lng, lat) = lng_lat
        x = lng * DEG_TO_RAD
        lat = max(min(MAX_LATITUDE, lat), -MAX_LATITUDE)
        y = lat * DEG_TO_RAD
        y = log(tan((pi / 4) + (y / 2)))
        return (x*EARTH_RADIUS, y*EARTH_RADIUS)
1355242
def to_protobuf(self):
        
        return latlng_pb2.LatLng(latitude=self.latitude, longitude=self.longitude)
119591
def geo_planar(self, surface):
        
        with context(self.fname, surface):
            tl = surface.topLeft
            top_left = geo.Point(tl['lon'], tl['lat'], tl['depth'])
            tr = surface.topRight
            top_right = geo.Point(tr['lon'], tr['lat'], tr['depth'])
            bl = surface.bottomLeft
            bottom_left = geo.Point(bl['lon'], bl['lat'], bl['depth'])
            br = surface.bottomRight
            bottom_right = geo.Point(br['lon'], br['lat'], br['depth'])
        return geo.PlanarSurface.from_corner_points(
            top_left, top_right, bottom_right, bottom_left)
439968
def interpolate(self, doy, depth, lat, lon, var):
        

        subset, dims = self.crop(doy, depth, lat, lon, var)

        if np.all([d in dims['time'] for d in doy]) & \
                np.all([z in dims['depth'] for z in depth]) & \
                np.all([y in dims['lat'] for y in lat]) & \
                np.all([x in dims['lon'] for x in lon]):
                    dn = np.nonzero([d in doy for d in dims['time']])[0]
                    zn = np.nonzero([z in depth for z in dims['depth']])[0]
                    yn = np.nonzero([y in lat for y in dims['lat']])[0]
                    xn = np.nonzero([x in lon for x in dims['lon']])[0]
                    output = {}
                    for v in subset:
                        # output[v] = subset[v][dn, zn, yn, xn]
                        # Seriously that this is the way to do it?!!??
                        output[v] = subset[v][:, :, :, xn][:, :, yn][:, zn][dn]
                    return output

        # The output coordinates shall be created only once.
        points_out = []
        for doyn in doy:
            for depthn in depth:
                for latn in lat:
                    for lonn in lon:
                        points_out.append([doyn, depthn, latn, lonn])
        points_out = np.array(points_out)

        output = {}
        for v in var:
            output[v] = ma.masked_all(
                    (doy.size, depth.size, lat.size, lon.size),
                    dtype=subset[v].dtype)

            # The valid data
            idx = np.nonzero(~ma.getmaskarray(subset[v]))

            if idx[0].size > 0:
                points = np.array([
                    dims['time'][idx[0]], dims['depth'][idx[1]],
                    dims['lat'][idx[2]], dims['lon'][idx[3]]]).T
                values = subset[v][idx]

                # Interpolate along the dimensions that have more than one
                #   position, otherwise it means that the output is exactly
                #   on that coordinate.
                ind = np.array(
                        [np.unique(points[:, i]).size > 1 for i in
                            range(points.shape[1])])
                assert ind.any()

                # These interpolators understand NaN, but not masks.
                values[ma.getmaskarray(values)] = np.nan

                values_out = griddata(
                        np.atleast_1d(np.squeeze(points[:, ind])),
                        values,
                        np.atleast_1d(np.squeeze(points_out[:, ind]))
                        )

                # Remap the interpolated value back into a 4D array
                idx = np.isfinite(values_out)
                for [t, z, y, x], out in zip(points_out[idx], values_out[idx]):
                    output[v][t==doy, z==depth, y==lat, x==lon] = out

            output[v] = ma.fix_invalid(output[v])

        return output
474493
function(N) {
  cosMap = cosMap || {};
  cosMap[N] = new Array(N*N);

  var PI_N = Math.PI / N;

  for (var k = 0; k < N; k++) {
    for (var n = 0; n < N; n++) {
      cosMap[N][n + (k * N)] = Math.cos(PI_N * (n + 0.5) * k);
    }
  }
}
912452
def project(lon0, lat0, lon1, lat1):
    """"""

    costh = np.cos(np.pi / 2. - lat0)
    cosphi = np.cos(lon0)

    sinth = np.sin(np.pi / 2. - lat0)
    sinphi = np.sin(lon0)

    xyz = lonlat_to_xyz(lon1, lat1)
    x1 = xyz[0]
    y1 = xyz[1]
    z1 = xyz[2]

    x1p = x1 * costh * cosphi + y1 * costh * sinphi - z1 * sinth
    y1p = -x1 * sinphi + y1 * cosphi
    z1p = x1 * sinth * cosphi + y1 * sinth * sinphi + z1 * costh

    r = np.arctan2(np.sqrt(x1p ** 2 + y1p ** 2), z1p)
    phi = np.arctan2(y1p, x1p)

    return r * np.cos(phi), r * np.sin(phi)
237254
void defineCoordinateSystem(View viewA, Motion motion) {

		View viewB = motion.destination(viewA);
		viewA.viewToWorld.reset(); // identity since it's the origin
		viewB.viewToWorld.set(motion.motionSrcToDst(viewB));
		// translation is only known up to a scale factor so pick a reasonable scale factor
		double scale = viewB.viewToWorld.T.norm();
		viewB.viewToWorld.T.scale(1.0/scale);

		viewsAdded.add(viewA);
		viewsAdded.add(viewB);

		viewA.state = ViewState.PROCESSED;
		viewB.state = ViewState.PROCESSED;

		// Take the already triangulated points and turn them into official 3D features
		boolean originIsDst = viewA == motion.viewDst;
		for (int i = 0; i < motion.stereoTriangulations.size(); i++) {
			Feature3D f = motion.stereoTriangulations.get(i);

			if( f.obsIdx.size != 2 )
				throw new RuntimeException("BUG");

			int indexSrc = f.obsIdx.get(0);
			int indexDst = f.obsIdx.get(1);

			motion.viewSrc.features3D[indexSrc] = f;
			motion.viewDst.features3D[indexDst] = f;

			if( originIsDst ) {
				SePointOps_F64.transform(motion.a_to_b,f.worldPt,f.worldPt);
			}

			f.worldPt.scale(1.0/scale);
			graph.features3D.add(f);
		}

		// free memory and mark as already processed
		motion.stereoTriangulations = new ArrayList<>();

		// All features which can be added using triangulation should now be added
		addTriangulatedFeaturesForAllEdges(viewA);
		addTriangulatedFeaturesForAllEdges(viewB);

		if( verbose != null ) {
			verbose.println("root  = " + viewA.index);
			verbose.println("other = " + viewB.index);
			verbose.println("-------------");
		}
	}
553881
def projection_to_raster_coords(self, lat, lon):
        
        r_px_py = np.array([1, lon, lat])
        tg = inv(np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]]))
        return np.inner(tg, r_px_py)[1:]
641964
public void equiToLatLon(double x , double y , GeoLL_F64 geo ) {
		geo.lon = (x/width - 0.5)*GrlConstants.PI2;
		geo.lat = (y/(height-1) - 0.5)*GrlConstants.PI;
	}
1156154
def cla(self):
        """"""
        Axes.cla(self)

        # Set grid defaults...
        self.set_longitude_grid(10)
        self.set_latitude_grid(10)
        self.set_longitude_grid_ends(80)

        # Hide all ticks and tick labels for the "native" lon and lat axes
        self.xaxis.set_minor_locator(NullLocator())
        self.yaxis.set_minor_locator(NullLocator())
        self.xaxis.set_ticks_position('none')
        self.yaxis.set_ticks_position('none')
        self.xaxis.set_tick_params(label1On=False)
        self.yaxis.set_tick_params(label1On=False)

        # Set the grid on or off based on the rc params.
        self.grid(mpl.rcParams['axes.grid'])

        # Set the default limits (so that the "native" ticklabels will be
        # correct if they're turned back on)...
        Axes.set_xlim(self, -2 * self.horizon, 2 * self.horizon)
        Axes.set_ylim(self, -np.pi / 2.0, np.pi / 2.0)

        # Set up the azimuth ticks.
        self._polar.set_theta_offset(np.radians(self.rotation + 90))
        self._polar.set_theta_direction(-1)
        self._polar.grid(False)
        self._polar.set_rticks([])
340460
def _cas_4(self):
        '''  '''

        lonc_left = self._format_lon(self.lonm)
        lonc_right = self._format_lon(self.lonM)
        latc_top = self._format_lat(self.latM)
        latc_bot = self._format_lat(self.latm)

        img_name_00 = self._format_name_map(lonc_left, latc_top)
        img_00 = BinaryTable(img_name_00, self.path_pdsfiles)
        X_00, Y_00, Z_00 = img_00.extract_grid(self.lonm,
                                               float(
                                                   img_00.EASTERNMOST_LONGITUDE),
                                               float(img_00.MINIMUM_LATITUDE),
                                               self.latM)

        img_name_01 = self._format_name_map(lonc_right, latc_top)
        img_01 = BinaryTable(img_name_01, self.path_pdsfiles)
        X_01, Y_01, Z_01 = img_01.extract_grid(float(img_01.WESTERNMOST_LONGITUDE),
                                               self.lonM,
                                               float(img_01.MINIMUM_LATITUDE),
                                               self.latM)

        img_name_10 = self._format_name_map(lonc_left, latc_bot)
        img_10 = BinaryTable(img_name_10, self.path_pdsfiles)
        X_10, Y_10, Z_10 = img_10.extract_grid(self.lonm,
                                               float(
                                                   img_10.EASTERNMOST_LONGITUDE),
                                               self.latm,
                                               float(img_10.MAXIMUM_LATITUDE))

        img_name_11 = self._format_name_map(lonc_right, latc_bot)
        img_11 = BinaryTable(img_name_11, self.path_pdsfiles)
        X_11, Y_11, Z_11 = img_11.extract_grid(float(img_11.WESTERNMOST_LONGITUDE),
                                               self.lonM,
                                               self.latm,
                                               float(img_11.MAXIMUM_LATITUDE))

        X_new_top = np.hstack((X_00, X_01))
        X_new_bot = np.hstack((X_10, X_11))
        X_new = np.vstack((X_new_top, X_new_bot))

        Y_new_top = np.hstack((Y_00, Y_01))
        Y_new_bot = np.hstack((Y_10, Y_11))
        Y_new = np.vstack((Y_new_top, Y_new_bot))

        Z_new_top = np.hstack((Z_00, Z_01))
        Z_new_bot = np.hstack((Z_10, Z_11))
        Z_new = np.vstack((Z_new_top, Z_new_bot))

        return X_new, Y_new, Z_new