Ellipsoid

wrf的椭球体不是WGS84什么的,而是一个半径6370000的球体。如果用cartopy等地理包计算投影坐标时要先定义一个wrf的椭球。

import cartopy.crs as ccrs

wrf_globe = ccrs.Globe(ellipse='sphere',
                       semimajor_axis=6370000,
                       semiminor_axis=6370000)
proj1 = ccrs.LambertConformal(globe=wrf_globe,
                             central_longitude=120,
                             central_latitude=30,
                             standard_parallels=(29, 31))
proj2 = ccrs.LambertConformal(central_longitude=120,
                             central_latitude=30,
                             standard_parallels=(29, 31))
xy1 = proj1.transform_point(110, 40, ccrs.Geodetic())
xy2 = proj2.transform_point(110, 40, ccrs.Geodetic())
xy3 = proj1.transform_point(110, 40, ccrs.PlateCarree(globe=wrf_globe))
xy4 = proj1.transform_point(110, 40, ccrs.PlateCarree())
xy5 = proj2.transform_point(110, 40, ccrs.PlateCarree())

print(xy1)
print(xy2)
print(xy3)
print(xy4)
print(xy5)

------------------------------------------------------------------
(-864060.3838457272, 1155171.7447797281)
(-866304.4461720559, 1152875.5385104648)
(-12572992.685273314, 3772649.026660949)
(-864060.3838457272, 1155171.7447797281)
(-866304.4461720559, 1152875.5385104648)

只有xy1和xy4是对的.

wrf-python的ll_to_xy函数

ll_to_xy()返回的是从0开始的索引(i,j)(而且是脏话mass point的索引),不是具体的坐标值