因为工作原因最近需要用python根据nc文件出一张雷达图,废话不多说上代码
import sys import xarray as xr from pylab import * from apscheduler.schedulers.blocking import BlockingScheduler from datetime import datetime import os import datetime as datetimes import bottle from bottle import run # 根据路径生成ppt @bottle.post('/radarImg', method='post') def radarImg(): try: path = bottle.request.query.path #nc文件路径 imgPath = bottle.request.query.imgPath#图片存放路径 infile = r'{}'.format(path) dataset = xr.open_dataset(infile) # print(dataset) dbz3d = dataset.DBZ.data[0]#获取nc文件数据要素 dbz3d = dbz3d.astype(int)#因为nc文件会有nan的情况需要把数据进行筛选 # print(dbz3d.shape) maxdbz = np.nanmax(dbz3d, axis=0) colors = ['#484892', '#01a0f6', '#00ecec', '#01ff00', '#00c800', '#019000', '#ffff00', '#e7c000', '#ff9000',