本文整理汇总了Python中anuga.file.netcdf.NetCDFFile.variables['ymomentum'][:]方法的典型用法代码示例。如果您正苦于以下问题:Python NetCDFFile.variables['ymomentum'][:]方法的具体用法?Python NetCDFFile.variables['ymomentum'][:]怎么用?Python NetCDFFile.variables['ymomentum'][:]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anuga.file.netcdf.NetCDFFile
的用法示例。
在下文中一共展示了NetCDFFile.variables['ymomentum'][:]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_timeboundary
# 需要导入模块: from anuga.file.netcdf import NetCDFFile [as 别名]
# 或者: from anuga.file.netcdf.NetCDFFile import variables['ymomentum'][:] [as 别名]
def prepare_timeboundary(filename, verbose = False):
"""Convert benchmark 2 time series to NetCDF tms file.
This is a 'throw-away' code taylor made for files like
'Benchmark_2_input.txt' from the LWRU2 benchmark
"""
from anuga.file.netcdf import NetCDFFile
if verbose: print 'Creating', filename
# Read the ascii (.txt) version of this file
fid = open(filename[:-4] + '.txt')
# Skip first line
line = fid.readline()
# Read remaining lines
lines = fid.readlines()
fid.close()
N = len(lines)
T = num.zeros(N, num.float) #Time
Q = num.zeros(N, num.float) #Values
for i, line in enumerate(lines):
fields = line.split()
T[i] = float(fields[0])
Q[i] = float(fields[1])
# Create tms NetCDF file
fid = NetCDFFile(filename, 'w')
fid.institution = 'Geoscience Australia'
fid.description = 'Input wave for Benchmark 2'
fid.starttime = 0.0
fid.createDimension('number_of_timesteps', len(T))
fid.createVariable('time', netcdf_float, ('number_of_timesteps',))
fid.variables['time'][:] = T
fid.createVariable('stage', netcdf_float, ('number_of_timesteps',))
fid.variables['stage'][:] = Q[:]
fid.createVariable('xmomentum', netcdf_float, ('number_of_timesteps',))
fid.variables['xmomentum'][:] = 0.0
fid.createVariable('ymomentum', netcdf_float, ('number_of_timesteps',))
fid.variables['ymomentum'][:] = 0.0
fid.close()