Esempio n. 1
0
def plotEarthSubTriangles(verbose=True, save=False, show=True, dpi=300, resolution='c'):
    '''Each Icosahedron Face has six sub-triangles that are splitting on.'''
    lonlat_islands, dymax_islands = getIslands(resolution)
    
    plt.figure(figsize=(20,12))
    
    xs, ys = [],[]
    lcds = []
    for i in range(10000):
        lon = np.random.random()*360-180
        lat = np.random.random()*180-90
        x, y, lcd = convert.lonlat2dymax(lon,lat, getlcd=True)
        xs += [x]
        ys += [y]
        lcds += [lcd]

    ### Draw LCD Triangle Indices
    colorlist = 'rgcmyg'
    for val in range(10000):
        plt.text(xs[val],ys[val],str(lcds[val]),color=colorlist[lcds[val]],ha='center',va='center',size='small',alpha=.5)

    ### Draw Large Fuller Triangles
    for jdx in range(constants.facecount):
        if jdx == 8 or jdx == 15: continue
        points = convert.face2dymax(jdx, push=.95)
        xcenter,ycenter = convert.dymax_centers[jdx]
        plt.plot(points[:,0],points[:,1],lw=5,alpha=.5)

    ### Draw Fuller LCD Sub-Triangles
    for jdx in range(constants.facecount):
        if jdx == 8 or jdx == 15: continue
        points = convert.face2dymax(jdx, push=.999, atomic=True)
        xcenter, ycenter = convert.dymax_centers[jdx]
        plt.text(xcenter,ycenter,str(jdx),size='xx-large',ha='center',va='center')
        plt.plot(points[:,0],points[:,1],lw=1,alpha=1,color='k',ls='dotted')

    ### Draw Landmasses
    patches = []
    for island in dymax_islands:
        polygon = Polygon(np.array(island), closed=True, fill=True)
        patches.append(polygon)
    
    colors = 100*np.random.random(len(patches))
    p = PatchCollection(patches, cmap=plt.cm.jet, alpha=.5,linewidths=0.)
    p.set_array(np.array(colors))
    plt.gca().add_collection(p)
    if verbose: print(':: plotted',len(patches),'coastlines')
    plt.gca().set_xlim([0,5.5])
    plt.gca().set_ylim([0,2.6])
    plt.gca().set_aspect('equal')
    
    if save: plt.savefig('dymax_earthsubtriangles.png',bbox_inches='tight',dpi=dpi,transparent=True,pad_inches=0)
    if show:
        plt.tight_layout()
        plt.show()
    else: plt.close()
Esempio n. 2
0
def plotEarthMeridiansTriangles(verbose=True, save=False, show=True, dpi=300, resolution='c'):
    '''Draw Dymax Triangles, All countries, and Meridians'''
    lonlat_islands, dymax_islands = getIslands(resolution)
    n = 1000
    plt.figure(figsize=(20,12))
    plt.title('Dymaxion Map Projection')
    
    ### Dymaxion Latitude Meridians
    lons = np.linspace(-180,180,n)
    latgrid = np.linspace(-85,85,35)
    points = []
    start = time.time()
    for lat in latgrid:
        for lon in lons:
            points += [convert.lonlat2dymax(lon,lat)]
    if verbose: print(':: mapped {:d} points to dymax projection @ {:.1f} pts/sec [{:.1f} secs total]'.format(len(points),len(points)/(time.time()-start),time.time()-start))
    points = np.array(points)
    plt.plot(points[:,0],points[:,1],',',c='k',alpha=.3)#,'.',lw=0)#,c=range(n))

    ### Dymaxion Longitude Meridians
    lats = np.linspace(-85,85,n)
    longrid = np.linspace(-180,175,72)
    points = []
    start = time.time()
    for lon in longrid:
        for lat in lats:
            points += [convert.lonlat2dymax(lon,lat)]
    if verbose: print(':: mapped {:d} points to dymax projection @ {:.1f} pts/sec [{:.1f} secs total]'.format(len(points),len(points)/(time.time()-start),time.time()-start))
    points = np.array(points)
    plt.plot(points[:,0],points[:,1],',',c='k',alpha=.3)#,'.',lw=0)#,c=range(n))

    ### Dymaxion Face Tiles
    for jdx in range(constants.facecount):
        if jdx == 8 or jdx == 15: continue
        points = convert.face2dymax(jdx,push=.95)
        xcenter,ycenter = convert.dymax_centers[jdx]
        plt.text(xcenter,ycenter,str(jdx),size='x-large')
        plt.plot(points[:,0],points[:,1],lw=5,alpha=.7)
        
    ### Draw Landmasses
    patches = []
    for island in dymax_islands:
        polygon = Polygon(np.array(island))#, closed=False, fill=False)
        patches.append(polygon)
    
    p = PatchCollection(patches, alpha=.3, linewidths=1.,facecolors=None)
    colors = 100*np.random.random(len(patches))
    p.set_array(np.array(colors))
    plt.gca().add_collection(p)
    if verbose: print(':: plotted',len(patches),'coastlines')
    plt.gca().set_xlim([0,5.5])
    plt.gca().set_ylim([0,2.6])
    plt.gca().set_aspect('equal')   
    if save: plt.savefig('dymax_earthmeridianstriangles.png',bbox_inches='tight',dpi=dpi,transparent=True,pad_inches=0)
    if show:
        plt.tight_layout()
        plt.show()
    else: plt.close()
Esempio n. 3
0
def plotTriangles(verbose=True, save=False, show=True, dpi=300):
    '''Draw Dymax Spherical Triangles'''
    plt.figure(figsize=(20,12))
    for jdx in range(constants.facecount):
        if jdx == 8 or jdx == 15: continue
        points = convert.face2dymax(jdx,push=.95)
        xcenter,ycenter = convert.dymax_centers[jdx]
        plt.text(xcenter,ycenter,str(jdx))
        plt.plot(points[:,0],points[:,1],lw=5,alpha=.5)
    plt.gca().set_xlim([0,5.5])
    plt.gca().set_ylim([0,2.6])
    plt.gca().set_aspect('equal')
    if verbose: print(':: plotted',constants.facecount,'triangles')
    if save: plt.savefig('dymax_triangles.png',bbox_inches='tight',dpi=300,transparent=True,pad_inches=0)
    if show:
        plt.tight_layout()
        plt.show()
    else: plt.close()