Changeset 2585
- Timestamp:
- Mar 23, 2006, 9:22:26 PM (17 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/least_squares.py
r2583 r2585 216 216 217 217 if verbose: 218 219 point_coordinates = ensure_numeric(point_coordinates) 220 vertex_coordinates = ensure_numeric(vertex_coordinates) 221 222 X = point_coordinates[:,0] 223 Y = point_coordinates[:,1] 224 Z = point_attributes 225 218 226 print '+------------------------------------------------' 219 print 'least squares finished' 220 print 'points: %d points' %(len(point_attributes)) 221 print ' x in [%f, %f]'%(min(point_coordinates[:,0]), 222 max(point_coordinates[:,0])) 223 print ' y in [%f, %f]'%(min(point_coordinates[:,1]), 224 max(point_coordinates[:,1])) 225 print ' z in [%f, %f]'%(min(point_attributes), 226 max(point_attributes)) 227 print 228 print 'mesh: %d vertices' %(len(vertex_attributes)) 229 print ' xi in [%f, %f]'%(min(vertex_coordinates[:,0]), 230 max(vertex_coordinates[:,0])) 231 print ' eta in [%f, %f]'%(min(vertex_coordinates[:,1]), 232 max(vertex_coordinates[:,1])) 233 print ' zeta in [%f, %f]'%(min(vertex_attributes), 234 max(vertex_attributes)) 227 print 'Least squares statistics' 228 print '+------------------------------------------------' 229 print 'points: %d points' %(len(Z)) 230 print ' x in [%f, %f]'%(min(X), max(X)) 231 print ' y in [%f, %f]'%(min(Y), max(Y)) 232 print ' z in [%f, %f]'%(min(Z), max(Z)) 233 print 234 235 indices = interp.point_indices 236 if indices is not None: 237 X = take(X, indices) 238 Y = take(Y, indices) 239 Z = take(Z, indices) 240 print 'Cropped points: %d points' %(len(Z)) 241 print ' x in [%f, %f]'%(min(X), max(X)) 242 print ' y in [%f, %f]'%(min(Y), max(Y)) 243 print ' z in [%f, %f]'%(min(Z), max(Z)) 244 print 245 246 Xi = vertex_coordinates[:,0] 247 Eta = vertex_coordinates[:,1] 248 Zeta = vertex_attributes 249 print 'Mesh: %d vertices' %(len(Zeta)) 250 print ' xi in [%f, %f]'%(min(Xi), max(Xi)) 251 print ' eta in [%f, %f]'%(min(Eta), max(Eta)) 252 print ' zeta in [%f, %f]'%(min(Zeta), max(Zeta)) 235 253 print '+------------------------------------------------' 236 254 -
inundation/pyvolution/test_least_squares.py
r2526 r2585 725 725 z = [2, 4, 4] 726 726 727 ref = fit_to_mesh(points, triangles, data_coords, z )727 ref = fit_to_mesh(points, triangles, data_coords, z, verbose=False) 728 728 729 729 #print attributes … … 943 943 #Fit surface to mesh 944 944 interp = Interpolation(points, triangles, data_points1, alpha=0.0, 945 precrop = True )945 precrop = True, verbose=False) 946 946 z = linear_function(data_points1) #Example z-values 947 947 f = interp.fit(z) #Fitted values at vertices … … 1817 1817 os.remove(point_file) 1818 1818 1819 1820 1821 def test_fit_using_fit_to_mesh(self): 1822 """Fit a surface to one set of points. Then interpolate that surface 1823 using another set of points. 1824 """ 1825 from mesh import Mesh 1826 1827 1828 #Setup mesh used to represent fitted function 1829 a = [0.0, 0.0] 1830 b = [0.0, 2.0] 1831 c = [2.0, 0.0] 1832 d = [0.0, 4.0] 1833 e = [2.0, 2.0] 1834 f = [4.0, 0.0] 1835 1836 points = [a, b, c, d, e, f] 1837 #bac, bce, ecf, dbe, daf, dae 1838 triangles = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 1839 1840 #Datapoints to fit from 1841 data_points1 = [[ 0.66666667, 0.66666667], 1842 [ 1.33333333, 1.33333333], 1843 [ 2.66666667, 0.66666667], 1844 [ 0.66666667, 2.66666667], 1845 [ 0.0, 1.0], 1846 [ 0.0, 3.0], 1847 [ 1.0, 0.0], 1848 [ 1.0, 1.0], 1849 [ 15, -17], #Outside mesh 1850 [ 1.0, 2.0], 1851 [ 1.0, 3.0], 1852 [ 2.0, 1.0], 1853 [ 3.0, 0.0], 1854 [ 3.0, 1.0]] 1855 1856 #Fit surface to mesh 1857 z = linear_function(data_points1) #Example z-values 1858 v = fit_to_mesh(points, triangles, data_points1, z, alpha=0.0, 1859 precrop=True, verbose=False) 1860 assert allclose(linear_function(points), v) 1861 1862 1819 1863 #------------------------------------------------------------- 1820 1864 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.