我正拼命地将一些对地静止数据从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
这是我的相关代码的一小段:
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的见识,问题似乎已解决,我想我可能对整个磁盘转换需要多长时间有些不耐烦/不了解。
答案 0 :(得分:1)
您似乎需要将transform关键字指定为imshow。此关键字告诉cartopy您的数据在什么坐标下,在这种情况下应该是对地静止的。
我没有您的数据集,因此无法测试,但是下面的代码段说明了这一概念。投影和变换是独立的,因此您应同时定义两者。对于数据集,transform参数的值(在下面的示例中为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.)