繁体   English   中英

Plot map 使用带有 hdf5 数据集的 cartopy

[英]Plot map using cartopy with hdf5 dataset

从 hdf4 切换后,我正在尝试 plot hdf5 文件。 我在计算文件中的经度和纬度变量时遇到了一些麻烦,它们都有一个形状 (4224, 3) 我猜对应于 1:值的数量和 2:开始/中间/结束颗粒点卫星。

我的问题是我的数据“extinction_coefficient_532”的形状 (4224, 399) 与我的经/纬度变量不匹配。 如果我错了请纠正我,但我需要一个形状为 (value, lon, lat) 的数据文件才能将其绘制在带有 cartopy 的 map 上。

有没有办法调整数据的形状以匹配 lon/lat 变量?

f['Longitude'].shape
Out[296]: (4224, 3)

f['Latitude'].shape
Out[297]: (4224, 3)

f['Extinction_Coefficient_532'].shape
Out[298]: (4224, 399)

编辑:

f['Extinction_Coefficient_532'].dtype
Out[122]: dtype('>f4')

祝你有美好的一天,托马斯

HDF5 只是一个数据容器。 具体的模式/数据层次结构取决于创建者。 理想情况下,它们提供可用于解释数据的文档或数据集属性。 没有细节很难给出具体的建议。

也就是说,我在NASA 的 CALIPSO Data 网站上找到了一些提到 Extinction_Coefficient_532 的文档。 它描述了上述所有 3 个数据集的格式。 此处提供的简要说明:

纬度/经度
激光足迹的大地纬度(/经度),以度为单位。 对于 5 公里剖面产品,报告了三个值:

  • 15 次射击平均值中包含的第一个脉冲的足迹纬度(/经度)
  • 时间中点(即 15 次连续激光发射中的第 8 次)的足迹纬度(/经度)
  • 最终脉冲的足迹纬度(/经度)。

消光系数 532
为检测到适当颗粒(即云或气溶胶)的每个剖面范围箱报告的颗粒消光系数; 那些未检测到微粒的范围箱包含填充值 (-9999)

基于此,我得出结论,你有 4224 个经纬度位置和匹配的消光系数。 如果这是正确的,请按照此页面上的示例提取数据以创建您的 plot: More advanced mapping with cartopy and matplotlib

它看起来像这样:

import h5py
with h5py.File('yourfilename.h5','r') as h5f:
# first extract the plot data:
# 1) Latitude, 2) Longitude and 3) Extinction Coefficient           
    pulse = 0  ## to select a particular pulse, valid range 0-2
    lats = h5f['Latitude'][:,pulse]
    lons = h5f['Longitude'][:,pulse]
    bin_no = 0 ## to plot a particular profile bin, valid range 0-398
    coef = h5f['Extinction_Coefficient_532'][:, bin_no]

# lines below reference plot data extracted above
# May need to be modified to generate the plot type you want.     
    ax = plt.axes(projection=ccrs.PlateCarree())   
    plt.contourf(lons, lats, coef, 60, transform=ccrs.PlateCarree())    
    ax.coastlines()    
    plt.show()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM