【问题标题】:Problem with generating Countour Plot using MetPy使用 MetPy 生成等高线图的问题
【发布时间】:2020-12-03 17:06:23
【问题描述】:

我正在尝试使用 MetPy 和 ContourPlot 生成等压线。 我使用我自己的 netCDF 文件中的压力数据。背景热图生成正确,但对于轮廓,似乎存在一种插值错误。有谁知道如何解决水平白线的问题?

这是我用于绘图生成的代码:

cams = xr.open_dataset('20191129.nc')
contour = ContourPlot(clabels=True)
contour.data = cams
contour.field = 'PN'
contour.time = datetime.strptime('2020-11-29 00:00', '%Y-%m-%d %H:%M')
contour.level = units.Quantity(1000,units.hPa)
contour.linecolor = 'white'
contour.contours = 10

img = ImagePlot(colormap='jet',colorbar='horizontal')
img.data = cams
img.field = 'PN'
img.level = units.Quantity(1000,units.hPa)
img.time = datetime.strptime('2020-11-29 00:00', '%Y-%m-%d %H:%M')

panel = MapPanel()
panel.layers = ['coastline', 'borders', 'states',  'ocean', 'land']    
panel.title = 'Pressure @ Sea level '+date_str+' 00:00 UTC'
panel.plots = [contour,img]

pc = PanelContainer()
pc.size = (10, 8)
pc.panels = [panel]

pc.save('tt.png')

【问题讨论】:

    标签: python netcdf metpy


    【解决方案1】:

    看起来我在 MetPy 代码中发现了一个错误,该错误在绘制覆盖零子午线两侧的数据时出现: https://github.com/Unidata/MetPy/pull/1595

    临时解决方案是编辑文件 src/metpy/plots/declarative.py 并替换该行:

    x = x[:, 0] % 360
    

    x = x[:, 0]
    

    不,它工作正常。

    【讨论】:

      猜你喜欢
      • 2015-06-03
      • 2013-10-04
      • 2012-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多