本文整理汇总了Python中Scientific.IO.NetCDF.NetCDFFile.file_format方法的典型用法代码示例。如果您正苦于以下问题:Python NetCDFFile.file_format方法的具体用法?Python NetCDFFile.file_format怎么用?Python NetCDFFile.file_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scientific.IO.NetCDF.NetCDFFile
的用法示例。
在下文中一共展示了NetCDFFile.file_format方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeNcFile
# 需要导入模块: from Scientific.IO.NetCDF import NetCDFFile [as 别名]
# 或者: from Scientific.IO.NetCDF.NetCDFFile import file_format [as 别名]
def writeNcFile(data, fileName=None, oldStyle=1):
if not ncOk:
raise Exception('module Scientific.IO.NetCDF not found, writeNcFile() failed!')
if not fileName:
fileName = data['name']+'_weather.nc'
f = NetCDFFile(fileName, 'w')
f.createDimension('time', data['time'].shape[0])
f.file_format = file_format
if oldStyle:
f.createDimension('scalar', 1)
if data.has_key('comment'):
f.comment = data['comment']
else:
f.comment = 'created by MeteonormFile.py (v%s)' % version
if data.has_key('source_file'):
f.source_file = str(data['source_file'])
for vn in ('latitude', 'longitude', 'height'):
setattr(f, vn, data[vn])
if oldStyle:
v = f.createVariable(vn, 'd', ('scalar', ))
v[:] = [data[vn]]
setattr(f, 'longitude_0', 15.0*data['timezone'])
if oldStyle:
v = f.createVariable('longitude_0', 'd', ('scalar', ))
v[:] = [15.0 * data['timezone']]
for vn in variables.keys():
t = variables[vn][1]
v = f.createVariable(vn, t, ('time',))
v[:] = data[vn].astype(t)
oname = variables[vn][0]
if oname.startswith('<'): oname = oname[1:]
if oname.endswith('>'): oname = oname[:-1]
v.original_name = oname
v.unit = variables[vn][2]
f.sync()
f.close()