添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
from netCDF4 import Dataset
from wrf import getvar, CoordPair, xy_to_ll, ll_to_xy, get_cartopy, latlon_coords
import cartopy.crs as ccrs
wrfout = Dataset('wrfout_d01_2019-08-07_00_00_00')
slp = getvar(wrfout, 'slp', timeidx=0)
cart_proj = get_cartopy(slp)
xy_cartopy = cart_proj.transform_point(122, 30, ccrs.PlateCarree())
xy_wrfpy = ll_to_xy(wrfout, 30, 122, as_int=False)
print(xy_cartopy)
print(xy_wrfpy)
Result:
(204023.2701774671, 70339.28035986092)
<xarray.DataArray 'xy' (x_y: 2)>
array([121.50213256, 119.3614694 ])
Coordinates:
    latlon_coord  object CoordPair(lat=30, lon=122)
  * x_y           (x_y) <U1 'x' 'y'
I've tried other map projection calculators and have confirmed that the result given by cartopy is correct. So what excactly does ll_to_xy returns? Looking forward to any replies.
from netCDF4 import Dataset
from wrf import getvar, CoordPair, xy_to_ll, ll_to_xy, get_cartopy, latlon_coords
import cartopy.crs as ccrs
wrfout = Dataset('wrfout_d01_2019-08-07_00_00_00')
slp = getvar(wrfout, 'slp', timeidx=0)
cart_proj = get_cartopy(slp)
xy_cartopy = cart_proj.transform_point(122, 30, ccrs.PlateCarree())
xy_wrfpy = ll_to_xy(wrfout, 30, 122, as_int=False)
print(xy_cartopy)
print(xy_wrfpy)
Result:
(204023.2701774671, 70339.28035986092)
<xarray.DataArray 'xy' (x_y: 2)>
array([121.50213256, 119.3614694 ])
Coordinates:
    latlon_coord  object CoordPair(lat=30, lon=122)
  * x_y           (x_y) <U1 'x' 'y'
I've tried other map pprojection caculators and have confirmed that the result given by cartopy is correct. So what excactly does ll_to_xy returns? Looking forward to any replies. OK, I get it. What ll_to_xy returns is not the xy coordinate itself but the grid index starting from 0. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies. Accept Learn more…