【问题标题】:Projecting GOES-16 Geostationary data into Plate Carree Cartopy将 GOES-16 地球同步数据投影到 Plate Carree Cartopy
【发布时间】:2018-10-18 22:45:27
【问题描述】:

我正在拼命地尝试将一些地球静止数据从 GOES-16 netCDF 文件投影到不同的投影。我可以让背景图重新投影,但似乎无法让数据跟随。

我对此还不是很精通,但这是我目前所掌握的:

通过 NetCDF4 读取数据:

from netCDF4 import Dataset
nc = Dataset('OR_ABI-L1b-RadF- 
    M3C13_G16_s20182831030383_e20182831041161_c20182831041217.nc')

data = nc.variables['Rad'][:]

我在这里尝试获取地球同步信息:

sat_h = nc.variables['goes_imager_projection'].perspective_point_height
X = nc.variables['x'][:] * sat_h
Y = nc.variables['y'][:] * sat_h

# Satellite longitude
sat_lon = 
    nc.variables['goes_imager_projection'].longitude_of_projection_origin

# Satellite sweep
sat_sweep = nc.variables['goes_imager_projection'].sweep_angle_axis

这里我从 .nc 文件中获取投影数据:

proj_var = nc.variables['goes_imager_projection']

sat_height = proj_var.perspective_point_height
central_lon = proj_var.longitude_of_projection_origin
semi_major = proj_var.semi_major_axis
semi_minor = proj_var.semi_minor_axis
print proj_var

<type 'netCDF4._netCDF4.Variable'>
int32 goes_imager_projection()
    long_name: GOES-R ABI fixed grid projection
    grid_mapping_name: geostationary
    perspective_point_height: 35786023.0
    semi_major_axis: 6378137.0
    semi_minor_axis: 6356752.31414
    inverse_flattening: 298.2572221
    latitude_of_projection_origin: 0.0
    longitude_of_projection_origin: -75.0
    sweep_angle_axis: x
unlimited dimensions: 
current shape = ()
filling on, default _FillValue of -2147483647 used

这是我的相关代码的一个小sn-p:

fig = plt.figure(figsize=(30,20))

globe = ccrs.Globe(semimajor_axis=semi_major, semiminor_axis=semi_minor)
proj = ccrs.Geostationary(central_longitude=central_lon, 
    satellite_height=sat_height, globe=globe)

ax = fig.add_subplot(1, 1, 1, projection=proj)

IR_img = ax.imshow(data[:,:],origin='upper',extent=(X.min(), X.max(), Y.min(), Y.max()),
    cmap=IR_cmap,interpolation='nearest',vmin=162.,vmax=330.)

还有一张每个人都打得很好的照片: Data and map working

当我尝试说一个 Plate Carree 投影时,我会尝试:

proj = ccrs.PlateCarree(central_longitude=central_lon,globe=globe)

还有我失败的形象: Data and map not working

我尝试在 imshow 方法中弄乱范围,我尝试添加一个

transform=proj 

在 imshow 中,没有运气,它只是挂了,我必须重新启动内核。

显然这是我缺乏理解。如果有人可以快速轻松地帮助/解释我想改变地球静止投影的方式,我将不胜感激。

我正在运行古老的 python2。

感谢收看。

编辑:由于 DopplerShift 和 ajdawson 的见解,问题似乎得到了解决,我想我可能有点不耐烦/不知道完整磁盘转换需要多长时间。

【问题讨论】:

  • 你确定传入transform=proj就挂了?您正在使用的完整磁盘映像真的很大,并且 Cartopy 中的图像变形可能是计算密集型的。我敢打赌,这个操作很容易花费 10 分钟到一个小时。
  • 我确实考虑过这一点,但我很确定当我尝试数据的子集时它会坐一会儿,我不能只做键盘中断,所以我认为它完全挂了。我今天早上用 CONUS lat/lon ax.extent 再次尝试,现在它似乎在几秒钟内运行。感谢您一如既往地提供 DopplerShift 输入,您在很多情况下都帮助了我。
  • @MethaneClouds 我遇到了同样的问题。你能扩展一下你的最终解决方案在几秒钟内运行的样子吗?或者您是说全盘转换需要很长时间,而您基本上只是切换到 CONUS?

标签: python netcdf cartopy


【解决方案1】:

看来您需要为 imshow 指定 transform 关键字。此关键字告诉 cartopy 您的数据所在的坐标,在这种情况下应该是地球同步的。

我没有你的数据集,所以我无法对此进行测试,但下面的 sn-p 说明了这个概念。投影和变换是独立的,因此您应该定义两者。变换参数的值(下例中的crs)对于数据集是固定的,但投影可以是您喜欢的任何值(包括与crs 相同的值)。

请参阅此重新投影地球静止图像的示例:https://scitools.org.uk/cartopy/docs/v0.16/gallery/geostationary.html#sphx-glr-gallery-geostationary-py。另请参阅此处的投影和转换参数指南:https://scitools.org.uk/cartopy/docs/v0.16/tutorials/understanding_transform.html

globe = ccrs.Globe(semimajor_axis=semi_major, semiminor_axis=semi_minor)
crs = ccrs.Geostationary(central_longitude=central_lon, 
                         satellite_height=sat_height, globe=globe)
proj = ccrs.PlateCarree(central_longitude=central_lon, globe=globe)

ax = fig.add_subplot(1, 1, 1, projection=proj)

IR_img = ax.imshow(data[:,:], origin='upper',
                   extent=(X.min(), X.max(), Y.min(), Y.max()),
                   transform=crs,
                   cmap=IR_cmap,
                   interpolation='nearest', vmin=162., vmax=330.)

【讨论】:

  • 我也试过了,但内核仍然冻结。它一定与我的 python 设置有关,因为我已经完全按照你的建议进行了尝试,甚至在此处提出问题之前......
猜你喜欢
  • 1970-01-01
  • 2017-06-19
  • 1970-01-01
  • 2017-07-03
  • 1970-01-01
  • 2016-11-02
  • 2014-03-18
  • 1970-01-01
  • 2023-03-04
相关资源
最近更新 更多