本文整理汇总了Python中cdo.Cdo.griddes方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.griddes方法的具体用法?Python Cdo.griddes怎么用?Python Cdo.griddes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.griddes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getLonLat
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import griddes [as 别名]
def __getLonLat(self, ifile):
"""
Get vectors with lon and lat values from a netdf file using cdo.griddes
Was introduced because we were using a damaged grid
lon,lat valued are located in the center of a gridbox
:param ifile: netcdf fn
:result: lon,lat vectors
"""
def searchGriddes(grid, needle):
tmp = [x for x in grid if x.find(needle) != -1]
return float(tmp[0].split(' ')[-1])
from cdo import Cdo
cdo = Cdo()
grid = cdo.griddes(input=ifile)
try:
xinc = searchGriddes(grid, 'xinc')
xsize = searchGriddes(grid, 'xsize')
xfirst = searchGriddes(grid, 'xfirst')
except:
xinc = searchGriddes(grid, 'yinc')
xsize = searchGriddes(grid, 'ysize')
xfirst = searchGriddes(grid, 'yfirst')
yfirst = searchGriddes(grid, 'yfirst')
ysize = searchGriddes(grid, 'ysize')
yinc = searchGriddes(grid, 'yinc')
lon = np.arange(xfirst+xinc/2, xsize*xinc+xfirst+xinc/2, xinc, dtype=float)
lat = np.arange(yfirst+yinc/2, ysize*yinc+yfirst+yinc/2, yinc, dtype=float)
lon = np.arange(xfirst, xsize*xinc+xfirst, xinc, dtype=float)
lat = np.arange(yfirst, ysize*yinc+yfirst, yinc, dtype=float)
return lon, lat