Example #1
0
def MapasCD_Imshow(data,
                   lat,
                   lon,
                   lat_down,
                   lat_up,
                   lon_left,
                   long_right,
                   name,
                   titulo,
                   cmap,
                   dt,
                   dmes,
                   levels='Nada'):
    plt.close('all')
    fig = plt.figure(figsize=(14, 18))

    for i in range(0, 12):
        ax = fig.add_subplot(4, 3, i + 1)
        ax.set_title(dmes[i], fontsize=18)
        m = Basemap(projection='merc',
                    llcrnrlat=lat_down,
                    urcrnrlat=lat_up,
                    llcrnrlon=lon_left,
                    urcrnrlon=lon_right,
                    resolution='i',
                    lat_ts=20)
        m.readshapefile(shape,
                        name='AreaMetropolitana',
                        color='k',
                        linewidth=1.5)
        cs = m.imshow(data[i], cmap=cmap)
        parallels = np.arange(lat_down, lat_up + 1, 0.3)
        m.drawparallels(parallels, labels=[1, 0, 0, 0], fontsize=10)
        meridians = np.arange(lon_left, long_right + 1, 0.3)
        m.drawmeridians(meridians, labels=[0, 0, 0, 1], fontsize=10)

    plt.subplots_adjust(left=0.125,
                        bottom=0.085,
                        right=0.9,
                        top=0.95,
                        wspace=0.35,
                        hspace=0.07)

    cbar_ax = fig.add_axes([0.125, 0.05, 0.78, 0.015])
    cbar = fig.colorbar(cs,
                        cax=cbar_ax,
                        orientation='horizontal',
                        format="%.2f")
    cbar.set_label(titulo, fontproperties=prop, fontsize=20)

    plt.savefig(Path_Save + name + '.png', format='png')
    os.system(
        'scp ' + Path_Save + name +
        '.png [email protected]:/var/www/nacorreasa/Graficas_Resultados/Estudio'
    )
Example #2
0
    def drawmap(self):
	
	lllon,urlon,lllat,urlat=self.source_dim
	m = Basemap(lllon,lllat,urlon,urlat,projection='merc',resolution='l')
	m.drawmapboundary(fill_color='aqua') 
	# fill continents, set lake color same as ocean color. 
	m.drawcoastlines()
	m.fillcontinents(color='coral',lake_color='aqua')
	if urlon - lllon < 2.5:
	  dlon = 0.5
	elif urlon - lllon < 5.:
	  dlon =1.0
	else:
	  dlon = 2.
	m.drawparallels(np.arange(-90.,90.,1.0),labels=[1,0,0,0])
	m.drawmeridians(np.arange(-180.,180.,dlon),labels=[0,0,0,1])
	return m
Example #3
0
def vizInterp(nLons, nLats, ufunct, vfunct, files):
    '''Creates a visualization of the interpolation function
    nLons: list of mesh node logitudes
    nLats: list of mesh node latitudes
    uFunct: interpolation function of interpolated current u component magnitudes at each mesh node
    vFunct: interpolation function of interpolated current v component magnitudes at each mesh node
    files: list of file input names and directories for data retreival. 
    '''

    iModule = np.sqrt(ufunct**2 + vfunct**2) * 1.94384

    m = Basemap(llcrnrlon=-100.,
                llcrnrlat=0.,
                urcrnrlon=30.,
                urcrnrlat=70,
                projection='merc',
                resolution='l')
    x, y = m(np.array(nLons), np.array(nLats))

    print x[:10]
    print y[:10]
    print iModule.squeeze()[:10]
    #print len(iModule.squeeze())
    #print len(x)
    sys.exit()
    m.drawcoastlines()
    #m.fillcontinents(color='coral',lake_color='white')
    m.drawparallels(np.arange(0., 81., 20.),
                    labels=[True, False, False, False])
    m.drawmeridians(np.arange(-180., 181., 20.),
                    labels=[False, False, False, True])
    #m.drawmapboundary(fill_color='aqua')
    m.pcolormesh(x, y, iModule.squeeze(), cmap='jet', vmin=0, vmax=2)
    #m.quiver(x[::n, ::n], y[::n, ::n], ufunct[::n, ::n], vfunct[::n, ::n], scale=10, pivot='mid')
    m.colorbar(ticks=np.arange(0, 2.1, .2))

    plt.savefig(files[8], bbox_inches='tight')
    plt.show()
Example #4
0
# North: 0.05'58.7"S 149.32'31.5"E
# South: 12.26'14.3"S 151.49'38.0"E

# Precip bins to be used for precip
clevs = [0, 1, 2.5, 5, 7.5, 10, 15, 20, 30, 40, 50, 70, 100, 150]

# More map configuration
# draw coastlines, country boundaries
m.drawcoastlines(linewidth=0.25)
m.drawcountries(linewidth=0.25)
# draw parallels.
parallels = np.arange(-40., 40, 10.)
m.drawparallels(parallels, labels=[1, 0, 0, 0], fontsize=10)
# draw meridians
meridians = np.arange(80., 180., 10.)
m.drawmeridians(meridians, labels=[0, 0, 0, 1], fontsize=10)

# Make grid for TRMM data
ny = trmm_precip.shape[0]
nx = trmm_precip.shape[1]
lons, lats = m.makegrid(nx, ny)  # get lat/lons of ny by nx evenly spaced grid.
x, y = m(lons, lats)  # compute map proj coordinates.

# Make grid for SACA data
ny_saca = saca_precip.shape[0]
nx_saca = saca_precip.shape[1]
lons_saca, lats_saca = m.makegrid(nx_saca, ny_saca)
x_saca, y_saca = m(lons_saca, lats_saca)

# Make grid for TRMM Land Sea mask (updated)
lons_mask, lats_mask = np.meshgrid(lons_ls_mask, lats_ls_mask)
precip_colormap = matplotlib.colors.ListedColormap(nws_precip_colors)

# Precip bins to be used for precip
clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150]


# More map configuration
# draw coastlines, country boundaries
m.drawcoastlines(linewidth=0.25)
m.drawcountries(linewidth=0.25)
# draw parallels.
parallels = np.arange(-40.,40,10.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(80.,180.,10.)
m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)


# Make grid for TRMM data
# ny = trmm_precip.shape[0]
# nx = trmm_precip.shape[1]
# lons, lats = m.makegrid(nx, ny)                     # get lat/lons of ny by nx evenly spaced grid.
# x, y = m(lons, lats)                                # compute map proj coordinates.

# Alternative grid
lonst, latst = np.meshgrid(lons, lats)
x, y = m(lonst, latst)


# Make grid for SACA data
ny_saca = saca_precip.shape[0]
        cs2 = m.contour(x,
                        y,
                        datadict_od_slp[itim][timelist[itim]] / 100.,
                        latlon=True,
                        levels=np.arange(980, 1030, 5),
                        colors='w',
                        linewidths=1,
                        zorder=10)

        m.drawmapboundary()
        m.drawparallels(np.arange(-90., 91., 20.),
                        labels=[1, 0, 0, 0],
                        linewidth=0.5,
                        fontsize=8)
        m.drawmeridians(np.arange(-180., 181., 20.),
                        labels=[0, 0, 0, 1],
                        linewidth=0.5,
                        fontsize=8)

        # plt.clabel(cs1, fontsize=9, inline=1, fmt='%d')
        plt.clabel(cs2, fontsize=9, inline=1, fmt='%d')
        let = 'a) ' if itim == 0 else 'b) '
        titlestr = let + dateobj.strftime('%d %b')
        ax.set_title(titlestr)

    cax = fig.add_axes([0.92, 0.09, 0.015, 0.81])

    cb = fig.colorbar(cs1, cax=cax, orientation='vertical')
    cb.set_label(r'500 hPa $\Phi$ [dam]', fontsize=8)
    cb.ax.tick_params(labelsize=8)
    plt.subplots_adjust(left=0.05, bottom=0.05, top=0.94, right=0.92)
    fig.savefig(result_dir + 'synoptic_situation.pdf')
	timeDelta = []

	print temp
	m = Basemap(width=width,height=width,resolution='h',projection='aeqd',
            lat_0=lat_0,lon_0=lon_0)
	m.bluemarble(ax=None, scale=None)
	m.warpimage(image='bluemarble', scale=None)
	#m.arcgisimage(server='http://server.arcgisonline.com/ArcGIS', service='ESRI_Imagery_World_2D', xpixels=400, ypixels=None, dpi=96, verbose=False)
# fill background.
	m.drawmapboundary(fill_color='aqua')
	# draw coasts and fill continents.
	m.drawcoastlines(linewidth=0.5)
	#m.fillcontinents(color='coral',lake_color='aqua')
	# 20 degree graticule.
	m.drawparallels(np.arange(-80,81,20))
	m.drawmeridians(np.arange(-180,180,20))
	# draw a black dot at the center.
	xpt, ypt = m(lon_0, lat_0)
	m.plot([xpt],[ypt],'ko')
	# draw the title.
	plt.title('Azimuthal Equidistant Projection')
	plt.show()

	

	# for x in range(len(fakeDataLat)):
	# 	plotGPSMap(fakeDataLong[x],fakeDataLat[x],canvas)

	
	#canvas.update()