def test_get_surround_idxs_cube():
    """
    CubeGridRemap.get_surround_idxs(): ne=30
    """
    from cube_remap import CubeGridRemap
    from util.convert_coord.cs_ll import abp2latlon

    ne, ngq = 30, 4
    rotated = False

    cube = CubeGridRemap(ne, ngq, rotated)
    td = (np.pi / 2) / ne / 3 / 2  # tiny delta

    ij = (1, 2, 1, 1, 1)
    gid = cube.ij2gid[ij]
    alpha, beta = cube.alpha_betas[gid]
    lat, lon = abp2latlon(alpha + td, beta + td, ij[0])
    ret_uids = cube.get_surround_idxs(lat, lon)
    a_equal(ret_uids, [3, 16, 7, 19])

    ij = (1, 2, 1, 2, 3)
    gid = cube.ij2gid[ij]
    alpha, beta = cube.alpha_betas[gid]
    lat, lon = abp2latlon(alpha + td, beta + td, ij[0])
    ret_uids = cube.get_surround_idxs(lat, lon)
    a_equal(ret_uids, [22, 23, 25, 26])

    """
Example #2
0
    def draw_cube_elements(self, ne, panel, **kargs):
        kwds = dict(c='0.5', lw=1., ls='-')
        kwds.update(kargs)

        angles = np.linspace(-pi/4,pi/4,ne+1)

        for angle in angles:
            latlon1 = abp2latlon(angle,-pi/4,panel)
            latlon2 = abp2latlon(angle,pi/4,panel)
            draw_line(self.bmap, latlon1, latlon2, **kwds)

        for angle in angles:
            latlon1 = abp2latlon(-pi/4,angle,panel)
            latlon2 = abp2latlon(pi/4,angle,panel)
            draw_line(self.bmap, latlon1, latlon2, **kwds)
def test_get_surround_elem_gids():
    """
    CubeGridRemap.get_surround_elem_gids(): ne=30
    """
    from cube_remap import CubeGridRemap
    from util.convert_coord.cs_ll import abp2latlon

    ne, ngq = 30, 4
    rotated = False
    cube = CubeGridRemap(ne, ngq, rotated)
    td = (np.pi / 2) / ne / 3 / 2  # tiny delta

    ij = (1, 2, 1, 1, 1)
    gid = cube.ij2gid[ij]
    alpha, beta = cube.alpha_betas[gid]
    lat, lon = abp2latlon(alpha + td, beta + td, ij[0])
    ret_gids = cube.get_surround_elem_gids(lat, lon)
    a_equal(ret_gids, [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])
    ret_uids = [cube.uids[gid] for gid in ret_gids]
    a_equal(ret_uids, [3, 16, 17, 18, 7, 19, 20, 21, 11, 22, 23, 24, 15, 25, 26, 27])