Changeset 2526
- Timestamp:
- Mar 12, 2006, 9:25:40 PM (19 years ago)
- Location:
- inundation
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/data_manager.py
r2521 r2526 3086 3086 from data_manager import get_dataobject 3087 3087 from os import sep, path 3088 from util import mean3088 from utilities.numerical_tools import mean 3089 3089 3090 3090 if verbose == True:print 'Creating domain from', filename -
inundation/pyvolution/least_squares.py
r2516 r2526 1134 1134 from math import pi, cos, sin, sqrt 1135 1135 from Numeric import zeros, Float 1136 from util import mean1136 from utilities.numerical_tools import mean 1137 1137 1138 1138 if self.spatial is True: -
inundation/pyvolution/mesh.py
r2502 r2526 495 495 from config import epsilon 496 496 from math import pi 497 from util import anglediff497 from utilities.numerical_tools import anglediff 498 498 499 499 N = self.number_of_elements -
inundation/pyvolution/quantity.py
r2516 r2526 1189 1189 1190 1190 from Numeric import zeros, Float 1191 from util import gradient1191 from utilitites.numerical_tools import gradient 1192 1192 1193 1193 centroid_coordinates = quantity.domain.centroid_coordinates -
inundation/pyvolution/test_data_manager.py
r2520 r2526 5 5 import copy 6 6 from Numeric import zeros, array, allclose, Float 7 from util import mean7 from utilities.numerical_tools import mean 8 8 import tempfile 9 9 import os -
inundation/pyvolution/test_least_squares.py
r2502 r2526 1085 1085 #Check basic interpolation of one quantity using averaging 1086 1086 #(no interpolation points or spatial info) 1087 from util import mean1087 from utilities.numerical_tools import mean 1088 1088 I = Interpolation_function(time, [mean(Q[0,:]), 1089 1089 mean(Q[1,:]), -
inundation/pyvolution/test_quantity.py
r2347 r2526 1065 1065 from shallow_water import Domain, Transmissive_boundary 1066 1066 from Numeric import zeros, Float 1067 from util import mean1067 from utilities.numerical_tools import mean 1068 1068 1069 1069 #Create basic mesh … … 1155 1155 from shallow_water import Domain, Transmissive_boundary 1156 1156 from Numeric import zeros, Float 1157 from util import mean1157 from utilities.numerical_tools import mean 1158 1158 1159 1159 -
inundation/pyvolution/test_shallow_water.py
r2516 r2526 1685 1685 domain = Domain(points, vertices, boundary) 1686 1686 domain.smooth = False 1687 domain.default_order =21687 domain.default_order = 2 1688 1688 domain.beta_h = 0.2 1689 domain.set_quantities_to_be_stored(['stage']) 1689 1690 1690 1691 #IC -
inundation/pyvolution/test_util.py
r2509 r2526 38 38 # 'distance is wrong!') 39 39 40 def test_angle(self):41 from util import angle42 43 assert allclose(angle([1.0, 1.0])/pi*180, 45.0)44 45 46 def test_anglediff(self):47 from util import anglediff48 49 assert allclose(anglediff([0.0, 1.], [1.0, 1.0])/pi*180, 45.0)50 51 52 40 53 41 def test_file_function_time1(self): … … 131 119 domain1 = Domain(points, vertices, boundary) 132 120 133 from util import mean121 from utilities.numerical_tools import mean 134 122 domain1.reduction = mean 135 123 domain1.smooth = True #NOTE: Mimic sww output where each vertex has … … 331 319 332 320 333 from util import mean321 from utilities.numerical_tools import mean 334 322 domain1.reduction = mean 335 323 domain1.smooth = True #NOTE: Mimic sww output where each vertex has -
inundation/pyvolution/util.py
r2516 r2526 8 8 import utilities.polygon 9 9 from warnings import warn 10 11 12 def angle(v):13 """Compute angle between e1 (the unit vector in the x-direction)14 and the specified vector15 """16 17 from math import acos, pi, sqrt18 from Numeric import sum, array19 20 l = sqrt( sum (array(v)**2))21 v1 = v[0]/l22 v2 = v[1]/l23 24 25 theta = acos(v1)26 27 #try:28 # theta = acos(v1)29 #except ValueError, e:30 # print 'WARNING (util.py): Angle acos(%s) failed: %s' %(str(v1), e)31 #32 # #FIXME, hack to avoid acos(1.0) Value error33 # # why is it happening?34 # # is it catching something we should avoid?35 # #FIXME (Ole): When did this happen? We need a unit test to36 # #reveal this condition or otherwise remove the hack37 #38 # s = 1e-639 # if (v1+s > 1.0) and (v1-s < 1.0) :40 # theta = 0.041 # elif (v1+s > -1.0) and (v1-s < -1.0):42 # theta = 3.141592653589793143 # print 'WARNING (util.py): angle v1 is %f, setting acos to %f '\44 # %(v1, theta)45 46 if v2 < 0:47 #Quadrant 3 or 448 theta = 2*pi-theta49 50 return theta51 52 53 def anglediff(v0, v1):54 """Compute difference between angle of vector x0, y0 and x1, y1.55 This is used for determining the ordering of vertices,56 e.g. for checking if they are counter clockwise.57 58 Always return a positive value59 """60 61 from math import pi62 63 a0 = angle(v0)64 a1 = angle(v1)65 66 #Ensure that difference will be positive67 if a0 < a1:68 a0 += 2*pi69 70 return a0-a171 72 73 def mean(x):74 from Numeric import sum75 return sum(x)/len(x)76 77 10 78 11 … … 465 398 466 399 400 def angle(v): 401 """Temporary Interface to new location""" 402 403 import utilities.numerical_tools as NT 404 405 msg = 'angle has moved from util.py. ' 406 msg += 'Please use "from utilities.numerical_tools import angle"' 407 warn(msg, DeprecationWarning) 408 409 return NT.angle(v) 410 411 def anglediff(v0, v1): 412 """Temporary Interface to new location""" 413 414 import utilities.numerical_tools as NT 415 416 msg = 'anglediff has moved from util.py. ' 417 msg += 'Please use "from utilities.numerical_tools import anglediff"' 418 warn(msg, DeprecationWarning) 419 420 return NT.anglediff(v0, v1) 421 422 423 def mean(x): 424 """Temporary Interface to new location""" 425 426 import utilities.numerical_tools as NT 427 428 msg = 'mean has moved from util.py. ' 429 msg += 'Please use "from utilities.numerical_tools import mean"' 430 warn(msg, DeprecationWarning) 431 432 return NT.mean(x) 433 467 434 def point_on_line(*args, **kwargs): 468 435 """Temporary Interface to new location""" -
inundation/test_all.py
r2390 r2526 23 23 exclude_dirs = ['pypar_dist', #Special requirements 24 24 'props', 'wcprops', 'prop-base', 'text-base', '.svn', #Svn 25 'tmp' ]#,26 #'pmesh'] #Name conflict on my home machine (Ole)25 'tmp', 26 'pmesh'] #Name conflict on my home machine (Ole) 27 27 28 28 -
inundation/triangle/triang.c
r2142 r2526 53 53 54 54 #include "Python.h" 55 55 56 56 57 -
inundation/utilities/numerical_tools.py
r2516 r2526 5 5 6 6 import Numeric 7 8 9 10 def angle(v): 11 """Compute angle between e1 (the unit vector in the x-direction) 12 and the specified vector 13 """ 14 15 from math import acos, pi, sqrt 16 from Numeric import sum, array 17 18 l = sqrt( sum (array(v)**2)) 19 v1 = v[0]/l 20 v2 = v[1]/l 21 22 23 theta = acos(v1) 24 25 #try: 26 # theta = acos(v1) 27 #except ValueError, e: 28 # print 'WARNING (util.py): Angle acos(%s) failed: %s' %(str(v1), e) 29 # 30 # #FIXME, hack to avoid acos(1.0) Value error 31 # # why is it happening? 32 # # is it catching something we should avoid? 33 # #FIXME (Ole): When did this happen? We need a unit test to 34 # #reveal this condition or otherwise remove the hack 35 # 36 # s = 1e-6 37 # if (v1+s > 1.0) and (v1-s < 1.0) : 38 # theta = 0.0 39 # elif (v1+s > -1.0) and (v1-s < -1.0): 40 # theta = 3.1415926535897931 41 # print 'WARNING (util.py): angle v1 is %f, setting acos to %f '\ 42 # %(v1, theta) 43 44 if v2 < 0: 45 #Quadrant 3 or 4 46 theta = 2*pi-theta 47 48 return theta 49 50 51 def anglediff(v0, v1): 52 """Compute difference between angle of vector x0, y0 and x1, y1. 53 This is used for determining the ordering of vertices, 54 e.g. for checking if they are counter clockwise. 55 56 Always return a positive value 57 """ 58 59 from math import pi 60 61 a0 = angle(v0) 62 a1 = angle(v1) 63 64 #Ensure that difference will be positive 65 if a0 < a1: 66 a0 += 2*pi 67 68 return a0-a1 69 7 70 8 71 def mean(x): -
inundation/utilities/test_numerical_tools.py
r2516 r2526 18 18 def tearDown(self): 19 19 pass 20 21 22 def test_angle(self): 23 assert allclose(angle([1.0, 1.0])/pi*180, 45.0) 24 25 26 def test_anglediff(self): 27 assert allclose(anglediff([0.0, 1.], [1.0, 1.0])/pi*180, 45.0) 20 28 21 29
Note: See TracChangeset
for help on using the changeset viewer.