我试图在底图中绘制风倒钩,我有两个单独的netCDF文件。这是我试图生产的东西,或者类似的东西:如何在python中读取netCDF文件中的uwnd变量?
从mpl_toolkits。basemap从netCDF4导入数据集,date2index导入numpy作为np导入matplotlib。从IPython导入datetime。从IPython.core.display import HTML导入netCDF4 as nc plt.clf() nc_file = '042711_V. txt 'nc' nc_file2 = '042711_U. c'V = Dataset(nc_file, mode='r') U = Dataset(nc_file2, mode='r'
这验证了uwnd确实是一个变量,但为什么它不读取?
OrderedDict([(u'lat', float32 lat(lat)单位:degrees_north actual_range:[90。-90年。[long_name:纬度无限维度:当前形状=(73,)填充off), (u'lon', float32 lon(lon)单位:degrees_east long_name:经度actual_range: [0.](u'time', float64 time(time) units: hours since 1800-1-1 00:00:0.0 long_name: time actual_range: [71870952.]71870952.[delta_t: 0000-01-00无限制维度:time current shape = (1,) filling off), (u'uwnd', float32 uwnd(time, lat, lon) long_name: u wind valid_range:[-99999。99999.] actual_range: [-26.84999084 377.20001221] units: m/s add_offset: 0.0 scale_factor: 1.0 missing_value: -9.96921e+36 precision: 99 least_signant_digit: 99 var_desc: u wind数据集:CDC Derived NCEP Reanalysis Products level_desc: 500mb压力级别统计:Composite parent_stat:其他无限维度:时间当前形状=(1,73,144)填充off)] KeyError: 'uwnd'
我正试着在地图上画一些倒钩。我已经成功地让它读取时间,经度和纬度,但什么是uwnd的意思,我如何把它读到numpy格式?
下面是我找到的如何读取netCDF文件的网站:http://www.hydro.washington.edu/~jhamman/hydro-logic/blog/2013/10/12/plot-netcdf-data/