本文整理汇总了Python中Scientific.IO.NetCDF.NetCDFFile.description方法的典型用法代码示例。如果您正苦于以下问题:Python NetCDFFile.description方法的具体用法?Python NetCDFFile.description怎么用?Python NetCDFFile.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scientific.IO.NetCDF.NetCDFFile
的用法示例。
在下文中一共展示了NetCDFFile.description方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from Scientific.IO.NetCDF import NetCDFFile [as 别名]
# 或者: from Scientific.IO.NetCDF.NetCDFFile import description [as 别名]
def create(missingdata = False, missingdimension = False, missingvariable = False, incorrectdimension = False, incorrectvariable = False):
if (missingdata):
filename = 'missingdata.nc'
description = ', with missing data.'
elif (missingdimension):
filename = 'missingdimension.nc'
description = ', with a missing dimension.'
elif (missingvariable):
filename = 'missingvariable.nc'
description = ', with a missing variable.'
elif (incorrectdimension):
filename = 'incorrectdimension.nc'
description = ', with an incorrect dimension label.'
elif (incorrectvariable):
filename = 'incorrectvariable.nc'
description = ', with an incorrect variable label.'
else:
filename = 'valid.nc'
description = '.'
print "Creating " + filename + description
f = NetCDFFile(filename, 'w')
f.description = 'Example free surface height' + description
if (missingdata):
offset = -0.4
else:
offset = 0.0
x = arange(-1.2 + offset, 1.21 + offset, 0.2)
y = arange(-1.2, 1.21, 0.2)
h = zeros((len(x),len(y)))
for i in range(len(x)):
for j in range(len(y)):
# Nice ordering netCDF API - y,x !
h[j,i] = x[i] * y[j]
if (not incorrectdimension):
xdimlabel = 'x'
else:
xdimlabel = 'lat'
ydimlabel = 'y'
if (not incorrectvariable):
zdimlabel = 'z'
else:
zdimlabel = 'height'
print xdimlabel, ydimlabel, zdimlabel
# dimensions
f.createDimension(xdimlabel, len(x))
if (not missingdimension):
f.createDimension(ydimlabel, len(y))
# variables
fx = f.createVariable(xdimlabel, 'd', (xdimlabel,))
fx[:] = x
if (not missingdimension):
fy = f.createVariable(ydimlabel, 'd', (ydimlabel,))
fy[:] = y
if (not missingvariable):
fh = f.createVariable(zdimlabel, 'd', (xdimlabel, ydimlabel,))
fh[:] = h
else:
fh = f.createVariable(zdimlabel, 'd', (xdimlabel,))
fh[:] = x
f.close()
示例2: NetCDFFile
# 需要导入模块: from Scientific.IO.NetCDF import NetCDFFile [as 别名]
# 或者: from Scientific.IO.NetCDF.NetCDFFile import description [as 别名]
#!/usr/bin/env python
from Scientific.IO.NetCDF import NetCDFFile
from numpy import arange, zeros
import height
f = NetCDFFile('height.nc', 'w')
f.description = 'Example free surface height.'
x = arange(-1.2, 1.21, 0.2)
y = arange(-1.2, 1.21, 0.2)
h = zeros((len(x),len(y)))
for i in range(len(x)):
for j in range(len(y)):
# Nice ordering netCDF API - y,x !
h[j,i] = height.function([x[i], y[j]])
# dimensions
f.createDimension('x', len(x))
f.createDimension('y', len(y))
# variables
fx = f.createVariable('x', 'd', ('x',))
fy = f.createVariable('y', 'd', ('y',))
fh = f.createVariable('z', 'd', ('x', 'y',))
fx[:] = x
fy[:] = y
fh[:] = h