Changeset 2533
- Timestamp:
- Mar 13, 2006, 2:18:40 PM (19 years ago)
- Location:
- inundation
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/examples/beach.py
r1977 r2533 10 10 ###################### 11 11 # Module imports 12 #13 12 14 13 import sys … … 16 15 #sys.path.append('..'+sep+'pyvolution') 17 16 18 from shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\17 from pyvolution.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary,\ 19 18 Transmissive_boundary, Time_boundary, Wind_stress 20 19 21 from p mesh2domain import pmesh_to_domain_instance22 from util import read_polygon, Polygon_function20 from pyvolution.pmesh2domain import pmesh_to_domain_instance 21 from utilities.polygon import read_polygon, Polygon_function 23 22 from math import pi 24 23 from Numeric import choose, greater, ones, sin, exp -
inundation/pyvolution/mesh.py
r2532 r2533 620 620 """ 621 621 622 from Numeric import arange 623 from utilities.numerical_tools import histogram 624 622 625 vertex_coordinates = self.vertex_coordinates 623 626 areas = self.areas 624 627 x = vertex_coordinates[:,0] 625 y = vertex_coordinates[:,1] 628 y = vertex_coordinates[:,1] 629 630 631 #Setup 10 bins for area histogram 632 m = max(areas) 633 bins = arange(0, m/10, m) 634 hist = histogram(areas, bins) 626 635 627 636 str = '------------------------------------------------\n' … … 633 642 str += ' Areas:\n' 634 643 str += ' A in [%f, %f]\n' %(min(areas), max(areas)) 644 str += ' Histogram:\n' 645 for i, count in enumerate(hist): 646 str += ' >=%f: %d\n' %(bins[i], count) 647 635 648 str += 'Boundary:\n' 636 649 str += ' Number of boundary segments == %d\n' %(len(self.boundary)) -
inundation/pyvolution/test_pmesh2domain.py
r2056 r2533 169 169 170 170 domain = pmesh_instance_to_domain_instance(mesh_instance, Domain) 171 171 172 os.remove(fileName) 172 173 #print "domain.tagged_elements", domain.tagged_elements -
inundation/utilities/numerical_tools.py
r2531 r2533 8 8 #(this should move to somewhere central) 9 9 try: 10 from scipy import ArrayType, array, sum, innerproduct, ravel, sqrt 10 from scipy import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate 11 11 except: 12 12 print 'Could not find scipy - using Numeric' 13 from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt 13 from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate 14 14 15 15 … … 190 190 191 191 192 193 def histogram(a, bins): 194 """Standard histogram straight from the Numeric manual 195 """ 196 197 n = searchsorted(sort(a), bins) 198 n = concatenate( [n, [len(a)]] ) 199 return n[1:]-n[:-1] 200 201 202 192 203 #################################################################### 193 204 #Python versions of function that are also implemented in numerical_tools_ext.c -
inundation/utilities/test_numerical_tools.py
r2526 r2533 141 141 142 142 143 def test_histogram(self): 144 """Test histogram with different bin boundaries 145 """ 146 147 a = [1,1,1,1,1,2,1,3,2,3,1,2,3,4,1] 148 149 150 #There are four elements greater than or equal to 3 151 bins = [3] 152 assert allclose(histogram(a, bins), [4]) 153 154 155 bins = [ min(a) ] 156 assert allclose(histogram(a, bins), [len(a)]) 157 158 159 bins = [ max(a)+0.00001 ] 160 assert allclose(histogram(a, bins), [0]) 161 162 163 bins = [1,2,3,4] 164 assert allclose(histogram(a, bins), [8,3,3,1]) 165 166 167 bins = [0.5,1.5,2,3] 168 assert allclose(histogram(a, bins), [8,0,3,4]) 169 170 171 172 143 173 def test_that_C_extension_compiles(self): 144 174 FN = 'util_ext.c'
Note: See TracChangeset
for help on using the changeset viewer.