import netCDF4 as nc
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import ListedColormap
newcolors = np.array([
[74,234,230, 256],
[40,152,196, 256],
[40,90,220, 256],
[32,24,172, 256],
[100,218,80, 256],
[42,182,46, 256],
[8,118,36, 256],
[222,184,96, 256],
[222,222,0, 256],
[254,254,0, 256],
[218,0,0, 256],
[198,0,0, 256],
[254,0,0, 256],
[254,0,254, 256]])/256
newcmp = ListedColormap(newcolors)
path="/opt/hdd/publicData/tp/CR/2016/20160611/Z9200/MSP1_PMSC_AIWRADAR_CR_Z9200_201606110954_00000-00000.nc"
with nc.Dataset(path) as data:
a=data["CR"][:][0]
latArr=data["lat"][:]
lonArr=data["lon"][:]
plt.pcolormesh(lonArr,latArr,a,cmap=newcmp,
vmax=60,
vmin=-5)
plt.show()
网友评论