资源简介
公开数据,与一些自己的学习笔记。供大家借阅。。。。。。
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Sat Dec 9 00:31:41 2017
@author: aze
“““
from mpl_toolkits.basemap import basemap cm
# requires netcdf4-python (netcdf4-python.googlecode.com)
from netCDF4 import Dataset as NetCDFFile
import numpy as np
import matplotlib.pyplot as plt
# plot rainfall from NWS using special precipitation
# colormap used by the NWS and included in basemap.
nc = NetCDFFile(‘D:/python/nc/merg_2014032900_4km-pixel.nc4‘)
# data from http://water.weather.gov/precip/
print(nc)
prcpvar = nc.variables[‘Tb‘]
data = prcpvar[:]
‘‘‘确定经纬度的最小最大值,以及点的个数。
因为在确定画图范围时,basemap,不能直接根据你选的定你所选画定的范围,自动选取
所在区域的要素的值。
nxny
通过比例关系,确定要素是从第n1行n2列到第n3行n4列。
‘‘‘
l=nc.variables[‘lon‘]
a=nc.variables[‘lat‘]
NX=l[:]
NY=a[:]
lx=len(NX)
ly=len(NY)
minxminy=min(NX)min(NY)
maxxmaxy=max(NX)max(NY)
‘‘‘
# create figure and axes instances
‘‘‘
fig = plt.figure(figsize=(88))
ax = fig.add_axes([0.10.10.80.8])
‘‘‘确定中心,以及地图大小
lon_0lat_0
llcrnrlaturcrnrlat
llcrnrlonurcrnrlon‘‘‘
lon_0lat_0=115.028.0
llcrnrlaturcrnrlat=20.030.0
llcrnrlonurcrnrlon=110.0130.0
# create polar stereographic basemap instance.
m = basemap(projection=‘mill‘lon_0=lon_0lat_0=lat_0lat_ts=lat_0\
llcrnrlat=llcrnrlaturcrnrlat=urcrnrlat\
llcrnrlon=llcrnrlonurcrnrlon=urcrnrlon\
rsphere=6371200.resolution=‘l‘area_thresh=10000)
‘‘‘
llcrnrlat=latcorners[0]urcrnrlat=latcorners[2]\
llcrnrlon=loncorners[0]urcrnrlon=loncorners[2]\
rsphere=6371200.resolution=‘l‘area_thresh=10000)‘‘‘
# draw coastlines state and country boundaries edge of map.
m.drawcoastlines()
#m.drawlsmask(land_color=‘coral‘ocean_color=‘aqua‘)
m.drawcountries()
m.drawstates()
m.drawrivers(linewidth=0.6color=‘b‘)
# draw parallels.
parallels = np.arange(0.040.5.)
m.drawparallels(parallelslabels=[1000]fontsize=10)
# draw meridians
meridians = np.arange(90.0130.05.0)
m.drawmeridians(meridianslabels=[0001]fontsize=10)
‘‘‘确定,经纬度格点数,用来计算所选区域的经纬度‘‘‘
ny1 =int(ly*(llcrnrlat-miny)/(maxy-miny)); nx1 =int(lx*(llcrnrlon-minx)/(maxx-minx))
ny2 =int(ly*(urcrnrlat-miny)/(maxy-miny)); nx2 =int(lx*(urcrnrlon-minx)/(maxx-minx))
#print(ny1ny2nx1nx2)
lons lats =m.makegrid(nx2-nx1 ny2-ny1)
#print(lonslats)
#print(lonslats)# get lat/lons of ny by nx evenly space grid.
x y = m(lons lats) # compute map proj coordinates.
# draw filled contours.
#print(xy)
tb=[[0 for i in range (nx2-nx1)] for i in range(ny2-ny1)]
‘‘‘内是第二,外是第一‘‘‘
jj=0
for j in range(ny1ny2):
ii=0
for i in range(nx1nx2):
tb[jj][ii]=data[1][j][i]
ii+=1
jj+=1
print(len(tb))
#clevs = [270271272273274275276277278279280]
cs =m.contourf(xytb)#clevs)#cmap=cm.s3pcpn)
m.contour(xytb)
# add colorbar.
cbar = m.colorbar(cslocation=‘bottom‘pad=“5%“)
cbar.set_label(‘k‘)
# add title
#plt.title(prcpvar
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3322 2017-12-10 22:37 2013032900_4km.py
文件 203039 2017-12-10 22:43 Figure初次完美.png
文件 36119375 2017-12-09 00:25 merg_2014032900_4km-pixel.nc4
----------- --------- ---------- ----- ----
36325736 3
相关资源
- python-Django-网上购书商城完整源码
- Python-基于深度神经网络和蒙特卡罗树
- python 2.7.15
- python-3.6.4.exe32位
- PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32
- Python深度学习.pdf+代码
- Python3.4 Numpy安装包
- Python入门到实践经典教材
- Learning Robotics using Python 2nd
- 流畅的python.pdf
- Math Adventures with Python: An Illustrated Gu
- Python网络爬虫与信息提取课件
- 《父与子的编程之旅:与小卡特一起
- 2019新书系列-Introduction to Python Progra
- 卷积神经网络的Python实现-参考代码
- 深度学习入门:基于Python的理论与实
- 语料库翻译学文库语料库与Python应用
- python操作海康威视相机------例程由海
- PyDev 5.2.0
- python深度学习2018中文版、英文版和源
- 最新python-3.7.3-64-安装版
- Python核心编程第3版PDF高清晰完整中文
- web2py_win_py37.zip
- python_pcl-0.3-cp36-cp36m-win_amd64.whl
- tesseract-ocr安装包和中文语言包
- Python3_3.6.8_x86精简绿色版
- python-3.4.4.amd64.msi
- Python数据分析基础(电子版)
- Python神经网络编程高清版.pdf
- Python3.7.0_b4 windows 64位 安装包
评论
共有 条评论