当前位置: 首页>>代码示例>>Python>>正文


Python crs.Orthographic方法代码示例

本文整理汇总了Python中cartopy.crs.Orthographic方法的典型用法代码示例。如果您正苦于以下问题:Python crs.Orthographic方法的具体用法?Python crs.Orthographic怎么用?Python crs.Orthographic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cartopy.crs的用法示例。


在下文中一共展示了crs.Orthographic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_extend

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Orthographic [as 别名]
def plot_extend(resource, file_extension='png'):
    """
    plots the extend (domain) of the values stored in a netCDF file:

    :parm resource: path to netCDF file
    :param file_extension: file format of the graphic. if file_extension=None a matplotlib figure will be returned

    :return graphic: graphic in specified format
    """
    lats, lons = get_coordinates(resource, unrotate=True)

    # box_top = 45
    # x, y = [-20, -20, 45, 45, -44], [-45, box_top, box_top, -45, -45]

    xy = np.array([[np.min(lons), np.min(lats)],
                   [np.max(lons), np.min(lats)],
                   [np.max(lons), np.max(lats)],
                   [np.min(lons), np.max(lats)]])

    fig = plt.figure(figsize=(20, 10), dpi=600, facecolor='w', edgecolor='k')
    projection = ccrs.Robinson()

    #  ccrs.Orthographic(central_longitude=np.mean(xy[:, 0]),
    #  central_latitude=np.mean(xy[:, 1]),
    #  globe=None)  # Robinson()

    ax = plt.axes(projection=projection)
    ax.stock_img()
    ax.coastlines()
    ax.add_patch(mpatches.Polygon(xy, closed=True, transform=ccrs.PlateCarree(), color='coral', alpha=0.6))
    # ccrs.Geodetic()
    ax.gridlines()
    plt.show()

    if file_extension is None:
        map_graphic = fig
    else:
        map_graphic = fig2plot(fig=fig, file_extension=file_extension)
    plt.close()

    return map_graphic 
开发者ID:bird-house,项目名称:flyingpigeon,代码行数:43,代码来源:plt_ncdata.py

示例2: test_warpcraters

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Orthographic [as 别名]
def test_warpcraters(self, box):
        """Test image warping and padding.

        Output of this function was tested by visual inspection.
        """
        box = np.array(box, dtype='int32')
        # Crop image.
        img = np.asanyarray(self.img.crop(box))

        # Determine long/lat and output projection.
        llbd = self.get_llbd(box)
        oproj = ccrs.Orthographic(central_longitude=np.mean(llbd[:2]),
                                  central_latitude=np.mean(llbd[2:]),
                                  globe=self.iglobe)

        # Determine coordinates of image limits in input and output projection
        # coordinates.
        iextent, oextent, ores = self.get_extents(llbd, self.geoproj,
                                                  self.iproj, oproj)

        # Obtain image from igen.WarpImagePad.
        imgout_WarpImagePad, WIPsize, WIPoffset = igen.WarpImagePad(
            img, self.iproj, iextent, oproj, oextent, origin="upper",
            rgcoeff=1.2, fillbg="black")

        ctr_xlim = ((self.craters["Long"] >= llbd[0]) &
                    (self.craters["Long"] <= llbd[1]))
        ctr_ylim = ((self.craters["Lat"] >= llbd[2]) &
                    (self.craters["Lat"] <= llbd[3]))
        ctr_wrp = self.craters.loc[ctr_xlim & ctr_ylim, :].copy()

        # Get output projection coords.
        # [:,:2] becaus we don't need elevation data
        # If statement is in case ctr_wrp has nothing in it
        if ctr_wrp.shape[0]:
            ilong = ctr_wrp["Long"].as_matrix()
            ilat = ctr_wrp["Lat"].as_matrix()
            res = oproj.transform_points(x=ilong, y=ilat,
                                         src_crs=self.geoproj)[:, :2]

            # Get output
            ctr_wrp["x"], ctr_wrp["y"] = trf.coord2pix(res[:, 0], res[:, 1],
                                                       oextent, WIPsize,
                                                       origin="upper")
        else:
            ctr_wrp["x"] = []
            ctr_wrp["y"] = []

        ctr_wrpctrloc = igen.WarpCraterLoc(self.craters, self.geoproj, oproj,
                                           oextent, WIPsize, llbd=llbd,
                                           origin="upper")

        assert np.all(ctr_wrp == ctr_wrpctrloc) 
开发者ID:silburt,项目名称:DeepMoon,代码行数:55,代码来源:test_input_data_gen.py

示例3: test_platecarreetoorthographic

# 需要导入模块: from cartopy import crs [as 别名]
# 或者: from cartopy.crs import Orthographic [as 别名]
def test_platecarreetoorthographic(self, box):
        """Test full Plate Carree to orthographic transform.

        Assumes input_data_gen's image and crater position warping
        functions are correct. Output of this function was tested by visual
        inspection.
        """

        box = np.array(box, dtype='int32')
        # Crop image.
        img = np.asanyarray(self.img.crop(box))

        # Determine long/lat and output projection.
        llbd = self.get_llbd(box)
        oproj = ccrs.Orthographic(central_longitude=np.mean(llbd[:2]),
                                  central_latitude=np.mean(llbd[2:]),
                                  globe=self.iglobe)

        # Determine coordinates of image limits in input and output projection
        # coordinates.
        iextent, oextent, ores = self.get_extents(llbd, self.geoproj,
                                                  self.iproj, oproj)

        # Obtain image from igen.WarpImagePad.
        imgo, imgwshp, offset = igen.WarpImagePad(
            img, self.iproj, iextent, oproj, oextent, origin="upper",
            rgcoeff=1.2, fillbg="black")

        ctr_xy = igen.WarpCraterLoc(self.craters, self.geoproj, oproj,
                                    oextent, imgwshp, llbd=llbd,
                                    origin="upper")
        ctr_xy.loc[:, "x"] += offset[0]
        ctr_xy.loc[:, "y"] += offset[1]

        distortion_coefficient = ((ores[7, 1] - ores[1, 1]) /
                                  (oextent[3] - oextent[2]))
        pixperkm = trf.km2pix(imgo.size[1], llbd[3] - llbd[2],
                              dc=distortion_coefficient, a=1737.4)
        ctr_xy["Diameter (pix)"] = ctr_xy["Diameter (km)"] * pixperkm


        # Determine x, y position of central lat/long.
        centrallonglat = pd.DataFrame({"Long": [np.mean(llbd[:2])],
                                       "Lat": [np.mean(llbd[2:])]})
        centrallonglat_xy = igen.WarpCraterLoc(centrallonglat, self.geoproj,
                                               oproj, oextent, imgwshp,
                                               llbd=llbd, origin="upper")
        centrallonglat_xy.loc[:, "x"] += offset[0]
        centrallonglat_xy.loc[:, "y"] += offset[1]

        img_pc, ctr_pc, dc_pc, cll_pc = igen.PlateCarree_to_Orthographic(
            self.img.crop(box), llbd, self.craters, iglobe=self.iglobe,
            ctr_sub=False, arad=1737.4, origin="upper", rgcoeff=1.2,
            slivercut=0.)

        assert np.all(np.asanyarray(img_pc) == np.asanyarray(imgo))
        assert np.all(ctr_pc == ctr_xy)
        assert dc_pc == distortion_coefficient
        assert np.all(cll_pc == centrallonglat_xy) 
开发者ID:silburt,项目名称:DeepMoon,代码行数:61,代码来源:test_input_data_gen.py


注:本文中的cartopy.crs.Orthographic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。