예제 #1
0
파일: plot.py 프로젝트: arokem/spheredwi
def scatter(theta, phi, basemap=None, ax=None, **scatter_args):
    if basemap is None:
        z = np.array([0, 0])
        basemap = surf_grid(z, z, z, projection='moll')

    lat, lon = coord.sph2latlon(theta, phi)
    x, y = basemap(lon, lat)
    basemap.scatter(x, y, **scatter_args)
예제 #2
0
파일: plot.py 프로젝트: arokem/spheredwi
def surf_grid(r, theta, phi, ax=None, vmin=None, vmax=None, **basemap_args):
    """Draw a function r = f(theta, phi), evaluated on a grid, on the sphere.

    Parameters
    ----------
    r : (M, N) ndarray
        Function values.
    theta : (M,) ndarray
        Inclination / polar angles of function values.
    phi : (N,) ndarray
        Azimuth angles of function values.
    ax : mpl axis, optional
        If specified, draw onto this existing axis instead.
    basemap_args : dict
        Parameters used to initialise the basemap, e.g. ``projection='ortho'``.

    Returns
    -------
    m : basemap
        The newly created matplotlib basemap.

    """
    basemap_args.setdefault('projection', 'ortho')
    basemap_args.setdefault('lat_0', 0)
    basemap_args.setdefault('lon_0', 0)
    basemap_args.setdefault('resolution', 'c')

    from mpl_toolkits.basemap import Basemap

    m = Basemap(**basemap_args)
    m.drawmapboundary()
    lat, lon = coord.sph2latlon(theta, phi)
    x, y = m(*np.meshgrid(lon, lat))
    m.pcolor(x, y, r, vmin=vmin, vmax=vmax)

    return m