本文整理匯總了Python中anuga.shallow_water.shallow_water_domain.Domain.evolve_to_end方法的典型用法代碼示例。如果您正苦於以下問題:Python Domain.evolve_to_end方法的具體用法?Python Domain.evolve_to_end怎麽用?Python Domain.evolve_to_end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類anuga.shallow_water.shallow_water_domain.Domain
的用法示例。
在下文中一共展示了Domain.evolve_to_end方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_sww2pts_centroids_de0
# 需要導入模塊: from anuga.shallow_water.shallow_water_domain import Domain [as 別名]
# 或者: from anuga.shallow_water.shallow_water_domain.Domain import evolve_to_end [as 別名]
def test_sww2pts_centroids_de0(self):
"""Test that sww information can be converted correctly to pts data at specified coordinates
- in this case, the centroids.
"""
import time, os
from anuga.file.netcdf import NetCDFFile
# Used for points that lie outside mesh
NODATA_value = 1758323
# Setup
from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular
# Create shallow water domain
domain = Domain(*rectangular(2, 2))
B = Transmissive_boundary(domain)
domain.set_boundary( {'left': B, 'right': B, 'top': B, 'bottom': B})
domain.set_name('datatest_de0')
ptsfile = domain.get_name() + '_elevation.pts'
swwfile = domain.get_name() + '.sww'
domain.set_datadir('.')
domain.format = 'sww'
domain.set_quantity('elevation', lambda x,y: -x-y)
domain.geo_reference = Geo_reference(56,308500,6189000)
sww = SWW_file(domain)
sww.store_connectivity()
sww.store_timestep()
#self.domain.tight_slope_limiters = 1
domain.evolve_to_end(finaltime = 0.01)
sww.store_timestep()
# Check contents in NetCDF
fid = NetCDFFile(sww.filename, netcdf_mode_r)
# Get the variables
x = fid.variables['x'][:]
y = fid.variables['y'][:]
elevation = fid.variables['elevation'][:]
time = fid.variables['time'][:]
stage = fid.variables['stage'][:]
volumes = fid.variables['volumes'][:]
# Invoke interpolation for vertex points
points = num.concatenate( (x[:,num.newaxis],y[:,num.newaxis]), axis=1 )
points = num.ascontiguousarray(points)
sww2pts(domain.get_name() + '.sww',
quantity = 'elevation',
data_points = points,
NODATA_value = NODATA_value)
ref_point_values = elevation
point_values = Geospatial_data(ptsfile).get_attributes()
#print 'P', point_values
#print 'Ref', ref_point_values
assert num.allclose(point_values, ref_point_values)
# Invoke interpolation for centroids
points = domain.get_centroid_coordinates()
#print points
sww2pts(domain.get_name() + '.sww',
quantity = 'elevation',
data_points = points,
NODATA_value = NODATA_value)
#ref_point_values = [-0.5, -0.5, -1, -1, -1, -1, -1.5, -1.5] #At centroids
ref_point_values = [-0.77777777, -0.77777777, -0.99999998, -0.99999998,
-0.99999998, -0.99999998, -1.22222221, -1.22222221]
point_values = Geospatial_data(ptsfile).get_attributes()
#print 'P', point_values
#print 'Ref', ref_point_values
assert num.allclose(point_values, ref_point_values)
fid.close()
#Cleanup
os.remove(sww.filename)
os.remove(ptsfile)