Changeset 8124
- Timestamp:
- Mar 3, 2011, 6:04:03 PM (14 years ago)
- Location:
- trunk/anuga_core/source/anuga
- Files:
-
- 48 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/__init__.py
r8118 r8124 249 249 msg = 'Caching was requested, but caching module'+\ 250 250 'could not be imported' 251 raise msg251 raise (msg) 252 252 253 253 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/ermapper_grids.py
r7317 r8124 176 176 # else: 177 177 # msg = 'Format %s is not yet defined by celltype_map' %data_format 178 # raise msg178 # raise Exception(msg) 179 179 180 180 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/file_function.py
r8118 r8124 215 215 # suggestion about reading hydrographs. 216 216 # This may also deal with the gist of ticket:289 217 raise 'Must be a NetCDF File'217 raise Exception('Must be a NetCDF File') 218 218 219 219 … … 271 271 if quantity_names is None or len(quantity_names) < 1: 272 272 msg = 'No quantities are specified in file_function' 273 raise Exception , msg273 raise Exception(msg) 274 274 275 275 if interpolation_points is not None: … … 289 289 % (str(missing), filename) 290 290 fid.close() 291 raise Exception , msg291 raise Exception(msg) 292 292 293 293 # Decide whether this data has a spatial dimension … … 298 298 299 299 if filename[-3:] == 'tms' and spatial is True: 300 msg = 'Files of type tms must not contain spatialinformation'300 msg = 'Files of type TMS must not contain spatial information' 301 301 raise Exception(msg) 302 302 303 303 if filename[-3:] == 'sww' and spatial is False: 304 msg = 'Files of type swwmust contain spatial information'304 msg = 'Files of type SWW must contain spatial information' 305 305 raise Exception(msg) 306 306 307 307 if filename[-3:] == 'sts' and spatial is False: 308 308 #What if mux file only contains one point 309 msg = 'Files of type stsmust contain spatial information'309 msg = 'Files of type STS must contain spatial information' 310 310 raise Exception(msg) 311 311 … … 414 414 != len(temp)-1: 415 415 msg='incorrect number of segments' 416 raise msg416 raise Exception(msg) 417 417 vertex_coordinates=ensure_numeric(temp) 418 418 if len(vertex_coordinates)==0: 419 419 msg = 'None of the sts gauges fall on the boundary' 420 raise msg420 raise Exception(msg) 421 421 else: 422 422 gauge_neighbour_id=None -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/gauge.py
r8063 r8124 156 156 except Exception, e: 157 157 msg = 'File "%s" could not be opened: Error="%s"' % (gauge_file, e) 158 raise msg158 raise Exception(msg) 159 159 160 160 if verbose: log.critical('Gauges obtained from: %s' % gauge_file) … … 193 193 else: 194 194 msg = 'File "%s" could not be opened: no read permission' % sww_file 195 raise msg195 raise Exception(msg) 196 196 197 197 sww_files = get_all_swwfiles(look_in_dir=dir_name, … … 453 453 except Exception, e: 454 454 msg = 'File "%s" could not be opened: Error="%s"' % (gauge_filename, e) 455 raise msg455 raise Exception(msg) 456 456 457 457 if report is None: … … 491 491 except Exception, e: 492 492 msg = 'File "%s" could not be opened: Error="%s"' % (swwfile, e) 493 raise msg493 raise Exception(msg) 494 494 495 495 if verbose: … … 543 543 if time_min < theminT: # min(T): 544 544 msg = 'Minimum time entered not correct - please try again' 545 raise Exception , msg545 raise Exception(msg) 546 546 547 547 if time_max is None: … … 550 550 if time_max > themaxT: # max(T): 551 551 msg = 'Maximum time entered not correct - please try again' 552 raise Exception , msg552 raise Exception(msg) 553 553 554 554 if verbose and len(gauge_index) > 0: … … 611 611 % filename 612 612 msg += 'The header must be: easting, northing, name, elevation' 613 raise Exception , msg613 raise Exception(msg) 614 614 615 615 if elev_index is None: -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py
r7573 r8124 26 26 def evaluate(self, vol_id=None, edge_id=None): 27 27 msg = 'Generic class Boundary must be subclassed' 28 raise Exception , msg28 raise Exception(msg) 29 29 30 30 … … 41 41 if domain is None: 42 42 msg = 'Domain must be specified for transmissive boundary' 43 raise Exception , msg43 raise Exception(msg) 44 44 45 45 self.domain = domain … … 73 73 if conserved_quantities is None: 74 74 msg = 'Must specify one value for each conserved quantity' 75 raise Exception , msg75 raise Exception(msg) 76 76 77 77 self.conserved_quantities=num.array(conserved_quantities, num.float) … … 116 116 117 117 if domain is None: 118 raise Exception , 'You must specify a domain to Time_boundary'118 raise Exception('You must specify a domain to Time_boundary') 119 119 120 120 # FIXME: Temporary code to deal with both f and function 121 121 if function is not None and f is not None: 122 raise Exception , 'Specify either function or f to Time_boundary'122 raise Exception('Specify either function or f to Time_boundary') 123 123 124 124 if function is None and f is None: 125 raise Exception , 'You must specify a function to Time_boundary'125 raise Exception('You must specify a function to Time_boundary') 126 126 127 127 if f is None: … … 133 133 except Exception, e: 134 134 msg = 'Function for time boundary could not be executed:\n%s' %e 135 raise msg135 raise Exception(msg) 136 136 137 137 … … 143 143 msg += 'Specified function should return either list or array.\n' 144 144 msg += 'I got %s' %str(q) 145 raise msg145 raise Exception(msg) 146 146 147 147 msg = 'ERROR: Time boundary function must return a 1d list or array ' … … 163 163 res = self.f(self.domain.time) 164 164 except Modeltime_too_early, e: 165 raise Modeltime_too_early , e165 raise Modeltime_too_early(e) 166 166 except Modeltime_too_late, e: 167 167 if self.default_boundary is None: 168 raise Exception , e# Reraise exception168 raise Exception(e) # Reraise exception 169 169 else: 170 170 # Pass control to default boundary … … 223 223 224 224 if function is None: 225 raise Exception , 'You must specify a function to Time_space_boundary'225 raise Exception('You must specify a function to Time_space_boundary') 226 226 227 227 try: … … 229 229 except Exception, e: 230 230 msg = 'Function for time_space_boundary could not be executed:\n%s' %e 231 raise msg231 raise Exception(msg) 232 232 233 233 … … 239 239 msg += 'Specified function should return either list or array.\n' 240 240 msg += 'I got %s' %str(q) 241 raise msg241 raise Exception(msg) 242 242 243 243 msg = 'ERROR: Time_space_boundary function must return a 1d list or array ' … … 262 262 res = self.function(self.domain.get_time(), x, y) 263 263 except Modeltime_too_early, e: 264 raise Modeltime_too_early , e264 raise Modeltime_too_early(e) 265 265 except Modeltime_too_late, e: 266 266 if self.default_boundary is None: 267 raise Exception , e# Reraise exception267 raise Exception(e) # Reraise exception 268 268 else: 269 269 # Pass control to default boundary … … 437 437 res = self.F(t, point_id=i) 438 438 except Modeltime_too_early, e: 439 raise Modeltime_too_early , e439 raise Modeltime_too_early(e) 440 440 except Modeltime_too_late, e: 441 441 if self.default_boundary is None: 442 raise Exception , e# Reraise exception442 raise Exception(e) # Reraise exception 443 443 else: 444 444 # Pass control to default boundary … … 486 486 msg += 'the file %s.\n' %self.F.filename 487 487 msg += 'Check this file for NANs.' 488 raise Exception , msg488 raise Exception(msg) 489 489 490 490 return res … … 492 492 msg = 'Boundary call without point_id not implemented.\n' 493 493 msg += 'vol_id=%s, edge_id=%s' %(str(vol_id), str(edge_id)) 494 raise Exception , msg494 raise Exception(msg) 495 495 496 496 class AWI_boundary(Boundary): … … 641 641 msg += 'the file %s.\n' % self.F.filename 642 642 msg += 'Check this file for NANs.' 643 raise Exception , msg643 raise Exception(msg) 644 644 645 645 q[0] = res[0] # Take stage, leave momentum alone -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8073 r8124 413 413 msg = 'Values for both vertex and edge was specified.' 414 414 msg += 'Only one (or none) is allowed.' 415 raise Exception , msg415 raise Exception(msg) 416 416 417 417 q = num.zeros(len(self.conserved_quantities), num.float) … … 452 452 msg = 'Values for both vertex and edge was specified.' 453 453 msg += 'Only one (or none) is allowed.' 454 raise Exception , msg454 raise Exception(msg) 455 455 456 456 q = num.zeros(len(self.evolved_quantities), num.float) … … 828 828 msg += 'in set_boundary.\n' 829 829 msg += 'The tags are: %s' %self.get_boundary_tags() 830 raise Exception , msg830 raise Exception(msg) 831 831 832 832 ## … … 942 942 943 943 if polygon in self.quantities: 944 raise Exception , msg944 raise Exception(msg) 945 945 946 946 try: … … 950 950 pass 951 951 else: 952 raise Exception , msg952 raise Exception(msg) 953 953 954 954 # In any case, we don't allow polygon to be a string 955 955 msg = ('argument "polygon" must not be a string: ' 956 956 'I got polygon="%s"') % polygon 957 raise Exception , msg957 raise Exception(msg) 958 958 959 959 # Get indices for centroids that are inside polygon … … 1330 1330 1331 1331 msg = '%s is an incorrect timestepping type' % timestepping_method 1332 raise Exception , msg1332 raise Exception(msg) 1333 1333 1334 1334 ## … … 1444 1444 if finaltime is not None and duration is not None: 1445 1445 msg = 'Only one of finaltime and duration may be specified' 1446 raise Exception , msg1446 raise Exception(msg) 1447 1447 else: 1448 1448 if finaltime is not None: … … 1531 1531 # Now changed to Exception. 1532 1532 msg = ('WARNING (domain.py): time overshot finaltime. ') 1533 raise Exception , msg1533 raise Exception(msg) 1534 1534 1535 1535 # Log and then Yield final time and stop … … 1808 1808 msg = 'Method conserved_values_to_evolved_values must be overridden' 1809 1809 msg += ' by Domain subclass' 1810 raise Exception , msg1810 raise Exception(msg) 1811 1811 1812 1812 return q_evol … … 1846 1846 msg = 'Boundary must return array of either conserved' 1847 1847 msg += ' or evolved quantities' 1848 raise Exception , msg1848 raise Exception(msg) 1849 1849 1850 1850 for j, name in enumerate(self.evolved_quantities): … … 1857 1857 def compute_fluxes(self): 1858 1858 msg = 'Method compute_fluxes must be overridden by Domain subclass' 1859 raise Exception , msg1859 raise Exception(msg) 1860 1860 1861 1861 … … 1936 1936 log.critical(stats) 1937 1937 1938 raise Exception , msg1938 raise Exception(msg) 1939 1939 else: 1940 1940 # Try to overcome situation by switching to 1 order … … 2033 2033 Q.extrapolate_second_order() 2034 2034 else: 2035 raise Exception , 'Unknown order'2035 raise Exception('Unknown order: %s' % str(self._order_)) 2036 2036 2037 2037 ## -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory.py
r8009 r8124 685 685 int(float(fields[2]))-1]) 686 686 else: 687 raise 'wrong format in ' + filename687 raise Excetion('wrong format in %s' % filename) 688 688 689 689 elements = [] #Final list of elements -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
r8070 r8124 262 262 if neighbourdict.has_key((a,b)): 263 263 msg = "Edge 2 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[a,b][1],neighbourdict[a,b][0]) 264 raise Exception , msg264 raise Exception(msg) 265 265 if neighbourdict.has_key((b,c)): 266 266 msg = "Edge 0 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[b,c][1],neighbourdict[b,c][0]) 267 raise msg267 raise Exception(msg) 268 268 if neighbourdict.has_key((c,a)): 269 269 msg = "Edge 1 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[c,a][1],neighbourdict[c,a][0]) 270 raise msg270 raise Exception(msg) 271 271 272 272 neighbourdict[a,b] = (i, 2) #(id, edge) … … 427 427 msg = 'Boundary dictionary must be defined before ' 428 428 msg += 'building boundary structure' 429 raise msg429 raise Exception(msg) 430 430 431 431 … … 505 505 if p0 is None: 506 506 msg = 'Impossible: p0 is None!?' 507 raise Exception , msg507 raise Exception(msg) 508 508 509 509 # Register potential paths from A to B … … 876 876 if is_outside_polygon(point, polygon): 877 877 msg = 'Point %s is outside mesh' %str(point) 878 raise Exception , msg878 raise Exception(msg) 879 879 880 880 … … 889 889 890 890 msg = 'Point %s not found within a triangle' %str(point) 891 raise Exception , msg891 raise Exception(msg) 892 892 893 893 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r8123 r8124 423 423 if indices is not None: 424 424 msg = 'Only one of polygon and indices can be specified' 425 raise Exception , msg425 raise Exception(msg) 426 426 427 427 msg = 'With polygon selected, set_quantity must provide ' … … 429 429 msg += 'a constant.' 430 430 if numeric is None: 431 raise Exception , msg431 raise Exception(msg) 432 432 else: 433 433 # Check that numeric is as constant … … 457 457 if location == 'edges': 458 458 msg = 'edges has been deprecated as valid location' 459 raise Exception , msg459 raise Exception(msg) 460 460 461 461 if location not in ['vertices', 'centroids', 'unique vertices']: 462 462 msg = 'Invalid location: %s' % location 463 raise Exception , msg463 raise Exception(msg) 464 464 465 465 msg = 'Indices must be a list, array or None' … … 488 488 msg = ("Illegal type for variable 'numeric': %s" 489 489 % type(numeric)) 490 raise Exception , msg490 raise Exception(msg) 491 491 self.set_values_from_constant(numeric, location, 492 492 indices, verbose) … … 513 513 use_cache=use_cache) 514 514 else: 515 raise Exception , "This can't happen :-)"515 raise Exception("This can't happen :-)") 516 516 517 517 # Update all locations in triangles … … 665 665 else: 666 666 msg = 'Values array must be 1d or 2d' 667 raise Exception , msg667 raise Exception(msg) 668 668 669 669 ## … … 769 769 self.vertex_values[i, j] = values[3*i + j] 770 770 else: 771 raise Exception , 'Not implemented: %s' % location771 raise Exception('Not implemented: %s' % location) 772 772 773 773 ## … … 802 802 msg = ("set_values_from_points is only defined for " 803 803 "location='vertices'") 804 raise Exception , msg804 raise Exception(msg) 805 805 806 806 # Take care of georeferencing … … 848 848 """Set quantity values from arbitray data points using fit_interpolate.fit""" 849 849 850 raise Exception , 'set_values_from_points is obsolete, use geospatial data object instead'850 raise Exception('set_values_from_points is obsolete, use geospatial data object instead') 851 851 852 852 ## … … 882 882 if location != 'vertices': 883 883 msg = "set_values_from_file is only defined for location='vertices'" 884 raise Exception , msg884 raise Exception(msg) 885 885 886 886 … … 951 951 i = num.argmin(V) 952 952 else: 953 raise ValueError , 'Bad mode value, got: %s' % str(mode)953 raise ValueError('Bad mode value, got: %s' % str(mode)) 954 954 955 955 if indices is None: … … 1190 1190 'edges', 'unique vertices']: 1191 1191 msg = 'Invalid location: %s' % location 1192 raise Exception , msg1192 raise Exception(msg) 1193 1193 1194 1194 … … 1218 1218 if len(triangles) == 0: 1219 1219 msg = 'Unique vertex not associated with triangles' 1220 raise Exception , msg1220 raise Exception(msg) 1221 1221 1222 1222 # Go through all triangle, vertex pairs … … 1381 1381 if current_node == N: 1382 1382 msg = 'Current node exceeding number of nodes (%d) ' % N 1383 raise Exception , msg1383 raise Exception(msg) 1384 1384 1385 1385 k += 1 … … 1576 1576 def __init__(self, domain, vertex_values=None): 1577 1577 msg = 'ERROR: Use Quantity instead of Conserved_quantity' 1578 raise Exception , msg1578 raise Exception(msg) 1579 1579 1580 1580 … … 1611 1611 msg += 'Make sure compile_all.py has been run as described in ' 1612 1612 msg += 'the ANUGA installation guide.' 1613 raise Exception , msg1613 raise Exception(msg) -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/region.py
r7276 r8124 20 20 def __call__(self, tag, elements, domain): 21 21 msg = 'Generic class Boundary must be subclassed' 22 raise msg22 raise Exception(msg) 23 23 24 24 … … 86 86 self.quantity_initial_value = initial_quantity 87 87 if callable(X): 88 raise 'This class does not work with functions'88 raise Exception('This class does not work with functions') 89 89 90 90 def __repr__(self): -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py
r7814 r8124 38 38 pass 39 39 else: 40 raise 'Should have raised exception'40 raise Exception('Should have raised exception') 41 41 42 42 … … 48 48 pass 49 49 else: 50 raise 'Should have raised exception'50 raise Exception('Should have raised exception') 51 51 52 52 def test_dirichlet(self): … … 95 95 pass 96 96 else: 97 raise 'Should have raised exception'97 raise Exception('Should have raised exception') 98 98 99 99 #Test time bdry, you need to provide a function … … 103 103 pass 104 104 else: 105 raise 'Should have raised exception'105 raise Exception('Should have raised exception') 106 106 107 107 … … 161 161 pass 162 162 else: 163 raise 'Should have raised exception'163 raise Exception('Should have raised exception') 164 164 165 165 #Test time bdry, you need to provide a function … … 169 169 pass 170 170 else: 171 raise 'Should have raised exception'171 raise Exception('Should have raised exception') 172 172 173 173 … … 233 233 pass 234 234 else: 235 raise 'Should have raised exception'235 raise Exception('Should have raised exception') 236 236 237 237 T = Transmissive_boundary(domain) … … 424 424 pass 425 425 else: 426 raise 'Should have raised an exception'426 raise Exception('Should have raised an exception') 427 427 428 428 os.remove(filename + '.txt') -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_neighbour_mesh.py
r7711 r8124 42 42 else: 43 43 msg = 'Should have raised exception' 44 raise msg44 raise Exception(msg) 45 45 46 46 … … 396 396 pass 397 397 else: 398 raise "triangle edge duplicates not caught"398 raise Exception("triangle edge duplicates not caught") 399 399 400 400 … … 652 652 pass 653 653 else: 654 raise 'Should have raised an exception'654 raise Exception('Should have raised an exception') 655 655 656 656 #Too few points - 1 element … … 660 660 pass 661 661 else: 662 raise 'Should have raised an exception'662 raise Exception('Should have raised an exception') 663 663 664 664 #Wrong dimension of vertices … … 668 668 pass 669 669 else: 670 raise 'Should have raised an exception'670 raise Exception('Should have raised an exception') 671 671 672 672 #Unsubscriptable coordinates object raises exception … … 676 676 pass 677 677 else: 678 raise 'Should have raised an exception'678 raise Exception('Should have raised an exception') 679 679 680 680 #FIXME: This has been commented out pending a decision … … 687 687 # pass 688 688 #else: 689 # raise 'Should have raised an exception'689 # raise Exception('Should have raised an exception') 690 690 691 691 #Specifying wrong non existing segment … … 695 695 pass 696 696 else: 697 raise 'Should have raised an exception'697 raise Exception('Should have raised an exception') 698 698 699 699 … … 1211 1211 else: 1212 1212 msg = 'Should have caught point outside polygon (Non)' 1213 raise Exception , msg1213 raise Exception(msg) 1214 1214 1215 1215 id = mesh.get_triangle_containing_point([0.5, 1.0]) … … 1268 1268 intersected_triangles = [2,3,6,7] 1269 1269 else: 1270 raise Exception , 'this test is not for parallel lines'1270 raise Exception('this test is not for parallel lines') 1271 1271 1272 1272 … … 1761 1761 assert num.allclose(x.normal, [s2,-s2]) 1762 1762 else: 1763 msg = 'Unknow segment: %s' %x.segment1764 raise Exception , msg1763 msg = 'Unknown segment: %s' %x.segment 1764 raise Exception(msg) 1765 1765 1766 1766 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r7737 r8124 75 75 pass 76 76 else: 77 raise 'Should have raised empty quantity exception'77 raise Exception('Should have raised empty quantity exception') 78 78 79 79 … … 84 84 # pass 85 85 #except: 86 # raise 'Should have raised "mising mesh object" error'86 # raise Exception('Should have raised "mising mesh object" error') 87 87 88 88 … … 286 286 pass 287 287 except: 288 raise 'should have raised Assertionerror'288 raise Exception('should have raised Assertionerror') 289 289 290 290 … … 461 461 else: 462 462 msg = 'Should have caught this' 463 raise msg463 raise Exception(msg) 464 464 465 465 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
r7814 r8124 166 166 #if t == t0: 167 167 # msg = 'Duplicate timestep found: %f, %f' %(t0, t) 168 # raise msg168 # raise Exception(msg) 169 169 t0 = t 170 170 … … 1269 1269 else: 1270 1270 msg = 'Should have raised a NameError Exception' 1271 raise msg1271 raise Exception(msg) 1272 1272 1273 1273 … … 1279 1279 else: 1280 1280 msg = 'Should have raised a AssertionError Exception' 1281 raise msg1281 raise Exception(msg) 1282 1282 1283 1283 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r7800 r8124 113 113 except NameError, e: 114 114 msg = 'Expression "%s" could not be evaluated: %s' % (expression, e) 115 raise NameError , msg115 raise NameError(msg) 116 116 except ValueError, e: 117 117 msg = 'Expression "%s" could not be evaluated: %s' % (expression, e) 118 raise ValueError , msg118 raise ValueError(msg) 119 119 120 120 … … 146 146 return s 147 147 else: 148 raise 'Illegal input to get_textual_float:', value148 raise Exception('Illegal input to get_textual_float: %s' % str(value)) 149 149 else: 150 150 return format % float(value) … … 177 177 p = list(set(quantity).difference(set(all_quantity))) 178 178 if len(p) != 0: 179 msg = 'Quantities %s do not exist - please try again' % p180 raise Exception , msg179 msg = 'Quantities %s do not exist - please try again' % p 180 raise Exception(msg) 181 181 182 182 … … 340 340 msg += 'Please use "from anuga.abstract_2d_finite_volumes.util import ' \ 341 341 'csv2timeseries_graphs"' 342 raise Exception , msg342 raise Exception(msg) 343 343 344 344 return csv2timeseries_graphs(directories_dic, … … 502 502 except ImportError: 503 503 msg='csv2timeseries_graphs needs pylab to be installed correctly' 504 raise msg504 raise Exception(msg) 505 505 #ANUGA don't need pylab to work so the system doesn't 506 506 #rely on pylab being installed -
trunk/anuga_core/source/anuga/advection/advection.py
r7737 r8124 105 105 #Q.limit() 106 106 else: 107 raise 'Unknown order'107 raise Exception('Unknown order: %s' % str(self._order_)) 108 108 #Q.interpolate_from_vertices_to_edges() 109 109 -
trunk/anuga_core/source/anuga/caching/caching.py
r7317 r8124 1049 1049 if argsfile is None: 1050 1050 msg = 'ERROR (caching): Could not open argsfile for writing: %s' %FN 1051 raise IOError , msg1051 raise IOError(msg) 1052 1052 1053 1053 mysave((args,kwargs),argsfile,compression) # Save args and kwargs to cache … … 1289 1289 msg = '****WARNING (caching.py): Could not pickle data for compression.' 1290 1290 msg += ' Try using compression = False' 1291 raise MemoryError , msg1291 raise MemoryError(msg) 1292 1292 else: 1293 1293 # Compressed pickling … … 1329 1329 # print e 1330 1330 # msg = 'Could not store to %s, bin=%s' %(file, bin) 1331 # raise msg1331 # raise Exception(msg) 1332 1332 1333 1333 … … 1566 1566 msg = 'Instance %s was passed into caching in the role of a function ' % str(my_F) 1567 1567 msg = ' but it was not callable.' 1568 raise Exception , msg1568 raise Exception(msg) 1569 1569 elif type(my_F) in [types.BuiltinFunctionType, types.BuiltinMethodType]: 1570 1570 # Built-in functions are assumed not to change … … 1576 1576 else: 1577 1577 msg = 'Unknown function type: %s' % type(my_F) 1578 raise Exception , msg1578 raise Exception(msg) 1579 1579 1580 1580 … … 1614 1614 if expanded_FN == []: 1615 1615 errmsg = 'ERROR (caching.py): Dependency '+FN+' does not exist.' 1616 raise Exception , errmsg1616 raise Exception(errmsg) 1617 1617 1618 1618 expanded_dependencies += expanded_FN … … 1623 1623 errmsg = 'ERROR (caching.py): Dependency must be a string.\n' 1624 1624 errmsg += ' Dependency given: %s' %FN 1625 raise Exception , errmsg1625 raise Exception(errmsg) 1626 1626 if not os.access(FN,os.F_OK): 1627 1627 errmsg = 'ERROR (caching.py): Dependency '+FN+' does not exist.' 1628 raise Exception , errmsg1628 raise Exception(errmsg) 1629 1629 (size,atime,mtime,ctime) = filestat(FN) 1630 1630 … … 2107 2107 if sortidx > len(rec)-1: 2108 2108 msg = 'ERROR: Sorting index too large, sortidx = %s' % str(sortidx) 2109 raise IndexError , msg2109 raise IndexError(msg) 2110 2110 2111 2111 val = rec[sortidx] -
trunk/anuga_core/source/anuga/caching/test_caching.py
r7317 r8124 724 724 fid.close() 725 725 except: 726 raise 'Statistics files cannot be opened'726 raise Exception('Statistics files cannot be opened') 727 727 728 728 -
trunk/anuga_core/source/anuga/coordinate_transforms/geo_reference.py
r7779 r8124 29 29 30 30 31 ##32 # @brief A class for ...33 31 class Geo_reference: 34 32 """ … … 46 44 """ 47 45 48 ##49 # @brief Instantiate an instance of class Geo_reference.50 # @param zone The UTM zone.51 # @param xllcorner X coord of origin of georef.52 # @param yllcorner Y coord of origin of georef.53 # @param datum ??54 # @param projection The projection used (default UTM).55 # @param units Units used in measuring distance (default m).56 # @param false_easting ??57 # @param false_northing ??58 # @param NetCDFObject NetCDF file *handle* to write to.59 # @param ASCIIFile ASCII text file *handle* to write to.60 # @param read_title Title of the georeference text.61 46 def __init__(self, 62 47 zone=DEFAULT_ZONE, … … 72 57 read_title=None): 73 58 """ 74 input: 75 NetCDFObject - a handle to the netCDF file to be written to 76 ASCIIFile - a handle to the text file 77 read_title - the title of the georeference text, if it was read in. 78 If the function that calls this has already read the title line, 79 it can't unread it, so this info has to be passed. 80 If you know of a way to unread this info, then tell us. 81 82 Note, the text file only saves a sub set of the info the 83 points file does. Currently the info not written in text 84 must be the default info, since ANUGA assumes it isn't 85 changing. 59 zone the UTM zone. 60 xllcorner X coord of origin of georef. 61 yllcorner Y coord of origin of georef. 62 datum ?? 63 projection the projection used (default UTM). 64 units units used in measuring distance (default m). 65 false_easting ?? 66 false_northing ?? 67 NetCDFObject NetCDF file *handle* to write to. 68 ASCIIFile ASCII text file *handle* to write to. 69 read_title title of the georeference text. 70 71 If the function that calls this has already read the title line, 72 it can't unread it, so this info has to be passed. 73 If you know of a way to unread this info, then tell us. 74 75 Note, the text file only saves a sub set of the info the 76 points file does. Currently the info not written in text 77 must be the default info, since ANUGA assumes it isn't 78 changing. 86 79 """ 87 80 … … 110 103 return self.xllcorner 111 104 112 ##113 # @brief Get the Y coordinate of the origin of this georef.114 105 def get_yllcorner(self): 106 """Get the Y coordinate of the origin of this georef.""" 107 115 108 return self.yllcorner 116 109 117 ##118 # @brief Get the zone of this georef.119 110 def get_zone(self): 111 """Get the zone of this georef.""" 112 120 113 return self.zone 121 114 122 ##123 # @brief Write <something> to an open NetCDF file.124 # @param outfile Handle to open NetCDF file.125 115 def write_NetCDF(self, outfile): 116 """Write georef attributes to an open NetCDF file. 117 118 outfile handle to open NetCDF file 119 """ 120 126 121 outfile.xllcorner = self.xllcorner 127 122 outfile.yllcorner = self.yllcorner … … 135 130 outfile.units = self.units 136 131 137 ##138 # @brief Read data from an open NetCDF file.139 # @param infile Handle to open NetCDF file.140 132 def read_NetCDF(self, infile): 133 """Set georef attributes from open NetCDF file. 134 135 infile Handle to open NetCDF file 136 """ 137 141 138 self.xllcorner = float(infile.xllcorner[0]) 142 139 self.yllcorner = float(infile.yllcorner[0]) … … 189 186 ################################################################################ 190 187 191 ##192 # @brief Write georef data to an open text file.193 # @param fd Handle to open text file.194 188 def write_ASCII(self, fd): 189 """Write georef attriutes to an open text file. 190 191 fd handle to open text file 192 """ 193 195 194 fd.write(TITLE) 196 195 fd.write(str(self.zone) + "\n") … … 198 197 fd.write(str(self.yllcorner) + "\n") 199 198 200 ##201 # @brief Read georef data from an open text file.202 # @param fd Handle to open text file.203 199 def read_ASCII(self, fd, read_title=None): 200 """Set georef attribtes from open text file. 201 202 fd handle to open text file 203 """ 204 204 205 try: 205 206 if read_title == None: … … 232 233 ################################################################################ 233 234 234 ##235 # @brief Change points to be absolute wrt new georef 'points_geo_ref'.236 # @param points The points to change.237 # @param points_geo_ref The new georef to make points absolute wrt.238 # @return The changed points.239 # @note If 'points' is a list then a changed list is returned.240 235 def change_points_geo_ref(self, points, points_geo_ref=None): 241 """Change the geo reference of a list or numeric array of points to 242 be this reference.(The reference used for this object) 243 If the points do not have a geo ref, assume 'absolute' values 244 """ 236 """Change points to be absolute wrt new georef 'points_geo_ref'. 237 238 points the points to change 239 points_geo_ref the new georef to make points absolute wrt 240 241 Returns the changed points data. 242 If the points do not have a georef, assume 'absolute' values. 243 """ 244 245 245 import copy 246 246 … … 285 285 286 286 def is_absolute(self): 287 """Return True if xllcorner==yllcorner==0 indicating that points 288 in question are absolute. 287 """Test if points in georef are absolute. 288 289 Return True if xllcorner==yllcorner==0 indicating that points in 290 question are absolute. 289 291 """ 290 292 … … 305 307 306 308 def get_absolute(self, points): 307 """Given a set of points geo referenced to this instance, 308 return thepoints as absolute values.309 """Given a set of points geo referenced to this instance, return the 310 points as absolute values. 309 311 """ 310 312 … … 338 340 return points 339 341 340 ##341 # @brief Convert points to relative measurement.342 # @param points Points to convert to relative measurements.343 # @return A set of points relative to the geo_reference instance.344 342 def get_relative(self, points): 345 """Given a set of points in absolute UTM coordinates, 346 make them relative to this geo_reference instance, 347 return the points as relative values. 348 349 This is the inverse of get_absolute. 343 """Convert points to relative measurement. 344 345 points Points to convert to relative measurements 346 347 Returns a set of points relative to the geo_reference instance. 348 349 This is the inverse of get_absolute(). 350 350 """ 351 351 … … 376 376 return points 377 377 378 ##379 # @brief ??380 # @param other ??381 378 def reconcile_zones(self, other): 382 379 if other is None: … … 402 399 # return [x-self.xllcorner, y - self.xllcorner] 403 400 404 ##405 # @brief Get origin of this geo_reference.406 # @return (zone, xllcorner, yllcorner).407 401 def get_origin(self): 402 """Get origin of this geo_reference.""" 403 408 404 return (self.zone, self.xllcorner, self.yllcorner) 409 405 410 ##411 # @brief Get a string representation of this geo_reference instance.412 406 def __repr__(self): 413 407 return ('(zone=%i easting=%f, northing=%f)' 414 408 % (self.zone, self.xllcorner, self.yllcorner)) 415 409 416 ##417 # @brief Compare two geo_reference instances.418 # @param self This geo_reference instance.419 # @param other Another geo_reference instance to compare against.420 # @return 0 if instances have the same attributes, else 1.421 # @note Attributes are: zone, xllcorner, yllcorner.422 410 def __cmp__(self, other): 411 """Compare two geo_reference instances. 412 413 self this geo_reference instance 414 other another geo_reference instance to compare against 415 416 Returns 0 if instances have the same attributes, else returns 1. 417 418 Note: attributes are: zone, xllcorner, yllcorner. 419 """ 420 423 421 # FIXME (DSG) add a tolerence 424 422 if other is None: … … 434 432 435 433 436 ##437 # @brief Write a geo_reference to a NetCDF file (usually SWW).438 # @param origin A georef instance or parameters to create a georef instance.439 # @param outfile Path to file to write.440 # @return A normalized geo_reference.441 434 def write_NetCDF_georeference(origin, outfile): 442 """Write georeference info to a netcdf file, usually sww. 443 444 The origin can be a georef instance or parameters for a geo_ref instance 445 446 outfile is the name of the file to be written to. 435 """Write georeference info to a NetCDF file, usually a SWW file. 436 437 origin a georef instance or parameters to create a georef instance 438 outfile path to file to write 439 440 Returns the normalised georef. 447 441 """ 448 442 … … 452 446 453 447 454 ##455 # @brief Convert an object to a georeference instance.456 # @param origin A georef instance or (zone, xllcorner, yllcorner)457 # @return A georef object, or None if 'origin' was None.458 448 def ensure_geo_reference(origin): 459 """ 460 Given a list/tuple of zone, xllcorner and yllcorner of a geo-ref object, 461 return a geo ref object.462 463 If theorigin is None, return None, so calling this function doesn't464 effect code logic 449 """Create a georef object from a tuple of attributes. 450 451 origin a georef instance or (zone, xllcorner, yllcorner) 452 453 If origin is None, return None, so calling this function doesn't 454 effect code logic. 465 455 """ 466 456 -
trunk/anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py
r7317 r8124 473 473 else: 474 474 msg = 'Should have raised an exception' 475 raise msg475 raise Exception(msg) 476 476 477 477 def test_bad_ASCII_title(self): -
trunk/anuga_core/source/anuga/culvert_flows/culvert_class.py
r7735 r8124 32 32 x = float(x) 33 33 except: 34 raise Exception , msg34 raise Exception(msg) 35 35 36 36 … … 39 39 msg = 'Value provided = %.2f, interpolation minimum = %.2f.'\ 40 40 % (x, xvec[0]) 41 raise Below_interval , msg41 raise Below_interval(msg) 42 42 43 43 if x > xvec[-1]: 44 44 msg = 'Value provided = %.2f, interpolation maximum = %.2f.'\ 45 45 %(x, xvec[-1]) 46 raise Above_interval , msg46 raise Above_interval(msg) 47 47 48 48 … … 400 400 else: 401 401 msg = 'Triangle not found for point (%f, %f)' %point 402 raise Exception , msg402 raise Exception(msg) 403 403 404 404 return enquiry_indices … … 922 922 else: 923 923 msg = 'Triangle not found for point (%f, %f)' %point 924 raise Exception , msg924 raise Exception(msg) 925 925 926 926 … … 1206 1206 msg = 'Either diameter or width&height must be specified, ' 1207 1207 msg += 'but not both.' 1208 raise Exception , msg1208 raise Exception(msg) 1209 1209 else: 1210 1210 if height is not None: … … 1220 1220 else: 1221 1221 msg = 'Either diameter or width&height must be specified.' 1222 raise Exception , msg1222 raise Exception(msg) 1223 1223 1224 1224 if height == width: … … 1321 1321 else: 1322 1322 msg = 'Triangle not found for point (%f, %f)' %point 1323 raise Exception , msg1323 raise Exception(msg) 1324 1324 1325 1325 … … 1460 1460 # This is possible since w and z are taken at different locations 1461 1461 #msg = 'D < 0.0: %f' %d 1462 #raise msg1462 #raise Exception(msg) 1463 1463 d = 0.0 1464 1464 -
trunk/anuga_core/source/anuga/culvert_flows/new_culvert_class.py
r7735 r8124 32 32 x = float(x) 33 33 except: 34 raise Exception , msg34 raise Exception(msg) 35 35 36 36 … … 39 39 msg = 'Value provided = %.2f, interpolation minimum = %.2f.'\ 40 40 % (x, xvec[0]) 41 raise Below_interval , msg41 raise Below_interval(msg) 42 42 43 43 if x > xvec[-1]: 44 44 msg = 'Value provided = %.2f, interpolation maximum = %.2f.'\ 45 45 %(x, xvec[-1]) 46 raise Above_interval , msg46 raise Above_interval(msg) 47 47 48 48 … … 403 403 else: 404 404 msg = 'Triangle not found for point (%f, %f)' %point 405 raise Exception , msg405 raise Exception(msg) 406 406 407 407 return enquiry_indices … … 925 925 else: 926 926 msg = 'Triangle not found for point (%f, %f)' %point 927 raise Exception , msg927 raise Exception(msg) 928 928 929 929 … … 1209 1209 msg = 'Either diameter or width&height must be specified, ' 1210 1210 msg += 'but not both.' 1211 raise Exception , msg1211 raise Exception(msg) 1212 1212 else: 1213 1213 if height is not None: … … 1223 1223 else: 1224 1224 msg = 'Either diameter or width&height must be specified.' 1225 raise Exception , msg1225 raise Exception(msg) 1226 1226 1227 1227 if height == width: … … 1324 1324 else: 1325 1325 msg = 'Triangle not found for point (%f, %f)' %point 1326 raise Exception , msg1326 raise Exception(msg) 1327 1327 1328 1328 … … 1463 1463 # This is possible since w and z are taken at different locations 1464 1464 #msg = 'D < 0.0: %f' %d 1465 #raise msg1465 #raise Exception(msg) 1466 1466 d = 0.0 1467 1467 -
trunk/anuga_core/source/anuga/file/urs.py
r7766 r8124 40 40 if self.points_num < 0: 41 41 mux_file.close() 42 raise ANUGAError , msg42 raise ANUGAError(msg) 43 43 if self.time_step_count < 0: 44 44 mux_file.close() 45 raise ANUGAError , msg45 raise ANUGAError(msg) 46 46 if self.time_step < 0: 47 47 mux_file.close() 48 raise ANUGAError , msg48 raise ANUGAError(msg) 49 49 50 50 # The depth is in meters, and it is the distance from the ocean … … 209 209 msg = 'Caching was requested, but caching module' \ 210 210 'could not be imported' 211 raise msg211 raise Exception(msg) 212 212 213 213 geo = cache(_calculate_boundary_points, … … 267 267 if lat_long_set == frozenset([]): 268 268 msg = "URS region specified and polygon does not overlap." 269 raise ValueError , msg269 raise ValueError(msg) 270 270 271 271 # Warning there is no info in geospatial saying the hemisphere of -
trunk/anuga_core/source/anuga/file_conversion/test_file_conversion.py
r7780 r8124 1211 1211 os.remove(elevation_dir_filename2) 1212 1212 os.rmdir(elevation_dir) 1213 raise 'Should raise exception'1213 raise Exception('Should raise exception') 1214 1214 1215 1215 os.remove(ucur_dir_filename1) … … 1914 1914 self.delete_mux(files) 1915 1915 msg = 'Should have raised exception' 1916 raise msg1916 raise Exception(msg) 1917 1917 sww_file = base_name + '.sww' 1918 1918 self.delete_mux(files) … … 1927 1927 self.delete_mux(files) 1928 1928 msg = 'Should have raised exception' 1929 raise msg1929 raise Exception(msg) 1930 1930 1931 1931 def test_urs2sww(self): … … 2393 2393 else: 2394 2394 msg = 'Should have raised exception' 2395 raise msg2395 raise Exception(msg) 2396 2396 2397 2397 def test_lon_lat2gridII(self): … … 2407 2407 else: 2408 2408 msg = 'Should have raised exception' 2409 raise msg2409 raise Exception(msg) 2410 2410 2411 2411 -
trunk/anuga_core/source/anuga/file_conversion/urs2sww.py
r7858 r8124 155 155 mux[quantity].close() 156 156 msg = "Due to mint and maxt there's no time info in the boundary SWW." 157 raise Exception , msg157 raise Exception(msg) 158 158 159 159 # If this raise is removed there is currently no downstream errors -
trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py
r7854 r8124 800 800 # This message is time consuming to form due to the conversion of 801 801 msg = 'Time must be a monotonuosly increasing sequence %s' % time 802 raise Exception , msg802 raise Exception(msg) 803 803 804 804 # Check if quantities is a single array only … … 859 859 #no longer true. sts files have spatial = True but 860 860 #if self.spatial is False: 861 # raise 'Triangles and vertex_coordinates must be specified'861 # raise Exception('Triangles and vertex_coordinates must be specified') 862 862 # 863 863 try: … … 868 868 'or a list of points\n' 869 869 msg += 'Got: %s.' %(str(self.interpolation_points)[:60] + '...') 870 raise msg870 raise Exception(msg) 871 871 872 872 # Ensure 'mesh_boundary_polygon' is defined … … 1103 1103 if x is not None and y is not None: 1104 1104 # Interpolate to x, y 1105 raise 'x,y interpolation not yet implemented'1105 raise Exception('x,y interpolation not yet implemented') 1106 1106 else: 1107 1107 # Use precomputed point -
trunk/anuga_core/source/anuga/fit_interpolate/test_fit.py
r7778 r8124 976 976 else: 977 977 #self.failUnless(0 ==1, 'Bad file did not raise error!') 978 raise 'Bad file did not raise error!'978 raise Exception('Bad file did not raise error!') 979 979 980 980 #clean up … … 1009 1009 pass 1010 1010 else: 1011 raise 'Bad file did not raise error!'1011 raise Exception('Bad file did not raise error!') 1012 1012 1013 1013 #clean up … … 1052 1052 pass 1053 1053 else: 1054 raise 'Bad file did not raise error!'1054 raise Exception('Bad file did not raise error!') 1055 1055 1056 1056 #clean up … … 1086 1086 pass 1087 1087 else: 1088 raise 'Verts with no triangles did not raise error!'1088 raise Exception('Verts with no triangles did not raise error!') 1089 1089 1090 1090 #f = interp.fit(data_coords, z) -
trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r7796 r8124 1170 1170 pass 1171 1171 else: 1172 raise 'Should raise exception'1172 raise Exception('Should raise exception') 1173 1173 1174 1174 try: … … 1177 1177 pass 1178 1178 else: 1179 raise 'Should raise exception'1179 raise Exception('Should raise exception') 1180 1180 1181 1181 … … 1235 1235 pass 1236 1236 else: 1237 raise 'Should raise exception'1237 raise Exception('Should raise exception') 1238 1238 1239 1239 … … 1294 1294 pass 1295 1295 else: 1296 raise 'Should raise exception'1296 raise Exception('Should raise exception') 1297 1297 1298 1298 … … 1504 1504 pass 1505 1505 else: 1506 raise 'Should raise exception'1506 raise Exception('Should raise exception') 1507 1507 1508 1508 … … 1667 1667 pass 1668 1668 else: 1669 raise 'Should raise exception due to time being non-monotoneous'1669 raise Exception('Should raise exception due to time being non-monotoneous') 1670 1670 1671 1671 -
trunk/anuga_core/source/anuga/fit_interpolate/test_search_functions.py
r8120 r8124 31 31 compile(FN) 32 32 except: 33 raise 'Could not compile %s' %FN33 raise Exception('Could not compile %s' % FN) 34 34 else: 35 35 import search_functions_ext -
trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py
r7780 r8124 216 216 self.data_points = None 217 217 msg = 'There is no data or file provided!' 218 raise ValueError , msg218 raise ValueError(msg) 219 219 else: 220 220 self.data_points = ensure_numeric(data_points) … … 245 245 msg = ("Attribute '%s' (%s) could not be converted to a" 246 246 "numeric vector" % (str(key), str(attributes[key]))) 247 raise Exception , msg247 raise Exception(msg) 248 248 249 249 self.attributes = attributes … … 272 272 msg = ('Argument geo_reference must be a valid Geo_reference ' 273 273 'object or None.') 274 raise Expection , msg274 raise Expection(msg) 275 275 276 276 # If a geo_reference already exists, change the point data according to … … 296 296 else: 297 297 msg = 'Illegal value: %s' % str(verbose) 298 raise Exception , msg298 raise Exception(msg) 299 299 300 300 ## … … 494 494 msg = ('Geospatial data must have the same ' 495 495 'attributes to allow addition.') 496 raise Exception , msg496 raise Exception(msg) 497 497 498 498 new_attributes = None … … 508 508 msg = ('Geospatial data must have the same ' 509 509 'attributes to allow addition.') 510 raise Exception , msg510 raise Exception(msg) 511 511 else: 512 512 # other is None: … … 549 549 if access(file_name, F_OK) == 0 : 550 550 msg = 'File %s does not exist or is not accessible' % file_name 551 raise IOError , msg551 raise IOError(msg) 552 552 553 553 attributes = {} … … 558 558 except IOError, e: 559 559 msg = 'Could not open file %s ' % file_name 560 raise IOError , msg560 raise IOError(msg) 561 561 elif file_name[-4:] == ".txt" or file_name[-4:]== ".csv": 562 562 try: … … 567 567 msg = ('Could not open file %s. Check the file location.' 568 568 % file_name) 569 raise IOError , msg569 raise IOError(msg) 570 570 except SyntaxError, e: 571 571 # This should only be if there is a format error 572 572 msg = ('Problem with format of file %s.\n%s' 573 573 % (file_name, Error_message['IOError'])) 574 raise SyntaxError , msg574 raise SyntaxError(msg) 575 575 else: 576 576 msg = 'Extension %s is unknown' % file_name[-4:] 577 raise IOError , msg577 raise IOError(msg) 578 578 579 579 self.data_points = data_points … … 636 636 else: 637 637 msg = 'Unknown file type %s ' %file_name 638 raise IOError , msg638 raise IOError(msg) 639 639 640 640 ## … … 878 878 msg = ('Geo reference given, then not given.' 879 879 ' This should not happen.') 880 raise ValueError , msg880 raise ValueError(msg) 881 881 geo = Geospatial_data(pointlist, att_dict, geo_ref) 882 882 except StopIteration: … … 897 897 msg = ('Could not open file %s.\n%s' 898 898 % (self.file_name, Error_message['IOError'])) 899 raise SyntaxError , msg899 raise SyntaxError(msg) 900 900 return geo 901 901 … … 934 934 msg = ('A georeference is specified yet latitude and longitude ' 935 935 'are also specified!') 936 raise ValueError , msg936 raise ValueError(msg) 937 937 938 938 if data_points is not None and not points_are_lats_longs: 939 939 msg = ('Data points are specified yet latitude and longitude are ' 940 940 'also specified.') 941 raise ValueError , msg941 raise ValueError(msg) 942 942 943 943 if points_are_lats_longs: 944 944 if data_points is None: 945 945 msg = "Data points are not specified." 946 raise ValueError , msg946 raise ValueError(msg) 947 947 lats_longs = ensure_numeric(data_points) 948 948 latitudes = num.ravel(lats_longs[:,0:1]) … … 951 951 if latitudes is None and longitudes is None: 952 952 msg = "Latitudes and Longitudes are not specified." 953 raise ValueError , msg953 raise ValueError(msg) 954 954 955 955 if latitudes is None: 956 956 msg = "Longitudes are specified yet latitudes aren't." 957 raise ValueError , msg957 raise ValueError(msg) 958 958 959 959 if longitudes is None: 960 960 msg = "Latitudes are specified yet longitudes aren't." 961 raise ValueError , msg961 raise ValueError(msg) 962 962 963 963 data_points, zone = convert_from_latlon_to_utm(latitudes=latitudes, … … 999 999 fid.close() 1000 1000 msg = "Expected keyword 'points' but could not find it" 1001 raise IOError , msg1001 raise IOError(msg) 1002 1002 1003 1003 attributes = {} … … 1123 1123 msg = ('File load error. ' 1124 1124 'There might be a problem with the file header.') 1125 raise SyntaxError , msg1125 raise SyntaxError(msg) 1126 1126 for i,n in enumerate(numbers): 1127 1127 n.strip() … … 1175 1175 fid.close() 1176 1176 msg = "Expected keyword 'points' but could not find it." 1177 raise IOError , msg1177 raise IOError(msg) 1178 1178 1179 1179 if verbose: log.critical('Got %d variables: %s' % (len(keys), keys)) … … 1577 1577 if no_boundary is True: 1578 1578 msg = 'All boundaries must be defined' 1579 raise Expection , msg1579 raise Expection(msg) 1580 1580 1581 1581 poly_topo = [[east_boundary, south_boundary], … … 1598 1598 if access(mesh_file,F_OK) == 0: 1599 1599 msg = "file %s doesn't exist!" % mesh_file 1600 raise IOError , msg1600 raise IOError(msg) 1601 1601 1602 1602 # split topo data … … 1786 1786 if no_boundary is True: 1787 1787 msg = 'All boundaries must be defined' 1788 raise Expection , msg1788 raise Expection(msg) 1789 1789 1790 1790 poly_topo = [[east_boundary, south_boundary], … … 1806 1806 if access(mesh_file,F_OK) == 0: 1807 1807 msg = "file %s doesn't exist!" % mesh_file 1808 raise IOError , msg1808 raise IOError(msg) 1809 1809 1810 1810 # split topo data -
trunk/anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r7779 r8124 118 118 pass 119 119 else: 120 raise Exception , 'Should have raised exception'120 raise Exception('Should have raised exception') 121 121 122 122 def test_get_data_points(self): … … 731 731 else: 732 732 msg = 'Different zones in Geo references not caught.' 733 raise Exception , msg733 raise Exception(msg) 734 734 735 735 os.remove(fileName) … … 795 795 else: 796 796 msg = 'Bad file did not raise error!' 797 raise Exception , msg797 raise Exception(msg) 798 798 os.remove(fileName) 799 799 … … 824 824 else: 825 825 msg = 'Bad file did not raise error!' 826 raise Exception , msg826 raise Exception(msg) 827 827 os.remove(fileName) 828 828 … … 847 847 else: 848 848 msg = 'Bad file did not raise error!' 849 raise Exception , msg849 raise Exception(msg) 850 850 os.remove(fileName) 851 851 … … 876 876 else: 877 877 msg = 'Bad file did not raise error!' 878 raise Exception , msg878 raise Exception(msg) 879 879 os.remove(fileName) 880 880 … … 1197 1197 else: 1198 1198 msg = 'imaginary file did not raise error!' 1199 raise Exception , msg1199 raise Exception(msg) 1200 1200 1201 1201 def test_create_from_pts_file(self): … … 1451 1451 else: 1452 1452 msg = 'Instance must have a filename or data points' 1453 raise Exception , msg1453 raise Exception(msg) 1454 1454 1455 1455 def test_load_csv_lat_long(self): … … 1507 1507 else: 1508 1508 msg = 'Different zones in Geo references not caught.' 1509 raise Exception , msg1509 raise Exception(msg) 1510 1510 1511 1511 os.remove(fileName) -
trunk/anuga_core/source/anuga/get_version.py
r1806 r8124 38 38 msg = 'Command %s could not execute.' 39 39 msg += 'Make sure the program SubWCRev.exe is available on your path' 40 raise msg40 raise Exception(msg) 41 41 42 42 -
trunk/anuga_core/source/anuga/mesh_engine/mesh_engine.py
r7779 r8124 49 49 except ValueError: 50 50 msg = 'ERROR: Inconsistent points array.' 51 raise ANUGAError , msg51 raise ANUGAError(msg) 52 52 if points.shape[1] <>2: 53 53 msg = 'ERROR: Bad shape points array.' 54 raise ANUGAError , msg54 raise ANUGAError(msg) 55 55 56 56 # This is after points is numeric … … 64 64 except ValueError: 65 65 msg = 'ERROR: Inconsistent segments array.' 66 raise ANUGAError , msg66 raise ANUGAError(msg) 67 67 68 68 # This is after segments is numeric … … 74 74 except ValueError: 75 75 msg = 'ERROR: Inconsistent holess array.' 76 raise ANUGAError , msg76 raise ANUGAError(msg) 77 77 78 78 … … 82 82 except (ValueError, TypeError): 83 83 msg = 'ERROR: Inconsistent regions array.' 84 raise ANUGAError , msg84 raise ANUGAError(msg) 85 85 86 86 if not regions.shape[0] == 0 and regions.shape[1] <= 2: 87 87 msg = 'ERROR: Bad shape points array.' 88 raise ANUGAError , msg88 raise ANUGAError(msg) 89 89 90 90 try: … … 92 92 except (ValueError, TypeError): 93 93 msg = 'ERROR: Inconsistent point attributes array.' 94 raise ANUGAError , msg94 raise ANUGAError(msg) 95 95 96 96 if pointatts.shape[0] <> points.shape[0]: 97 97 msg = """ERROR: Point attributes array not the same shape as 98 98 point array.""" 99 raise ANUGAError , msg99 raise ANUGAError(msg) 100 100 if len(pointatts.shape) == 1: 101 101 pointatts = num.reshape(pointatts,(pointatts.shape[0],1)) … … 105 105 except ValueError: 106 106 msg = 'ERROR: Inconsistent point attributes array.' 107 raise ANUGAError , msg107 raise ANUGAError(msg) 108 108 if segatts.shape[0] <> segments.shape[0]: 109 109 msg = """ERROR: Segment attributes array not the same shape as 110 110 segment array.""" 111 raise ANUGAError , msg111 raise ANUGAError(msg) 112 112 113 113 if mode.find('n'): … … 186 186 #len(region) <= 2: 187 187 #msg = 'ERROR: Inconsistent regions array.' 188 #raise msg188 #raise Exception(msg) 189 189 #elif 190 190 return regions -
trunk/anuga_core/source/anuga/pmesh/Pmw.py
r3491 r8124 43 43 def setversion(version): 44 44 if version != _VERSION: 45 raise ValueError , 'Dynamic versioning not available'45 raise ValueError('Dynamic versioning not available') 46 46 47 47 def setalphaversions(*alpha_versions): 48 48 if alpha_versions != (): 49 raise ValueError , 'Dynamic versioning not available'49 raise ValueError('Dynamic versioning not available') 50 50 51 51 def version(alpha = 0): … … 258 258 # It's not a valid type 259 259 else: 260 raise TypeError , 'toPart must be attribute name, function or method'260 raise TypeError('toPart must be attribute name, function or method') 261 261 262 262 # get the full set of candidate methods … … 524 524 525 525 if self.__componentInfo.has_key(componentName): 526 raise ValueError , 'Component "%s" already exists' % componentName526 raise ValueError('Component "%s" already exists' % componentName) 527 527 528 528 if '_' in componentName: 529 raise ValueError , \530 'Component name "%s" must not contain "_"' % componentName529 raise ValueError('Component name "%s" must not contain "_"' 530 % componentName) 531 531 532 532 if hasattr(self, '_constructorKeywords'): … … 654 654 else: 655 655 text = 'Unknown options "' 656 raise KeyError , text + string.join(unusedOptions, ', ') + \657 '" for ' + self.__class__.__name__ 656 raise KeyError(text + string.join(unusedOptions, ', ') 657 + '" for ' + self.__class__.__name__) 658 658 659 659 # Call the configuration callback function for every option. … … 733 733 # Make sure it is not an initialisation option. 734 734 if optionInfo[option][FUNCTION] is INITOPT: 735 raise KeyError , \736 'Cannot configure initialisation option "' \ 737 + option + '" for ' + self.__class__.__name__ 735 raise KeyError('Cannot configure initialisation option "' 736 + option + '" for ' 737 + self.__class__.__name__) 738 738 optionInfo[option][VALUE] = value 739 739 directOptions.append(option) … … 768 768 if len(componentConfigFuncs) == 0 and \ 769 769 component not in self._dynamicGroups: 770 raise KeyError , 'Unknown option "' + option + \771 '" for ' + self.__class__.__name__ 770 raise KeyError('Unknown option "' + option + '" for ' 771 + self.__class__.__name__) 772 772 773 773 # Add the configure method(s) (may be more than … … 780 780 = value 781 781 else: 782 raise KeyError , 'Unknown option "' + option + \783 '" for ' + self.__class__.__name__ 782 raise KeyError('Unknown option "' + option + '" for ' 783 + self.__class__.__name__) 784 784 785 785 # Call the configure methods for any components. … … 874 874 return componentCget(componentOption) 875 875 876 raise KeyError , 'Unknown option "' + option + \877 '" for ' + self.__class__.__name__ 876 raise KeyError('Unknown option "' + option + '" for ' 877 + self.__class__.__name__) 878 878 879 879 __getitem__ = cget … … 1167 1167 def activate(self, globalMode = 0, geometry = 'centerscreenfirst'): 1168 1168 if self._active: 1169 raise ValueError , 'Window is already active'1169 raise ValueError('Window is already active') 1170 1170 if self.state() == 'normal': 1171 1171 self.withdraw() … … 1408 1408 _toplevelBusyInfo[window]['busyCursorName'] = value 1409 1409 else: 1410 raise KeyError , 'Unknown busycursor attribute "' + name + '"'1410 raise KeyError('Unknown busycursor attribute "' + name + '"') 1411 1411 1412 1412 def _addRootToToplevelBusyInfo(): … … 1423 1423 def busycallback(command, updateFunction = None): 1424 1424 if not callable(command): 1425 raise ValueError, \ 1426 'cannot register non-command busy callback %s %s' % \ 1427 (repr(command), type(command)) 1425 raise ValueError('cannot register non-command busy callback %s %s' 1426 % (repr(command), type(command))) 1428 1427 wrapper = _BusyWrapper(command, updateFunction) 1429 1428 return wrapper.callback … … 1593 1592 _traceTkFile.write('CALL TK> stack:\n') 1594 1593 traceback.print_stack() 1595 raise Tkinter.TclError , errorString1594 raise Tkinter.TclError(errorString) 1596 1595 1597 1596 _recursionCounter = _recursionCounter - 1 … … 1812 1811 return apply(self.func, args) 1813 1812 except SystemExit, msg: 1814 raise SystemExit , msg1813 raise SystemExit(msg) 1815 1814 except: 1816 1815 _reporterror(self.func, args) … … 2044 2043 pos = self['buttonboxpos'] 2045 2044 if pos not in 'nsew': 2046 raise ValueError, \ 2047 'bad buttonboxpos option "%s": should be n, s, e, or w' \ 2048 % pos 2045 raise ValueError('bad buttonboxpos option "%s": should be n, s, e, or w' 2046 % pos) 2049 2047 2050 2048 if pos in 'ns': … … 2141 2139 buttons = self['buttons'] 2142 2140 if type(buttons) != types.TupleType and type(buttons) != types.ListType: 2143 raise ValueError , \2144 'bad buttons option "%s": should be a tuple' % str(buttons)2141 raise ValueError('bad buttons option "%s": should be a tuple' 2142 % str(buttons)) 2145 2143 if self.oldButtons == buttons: 2146 2144 return … … 2195 2193 inputList = string.split(string.strip(text), separator) 2196 2194 if len(inputList) != 3: 2197 raise ValueError , 'invalid value: ' + text2195 raise ValueError('invalid value: ' + text) 2198 2196 2199 2197 sign = 1 … … 2204 2202 2205 2203 if re.search('[^0-9]', string.join(inputList, '')) is not None: 2206 raise ValueError , 'invalid value: ' + text2204 raise ValueError('invalid value: ' + text) 2207 2205 2208 2206 hour = string.atoi(inputList[0]) … … 2211 2209 2212 2210 if minute >= 60 or second >= 60: 2213 raise ValueError , 'invalid value: ' + text2211 raise ValueError('invalid value: ' + text) 2214 2212 return sign * (hour * 60 * 60 + minute * 60 + second) 2215 2213 … … 2229 2227 inputList = string.split(string.strip(text), separator) 2230 2228 if len(inputList) != 3: 2231 raise ValueError , 'invalid value: ' + text2229 raise ValueError('invalid value: ' + text) 2232 2230 2233 2231 if re.search('[^0-9]', string.join(inputList, '')) is not None: 2234 raise ValueError , 'invalid value: ' + text2232 raise ValueError('invalid value: ' + text) 2235 2233 formatList = list(format) 2236 2234 day = string.atoi(inputList[formatList.index('d')]) … … 2247 2245 jdn = ymdtojdn(year, month, day) 2248 2246 if jdntoymd(jdn) != (year, month, day): 2249 raise ValueError , 'invalid value: ' + text2247 raise ValueError('invalid value: ' + text) 2250 2248 return jdn 2251 2249 … … 2328 2326 if separator != '.': 2329 2327 if string.find(text, '.') >= 0: 2330 raise ValueError , 'invalid value: ' + text2328 raise ValueError('invalid value: ' + text) 2331 2329 index = string.find(text, separator) 2332 2330 if index >= 0: … … 2546 2544 def _state(self): 2547 2545 if self['state'] not in ('both', 'balloon', 'status', 'none'): 2548 raise ValueError , 'bad state option ' + repr(self['state']) + \2549 ': should be one of \'both\', \'balloon\', ' + \ 2550 '\'status\' or \'none\'' 2546 raise ValueError('bad state option ' + repr(self['state']) 2547 + ": should be one of 'both', 'balloon', " 2548 + "'status' or 'none'") 2551 2549 2552 2550 def _relmouse(self): 2553 2551 if self['relmouse'] not in ('both', 'x', 'y', 'none'): 2554 raise ValueError , 'bad relmouse option ' + repr(self['relmouse'])+ \2555 ': should be one of \'both\', \'x\', ' + '\'y\' or \'none\'' 2552 raise ValueError("bad relmouse option %s: should be one of 'both', 'x', " 2553 "'y' or 'none'" % repr(self['relmouse'])) 2556 2554 2557 2555 def _enter(self, event, widget, statusHelp, balloonHelp, isItem): … … 2747 2745 interior.grid_rowconfigure(columnOrRow, weight = 1) 2748 2746 else: 2749 raise ValueError , 'bad orient option ' + repr(orient) + \2750 ': must be either \'horizontal\' or \'vertical\'' 2747 raise ValueError("bad orient option %s: must be either 'horizontal' or " 2748 "'vertical'" % repr(orient)) 2751 2749 2752 2750 # Initialise instance variables. … … 2782 2780 return index 2783 2781 else: 2784 raise ValueError , 'index "%s" is out of range' % index2782 raise ValueError('index "%s" is out of range' % index) 2785 2783 elif index is END: 2786 2784 if forInsert: … … 2789 2787 return listLength - 1 2790 2788 else: 2791 raise ValueError , 'ButtonBox has no buttons'2789 raise ValueError('ButtonBox has no buttons') 2792 2790 elif index is DEFAULT: 2793 2791 if self._defaultButton is not None: 2794 2792 return self._defaultButton 2795 raise ValueError , 'ButtonBox has no default'2793 raise ValueError('ButtonBox has no default') 2796 2794 else: 2797 2795 names = map(lambda t: t[0], self._buttonList) … … 2799 2797 return names.index(index) 2800 2798 validValues = 'a name, a number, END or DEFAULT' 2801 raise ValueError, \ 2802 'bad index "%s": must be %s' % (index, validValues) 2799 raise ValueError('bad index "%s": must be %s' % (index, validValues)) 2803 2800 2804 2801 def insert(self, componentName, beforeComponent = 0, **kw): 2805 2802 if componentName in self.components(): 2806 raise ValueError , 'button "%s" already exists' % componentName2803 raise ValueError('button "%s" already exists' % componentName) 2807 2804 if not kw.has_key('text'): 2808 2805 kw['text'] = componentName … … 3112 3109 msg = 'bad %s value "%s": must be a function or one of ' \ 3113 3110 'the standard validators %s or extra validators %s' 3114 raise ValueError , msg % (option, validator, standard, extra)3111 raise ValueError(msg % (option, validator, standard, extra)) 3115 3112 3116 3113 def _executeCommand(self, event = None): … … 3638 3635 3639 3636 if (menuName) in self.components(): 3640 raise ValueError , 'menu "%s" already exists' % menuName3637 raise ValueError('menu "%s" already exists' % menuName) 3641 3638 3642 3639 menukw = {} … … 3697 3694 command = menu.add_cascade 3698 3695 else: 3699 raise ValueError , 'unknown menuitem type "%s"' % itemType3696 raise ValueError('unknown menuitem type "%s"' % itemType) 3700 3697 3701 3698 self._menuInfo[menuName][1].append(statusHelp) … … 3875 3872 3876 3873 if (menuName + '-menu') in self.components(): 3877 raise ValueError , 'menu "%s" already exists' % menuName3874 raise ValueError('menu "%s" already exists' % menuName) 3878 3875 3879 3876 menukw = {} … … 3940 3937 command = menu.add_cascade 3941 3938 else: 3942 raise ValueError , 'unknown menuitem type "%s"' % itemType3939 raise ValueError('unknown menuitem type "%s"' % itemType) 3943 3940 3944 3941 self._menuInfo[menuName][1].append(statusHelp) … … 4206 4203 Tkinter.Label, (interior,)) 4207 4204 if iconpos not in 'nsew': 4208 raise ValueError, \ 4209 'bad iconpos option "%s": should be n, s, e, or w' \ 4210 % iconpos 4205 raise ValueError('bad iconpos option "%s": should be n, s, e, or w' 4206 % iconpos) 4211 4207 4212 4208 if iconpos in 'nw': … … 4273 4269 tabpos = self['tabpos'] 4274 4270 if tabpos is not None and tabpos != 'n': 4275 raise ValueError , \4276 'bad tabpos option %s: should be n or None' % repr(tabpos)4271 raise ValueError('bad tabpos option %s: should be n or None' 4272 % repr(tabpos)) 4277 4273 self._withTabs = (tabpos is not None) 4278 4274 self._pageMargin = self['pagemargin'] … … 4366 4362 if self._pageAttrs.has_key(pageName): 4367 4363 msg = 'Page "%s" already exists.' % pageName 4368 raise ValueError , msg4364 raise ValueError(msg) 4369 4365 4370 4366 # Do this early to catch bad <before> spec before creating any items. … … 4388 4384 del kw[key] 4389 4385 else: 4390 raise KeyError , 'Unknown option "' + key + '"'4386 raise KeyError('Unknown option "' + key + '"') 4391 4387 4392 4388 # Create the frame to contain the page. … … 4513 4509 return index 4514 4510 else: 4515 raise ValueError , 'index "%s" is out of range' % index4511 raise ValueError('index "%s" is out of range' % index) 4516 4512 elif index is END: 4517 4513 if forInsert: … … 4520 4516 return listLength - 1 4521 4517 else: 4522 raise ValueError , 'NoteBook has no pages'4518 raise ValueError('NoteBook has no pages') 4523 4519 elif index is SELECT: 4524 4520 if listLength == 0: 4525 raise ValueError , 'NoteBook has no pages'4521 raise ValueError('NoteBook has no pages') 4526 4522 return self._pageNames.index(self.getcurselection()) 4527 4523 else: … … 4529 4525 return self._pageNames.index(index) 4530 4526 validValues = 'a name, a number, END or SELECT' 4531 raise ValueError, \ 4532 'bad index "%s": must be %s' % (index, validValues) 4527 raise ValueError('bad index "%s": must be %s' % (index, validValues)) 4533 4528 4534 4529 def selectpage(self, page): … … 4977 4972 return index 4978 4973 else: 4979 raise ValueError , 'index "%s" is out of range' % index4974 raise ValueError('index "%s" is out of range' % index) 4980 4975 elif index is END: 4981 4976 if listLength > 0: 4982 4977 return listLength - 1 4983 4978 else: 4984 raise ValueError , 'OptionMenu has no items'4979 raise ValueError('OptionMenu has no items') 4985 4980 else: 4986 4981 if index is SELECT: … … 4988 4983 index = self.getcurselection() 4989 4984 else: 4990 raise ValueError , 'OptionMenu has no items'4985 raise ValueError('OptionMenu has no items') 4991 4986 if index in self._itemList: 4992 4987 return self._itemList.index(index) 4993 raise ValueError, \ 4994 'bad index "%s": must be a ' \ 4995 'name, a number, END or SELECT' % (index,) 4988 raise ValueError('bad index "%s": must be a name, a number, END or SELECT' 4989 % (index,)) 4996 4990 4997 4991 def invoke(self, index = SELECT): … … 5043 5037 5044 5038 if self['orient'] not in ('horizontal', 'vertical'): 5045 raise ValueError , 'bad orient option ' + repr(self['orient']) + \5046 ': must be either \'horizontal\' or \'vertical\'' 5039 raise ValueError("bad orient option %s: must be either 'horizontal' or " 5040 "'vertical'" % repr(self['orient'])) 5047 5041 5048 5042 self._separatorThickness = self['separatorthickness'] … … 5237 5231 self._max[name], self._relmax[name] = value, relvalue 5238 5232 else: 5239 raise ValueError , 'keyword must be "size", "min", or "max"'5233 raise ValueError('keyword must be "size", "min", or "max"') 5240 5234 5241 5235 def _absSize(self, relvalue): … … 5743 5737 self._singleSelect = 0 5744 5738 else: 5745 raise ValueError , 'bad selectmode option "' + \5746 self['selectmode'] + '": should be single or multiple' 5739 raise ValueError('bad selectmode option "' + self['selectmode'] 5740 + '": should be single or multiple') 5747 5741 5748 5742 if self['buttontype'] == 'button': … … 5756 5750 self.buttonClass = Tkinter.Checkbutton 5757 5751 else: 5758 raise ValueError, 'bad buttontype option "' + \ 5759 self['buttontype'] + \ 5760 '": should be button, radiobutton or checkbutton' 5752 raise ValueError('bad buttontype option "' + self['buttontype'] 5753 + '": should be button, radiobutton or checkbutton') 5761 5754 5762 5755 if self._singleSelect: … … 5766 5759 5767 5760 if self['orient'] not in ('horizontal', 'vertical'): 5768 raise ValueError , 'bad orient option ' + repr(self['orient']) + \5769 ': must be either \'horizontal\' or \'vertical\'' 5761 raise ValueError('bad orient option ' + repr(self['orient']) 5762 + ': must be either \'horizontal\' or \'vertical\'') 5770 5763 5771 5764 # Check keywords and initialise options. … … 5817 5810 return index 5818 5811 else: 5819 raise ValueError , 'index "%s" is out of range' % index5812 raise ValueError('index "%s" is out of range' % index) 5820 5813 elif index is END: 5821 5814 if listLength > 0: 5822 5815 return listLength - 1 5823 5816 else: 5824 raise ValueError , 'RadioSelect has no buttons'5817 raise ValueError('RadioSelect has no buttons') 5825 5818 else: 5826 5819 for count in range(listLength): … … 5829 5822 return count 5830 5823 validValues = 'a name, a number or END' 5831 raise ValueError, \ 5832 'bad index "%s": must be %s' % (index, validValues) 5824 raise ValueError('bad index "%s": must be %s' % (index, validValues)) 5833 5825 5834 5826 def button(self, buttonIndex): … … 5838 5830 def add(self, componentName, **kw): 5839 5831 if componentName in self._buttonList: 5840 raise ValueError , 'button "%s" already exists' % componentName5832 raise ValueError('button "%s" already exists' % componentName) 5841 5833 5842 5834 kw['command'] = \ … … 6061 6053 else: 6062 6054 message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode 6063 raise ValueError , message6055 raise ValueError(message) 6064 6056 6065 6057 self._configureScrollCommands() … … 6081 6073 else: 6082 6074 message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode 6083 raise ValueError , message6075 raise ValueError(message) 6084 6076 6085 6077 self._configureScrollCommands() … … 6483 6475 else: 6484 6476 message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode 6485 raise ValueError , message6477 raise ValueError(message) 6486 6478 6487 6479 def _vscrollMode(self): … … 6501 6493 else: 6502 6494 message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode 6503 raise ValueError , message6495 raise ValueError(message) 6504 6496 6505 6497 def _horizflex(self): … … 6511 6503 message = 'bad horizflex option "%s": should be one of %s' % \ 6512 6504 (flex, str(self._flexoptions)) 6513 raise ValueError , message6505 raise ValueError(message) 6514 6506 6515 6507 self.reposition() … … 6523 6515 message = 'bad vertflex option "%s": should be one of %s' % \ 6524 6516 (flex, str(self._flexoptions)) 6525 raise ValueError , message6517 raise ValueError(message) 6526 6518 6527 6519 self.reposition() … … 6818 6810 self._listbox.selection_set(listitems.index(textOrList)) 6819 6811 else: 6820 raise ValueError , 'no such item "%s"' % textOrList6812 raise ValueError('no such item "%s"' % textOrList) 6821 6813 else: 6822 6814 for item in textOrList: … … 6824 6816 self._listbox.selection_set(listitems.index(item)) 6825 6817 else: 6826 raise ValueError , 'no such item "%s"' % item6818 raise ValueError('no such item "%s"' % item) 6827 6819 6828 6820 def setlist(self, items): … … 6861 6853 else: 6862 6854 message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode 6863 raise ValueError , message6855 raise ValueError(message) 6864 6856 6865 6857 self._configureScrollCommands() … … 6881 6873 else: 6882 6874 message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode 6883 raise ValueError , message6875 raise ValueError(message) 6884 6876 6885 6877 self._configureScrollCommands() … … 7282 7274 else: 7283 7275 message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode 7284 raise ValueError , message7276 raise ValueError(message) 7285 7277 7286 7278 self._configureScrollCommands() … … 7302 7294 else: 7303 7295 message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode 7304 raise ValueError , message7296 raise ValueError(message) 7305 7297 7306 7298 self._configureScrollCommands() … … 8037 8029 list = string.split(text, ':') 8038 8030 if len(list) != 3: 8039 raise ValueError , 'invalid value: ' + text8031 raise ValueError('invalid value: ' + text) 8040 8032 8041 8033 self._hour = string.atoi(list[0]) … … 8363 8355 index = list(items).index(text) 8364 8356 else: 8365 raise IndexError , 'index "%s" not found' % text8357 raise IndexError('index "%s" not found' % text) 8366 8358 elif setentry: 8367 8359 text = self._list.get(0, 'end')[index] … … 8737 8729 frame.grid_columnconfigure(0, pad = padx) 8738 8730 else: 8739 raise ValueError , 'bad orient option ' + repr(orient) + \8740 ': must be either \'horizontal\' or \'vertical\'' 8731 raise ValueError('bad orient option ' + repr(orient) 8732 + ': must be either \'horizontal\' or \'vertical\'') 8741 8733 8742 8734 self.createlabel(interior) … … 8848 8840 validValues = _counterCommands.keys() 8849 8841 validValues.sort() 8850 raise ValueError , ('bad datatype value "%s": must be a' +8851 ' function or one of %s') % (datatype, validValues)8842 raise ValueError('bad datatype value "%s": must be a function ' 8843 'or one of %s' % (datatype, validValues)) 8852 8844 8853 8845 def _forceCount(self, factor): … … 9105 9097 def logicalfont(name='Helvetica', sizeIncr = 0, **kw): 9106 9098 if not _fontInfo.has_key(name): 9107 raise ValueError , 'font %s does not exist' % name9099 raise ValueError('font %s does not exist' % name) 9108 9100 9109 9101 rtn = [] -
trunk/anuga_core/source/anuga/pmesh/mesh_interface.py
r8010 r8124 110 110 msg = 'Caching was requested, but caching module'+\ 111 111 'could not be imported' 112 raise msg112 raise Exception(msg) 113 113 114 114 … … 152 152 %(str(key)) 153 153 msg += 'Number of points in bounding polygon = %d' % max_points 154 raise SegmentError , msg154 raise SegmentError(msg) 155 155 156 156 for i in range(max_points): … … 162 162 msg = 'Segment %d was not assigned a boundary_tag.' % i 163 163 msg += 'Default tag "exterior" will be assigned to missing segment' 164 #raise Exception , msg164 #raise Exception(msg) 165 165 # Fixme: Use proper Python warning 166 166 if verbose: log.critical('WARNING: %s' % msg) … … 197 197 198 198 if fail_if_polygons_outside is True: 199 raise PolygonError , msg199 raise PolygonError(msg) 200 200 else: 201 201 msg += ' I will ignore it.' … … 239 239 msg = 'Interior polygon %s is outside bounding polygon: %s'\ 240 240 %(str(interior_polygon), str(bounding_polygon)) 241 raise PolygonError , msg241 raise PolygonError(msg) 242 242 243 243 # Resolve geo referencing -
trunk/anuga_core/source/anuga/shallow_water/boundaries.py
r7861 r8124 48 48 """ 49 49 50 ##51 # @brief Instantiate a Reflective_boundary.52 # @param domain53 50 def __init__(self, domain=None): 54 51 Boundary.__init__(self) … … 66 63 self.conserved_quantities = num.zeros(3, num.float) 67 64 68 ##69 # @brief Return a representation of this instance.70 65 def __repr__(self): 71 66 return 'Reflective_boundary' 72 67 73 ##74 # @brief Calculate reflections (reverse outward momentum).75 # @param vol_id76 # @param edge_id77 68 def evaluate(self, vol_id, edge_id): 78 """Reflective boundaries reverses the outward momentum 79 of the volume they serve. 69 """Calculate reflections (reverse outward momentum). 70 71 vol_id 72 edge_id 80 73 """ 81 74 -
trunk/anuga_core/source/anuga/shallow_water/forcing.py
r8116 r8124 44 44 msg = 'Function %s could not be executed:\n%s' %(f, e) 45 45 # FIXME: Reconsider this semantics 46 raise Exception , msg46 raise Exception(msg) 47 47 48 48 try: … … 52 52 'be converted into a numeric array of floats.\nSpecified ' 53 53 'function should return either list or array.' % f) 54 raise Exception , msg54 raise Exception(msg) 55 55 56 56 # Is this really what we want? … … 63 63 except: 64 64 msg = '%s must return vector' % func_msg 65 raise Exception , msg65 raise Exception(msg) 66 66 msg = '%s must return vector of length %d' % (func_msg, N) 67 67 assert result_len == N, msg … … 72 72 msg = ('Force field %s must be a scalar value coercible to float.' 73 73 % str(f)) 74 raise Exception , msg74 raise Exception(msg) 75 75 76 76 return f … … 147 147 phi = kwargs['phi'] 148 148 else: 149 raise Exception , 'Assumes two keyword arguments: s=..., phi=....'149 raise Exception('Assumes two keyword arguments: s=..., phi=....') 150 150 151 151 if ( self.use_coordinates ): … … 183 183 except: 184 184 msg = 'Speed must be either callable or a scalar: %s' %self.s 185 raise msg185 raise Exception(msg) 186 186 187 187 if callable(self.phi): … … 200 200 except: 201 201 msg = 'Angle must be either callable or a scalar: %s' %self.phi 202 raise msg202 raise Exception(msg) 203 203 204 204 assign_windfield_values(xmom_update, ymom_update, … … 388 388 msg = 'No triangles have been identified in ' 389 389 msg += 'specified region: %s' % inlet_region 390 raise Exception , msg390 raise Exception(msg) 391 391 392 392 # Compute exchange area as the sum of areas of triangles identified … … 421 421 default_rate(0.0) 422 422 except: 423 raise Exception , msg423 raise Exception(msg) 424 424 425 425 self.default_rate = default_rate … … 437 437 rate = self.update_rate(t) 438 438 except Modeltime_too_early, e: 439 raise Modeltime_too_early , e439 raise Modeltime_too_early(e) 440 440 except Modeltime_too_late, e: 441 441 if self.default_rate is None: … … 443 443 msg += 'You can specify keyword argument default_rate in the ' 444 444 msg += 'forcing function to tell it what to do in the absence of time data.' 445 raise Modeltime_too_late , msg445 raise Modeltime_too_late(msg) 446 446 else: 447 447 # Pass control to default rate function … … 464 464 msg = ('Attribute rate must be specified in General_forcing ' 465 465 'or its descendants before attempting to call it') 466 raise Exception , msg466 raise Exception(msg) 467 467 468 468 # Now rate is a number … … 947 947 self.use_coordinates = kwargs['use_coordinates'] 948 948 else: 949 raise Exception, 'Assumes one keyword argument: p=... or two keyword arguments p=...,use_coordinates=...' 949 raise Exception('Assumes one keyword argument: p=... or two ' 950 'keyword arguments p=...,use_coordinates=...') 950 951 951 952 if ( self.use_coordinates ): … … 980 981 except: 981 982 msg = 'Pressure must be either callable or a scalar: %s' %self.s 982 raise msg983 raise Exception(msg) 983 984 984 985 stage = domain.quantities['stage'] … … 1093 1094 self.use_coordinates=False 1094 1095 else: 1095 raise Exception, 'Assumes zero or two keyword arguments filename=...,domain=...' 1096 raise Exception('Assumes zero or two keyword arguments ' 1097 'filename=...,domain=...') 1096 1098 1097 1099 if ( self.use_coordinates ): … … 1110 1112 self.use_coordinates = False 1111 1113 else: 1112 raise Exception, 'Assumes one keyword argument: p=f(t,x,y,) or three keyword arguments p=f(t,i),filename=...,domain=...' 1114 raise Exception('Assumes one keyword argument: p=f(t,x,y,) or ' 1115 'three keyword arguments ' 1116 'p=f(t,i),filename=...,domain=...') 1113 1117 1114 1118 if ( self.use_coordinates ): … … 1126 1130 msg = 'pressure_file.starttime > domain.starttime' 1127 1131 if (self.file_time[0]>domain.starttime): 1128 raise Exception , msg1132 raise Exception(msg) 1129 1133 1130 1134 msg = 'pressure_file[-1] < domain.starttime' 1131 1135 if (self.file_time[-1]<domain.starttime): 1132 raise Exception , msg1136 raise Exception(msg) 1133 1137 1134 1138 msg = 'No pressure values exist for times greater than domain.starttime' … … 1185 1189 except: 1186 1190 msg = 'Pressure must be either callable function or a scalar: %s' %self.s 1187 raise msg1191 raise Exception(msg) 1188 1192 1189 1193 stage = domain.quantities['stage'] … … 1288 1292 phi = kwargs['phi'] 1289 1293 else: 1290 raise Exception , 'Assumes two keyword arguments: s=..., phi=....'1294 raise Exception('Assumes two keyword arguments: s=...,phi=....') 1291 1295 1292 1296 if ( self.use_coordinates ): … … 1307 1311 msg = 'wind_file.starttime > domain.starttime' 1308 1312 if (self.file_time[0]>domain.starttime): 1309 raise Exception , msg1313 raise Exception(msg) 1310 1314 1311 1315 msg = 'wind_file[-1] < domain.starttime' 1312 1316 if (self.file_time[-1]<domain.starttime): 1313 raise Exception , msg1317 raise Exception(msg) 1314 1318 1315 1319 msg = 'No wind values exist for times greater than domain.starttime' 1316 1320 if (self.file_time[-2]<domain.starttime and self.file_time[-1]>domain.starttime): 1317 raise Exception , msg1321 raise Exception(msg) 1318 1322 1319 1323 # FIXME(JJ): How do we check that evolve … … 1373 1377 except: 1374 1378 msg = 'Speed must be either callable or a scalar: %s' %self.s 1375 raise msg1379 raise Exception(msg) 1376 1380 1377 1381 if callable(self.phi): … … 1395 1399 except: 1396 1400 msg = 'Angle must be either callable or a scalar: %s' %self.phi 1397 raise msg1401 raise Exception(msg) 1398 1402 1399 1403 assign_windfield_values(xmom_update, ymom_update, -
trunk/anuga_core/source/anuga/shallow_water/most2nc.py
r7317 r8124 13 13 14 14 15 ##16 # @brief Convert a MOST file to NetCDF format.17 # @param input_file The input file to convert.18 # @param output_file The name of the oputput NetCDF file to create,19 # @param inverted_bathymetry ??20 # @param verbose True if the function is to be verbose.21 15 def most2nc(input_file, output_file, inverted_bathymetry=False, verbose=True): 16 """Convert a MOST file to NetCDF format. 17 18 input_file the input file to convert 19 output_file the name of the oputput NetCDF file to create 20 inverted_bathymetry ?? 21 verbose True if the function is to be verbose 22 """ 23 22 24 # variable names 23 25 long_name = 'LON' -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8100 r8124 301 301 #self.reduction = min #Looks better near steep slopes 302 302 303 ##304 # @brief Set the minimum depth that will be written to an SWW file.305 # @param minimum_storable_height The minimum stored height (in m).306 303 def set_minimum_storable_height(self, minimum_storable_height): 307 """Set the minimum depth that will be recognised when writing 308 to an sww file. This is useful for removing thin water layers 309 that seems to be caused by friction creep. 310 311 The minimum allowed sww depth is in meters. 304 """Set the minimum depth that will be written to an SWW file. 305 306 minimum_storable_height minimum allowed SWW depth is in meters 307 308 This is useful for removing thin water layers that seems to be caused 309 by friction creep. 312 310 """ 313 311 314 312 self.minimum_storable_height = minimum_storable_height 315 313 316 ##317 # @brief318 # @param minimum_allowed_height319 314 def set_minimum_allowed_height(self, minimum_allowed_height): 320 315 """Set minimum depth that will be recognised in the numerical scheme. 321 316 322 The minimum allowed depth is in meters.323 324 The parameter H0 (Minimal height for flux computation) 325 is also set by this function317 minimum_allowed_height minimum allowed depth in meters 318 319 The parameter H0 (Minimal height for flux computation) is also set by 320 this function. 326 321 """ 327 322 … … 335 330 self.H0 = minimum_allowed_height 336 331 337 ##338 # @brief339 # @param maximum_allowed_speed340 332 def set_maximum_allowed_speed(self, maximum_allowed_speed): 341 """Set the maximum particle speed that is allowed in water 342 shallower than minimum_allowed_height. This is useful for 343 controlling speeds in very thin layers of water and at the same time 344 allow some movement avoiding pooling of water. 333 """Set the maximum particle speed that is allowed in water shallower 334 than minimum_allowed_height. 335 336 maximum_allowed_speed 337 338 This is useful for controlling speeds in very thin layers of water and 339 at the same time allow some movement avoiding pooling of water. 345 340 """ 346 341 347 342 self.maximum_allowed_speed = maximum_allowed_speed 348 343 349 ##350 # @brief351 # @param points_file_block_line_size352 344 def set_points_file_block_line_size(self, points_file_block_line_size): 353 """Set the minimum depth that will be recognised when writing 354 to an sww file. This is useful for removing thin water layers 355 that seems to be caused by friction creep. 356 357 The minimum allowed sww depth is in meters. 358 """ 345 """ 346 """ 347 359 348 self.points_file_block_line_size = points_file_block_line_size 360 349 361 350 362 351 # FIXME: Probably obsolete in its curren form 363 ##364 # @brief Set the quantities that will be written to an SWW file.365 # @param q The quantities to be written.366 # @note Param 'q' may be None, single quantity or list of quantity strings.367 # @note If 'q' is None, no quantities will be stored in the SWW file.368 352 def set_quantities_to_be_stored(self, q): 369 """Specify which quantities will be stored in the sww file353 """Specify which quantities will be stored in the SWW file. 370 354 371 355 q must be either: … … 409 393 self.quantities_to_be_stored = q 410 394 411 ##412 # @brief413 # @param indices414 395 def get_wet_elements(self, indices=None): 415 396 """Return indices for elements where h > minimum_allowed_height … … 439 420 return wet_indices 440 421 441 ##442 # @brief443 # @param indices444 422 def get_maximum_inundation_elevation(self, indices=None): 445 423 """Return highest elevation where h > 0 … … 458 436 get_maximum_value(indices=wet_elements) 459 437 460 ##461 # @brief462 # @param indices463 438 def get_maximum_inundation_location(self, indices=None): 464 439 """Return location of highest elevation where h > 0 … … 883 858 #----------------- 884 859 885 ## @brief Compute fluxes and timestep suitable for all volumes in domain.886 # @param domain The domain to calculate fluxes for.887 860 def compute_fluxes(domain): 888 861 """Compute fluxes and timestep suitable for all volumes in domain. … … 949 922 ################################################################################ 950 923 951 ##952 # @brief Wrapper for C version of extrapolate_second_order_sw.953 # @param domain The domain to operate on.954 # @note MH090605 The following method belongs to the shallow_water domain class955 # see comments in the corresponding method in shallow_water_ext.c956 924 def extrapolate_second_order_sw(domain): 957 """Wrapper calling C version of extrapolate_second_order_sw""" 925 """Wrapper calling C version of extrapolate_second_order_sw. 926 927 domain the domain to operate on 928 929 Note MH090605: The following method belongs to the shallow_water domain 930 class, see comments in the corresponding method in shallow_water_ext.c 931 """ 958 932 959 933 from shallow_water_ext import extrapolate_second_order_sw as extrapol2 … … 980 954 int(domain.optimise_dry_cells)) 981 955 982 ##983 # @brief Distribution from centroids to vertices specific to the SWW eqn.984 # @param domain The domain to operate on.985 956 def distribute_using_vertex_limiter(domain): 986 957 """Distribution from centroids to vertices specific to the SWW equation. … … 1040 1011 Q.interpolate_from_vertices_to_edges() 1041 1012 1042 ##1043 # @brief Distribution from centroids to edges specific to the SWW eqn.1044 # @param domain The domain to operate on.1045 1013 def distribute_using_edge_limiter(domain): 1046 1014 """Distribution from centroids to edges specific to the SWW eqn. … … 1081 1049 Q.interpolate_from_vertices_to_edges() 1082 1050 1083 ##1084 # @brief Protect against infinitesimal heights and associated high velocities.1085 # @param domain The domain to operate on.1086 1051 def protect_against_infinitesimal_and_negative_heights(domain): 1087 1052 """Protect against infinitesimal heights and associated high velocities""" … … 1098 1063 domain.epsilon, wc, zc, xmomc, ymomc) 1099 1064 1100 ##1101 # @brief Wrapper for C function balance_deep_and_shallow_c().1102 # @param domain The domain to operate on.1103 1065 def balance_deep_and_shallow(domain): 1104 1066 """Compute linear combination between stage as computed by … … 1142 1104 ################################################################################ 1143 1105 1144 ##1145 # @brief Apply gravitational pull in the presence of bed slope.1146 # @param domain The domain to apply gravity to.1147 # @note Wrapper for C function gravity_c().1148 1106 def gravity(domain): 1149 1107 """Apply gravitational pull in the presence of bed slope … … 1167 1125 gravity_c(domain.g, height, elevation, point, xmom_update, ymom_update) 1168 1126 1169 ##1170 # @brief Apply friction to a surface (implicit).1171 # @param domain The domain to apply Manning friction to.1172 # @note Wrapper for C function manning_friction_c().1173 1127 def manning_friction_implicit(domain): 1174 1128 """Apply (Manning) friction to water momentum … … 1205 1159 1206 1160 1207 ##1208 # @brief Apply friction to a surface (explicit).1209 # @param domain The domain to apply Manning friction to.1210 # @note Wrapper for C function manning_friction_c().1211 1161 def manning_friction_explicit(domain): 1212 1162 """Apply (Manning) friction to water momentum … … 1244 1194 1245 1195 # FIXME (Ole): This was implemented for use with one of the analytical solutions 1246 ##1247 # @brief Apply linear friction to a surface.1248 # @param domain The domain to apply Manning friction to.1249 # @note Is this still used (30 Oct 2007)?1250 1196 def linear_friction(domain): 1251 1197 """Apply linear friction to water momentum -
trunk/anuga_core/source/anuga/shallow_water/sww_interrogate.py
r7858 r8124 14 14 from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints 15 15 16 ## 17 # @brief Get values for quantities interpolated to polyline midpoints from SWW. 18 # @param filename Path to file to read. 19 # @param quantity_names Quantity names to get. 20 # @param polyline Representation of desired cross-section. 21 # @param verbose True if this function is to be verbose. 22 # @return (segments, i_func) where segments is a list of Triangle_intersection 23 # instances and i_func is an instance of Interpolation_function. 24 # @note For 'polyline' assume absolute UTM coordinates. 16 25 17 def get_interpolated_quantities_at_polyline_midpoints(filename, 26 18 quantity_names=None, 27 19 polyline=None, 28 20 verbose=False): 29 """Get values for quantities interpolated to polyline midpoints from SWW 30 31 Input:32 filename - Name of sww file33 quantity_names - Names of quantities to load34 polyline: Representation of desired cross section - it may contain35 multiple sections allowing for complex shapes. Assume36 absolute UTM coordinates.37 Format [[x0, y0], [x1, y1], ...] 38 39 Output:40 segments: list of instances of class Triangle_intersection41 interpolation_function: Instance of class Interpolation_function 42 43 44 45 get_energy_through_cross_section21 """Get values for quantities interpolated to polyline midpoints from SWW. 22 23 filename path to file to read 24 quantity_names quantity names to get 25 polyline representation of desired cross-section 26 may contain multiple sections allowing complex shapes 27 assume UTM coordinates 28 verbose True if this function is to be verbose 29 30 Returns (segments, i_func) 31 where segments is a list of Triangle_intersection instances 32 and i_func is an instance of Interpolation_function. 33 34 Note: For 'polyline' assume absolute UTM coordinates. 35 36 This function is used by get_flow_through_cross_section and 37 get_energy_through_cross_section. 46 38 """ 47 39 … … 76 68 77 69 78 ##79 # @brief Obtain flow (m^3/s) perpendicular to specified cross section.80 # @param filename Path to file to read.81 # @param polyline Representation of desired cross-section.82 # @param verbose Trie if this function is to be verbose.83 # @return (time, Q) where time and Q are lists of time and flow respectively.84 70 def get_flow_through_cross_section(filename, polyline, verbose=False): 85 71 """Obtain flow (m^3/s) perpendicular to specified cross section. 86 72 87 Inputs: 88 filename: Name of sww file 89 polyline: Representation of desired cross section - it may contain 90 multiple sections allowing for complex shapes. Assume 91 absolute UTM coordinates. 92 Format [[x0, y0], [x1, y1], ...] 93 94 Output: 95 time: All stored times in sww file 96 Q: Hydrograph of total flow across given segments for all stored times. 73 filename path to SWW file to read 74 polyline representation of desired cross-section - it may contain 75 multiple sections allowing for complex shapes. Assume 76 absolute UTM coordinates. 77 Format [[x0, y0], [x1, y1], ...] 78 verbose True if this function is to be verbose 79 80 Return (time, Q) 81 where time is a list of all stored times in SWW file 82 and Q is a hydrograph of total flow across given segments for all 83 stored times. 97 84 98 85 The normal flow is computed for each triangle intersected by the polyline … … 147 134 148 135 149 ##150 # @brief Get average energy across a cross-section.151 # @param filename Path to file of interest.152 # @param polyline Representation of desired cross-section.153 # @param kind Select energy to compute: 'specific' or 'total'.154 # @param verbose True if this function is to be verbose.155 # @return (time, E) where time and E are lists of timestep and energy.156 136 def get_energy_through_cross_section(filename, 157 137 polyline, … … 160 140 """Obtain average energy head [m] across specified cross section. 161 141 162 Inputs:163 polyline: Representation of desired cross section - it may contain164 multiple sections allowing for complex shapes. Assume165 absolute UTM coordinates.166 Format [[x0, y0], [x1, y1], ...]167 kind: Select which energy to compute.168 Options are 'specific' and 'total' (default) 169 170 Output:171 E:Average energy [m] across given segments for all stored times.172 173 The average velocity is computed for each triangle intersected by 174 thepolyline and averaged weighted by segment lengths.142 filename path to file of interest 143 polyline representation of desired cross-section - it may contain multiple 144 sections allowing for complex shapes. Assume absolute UTM 145 coordinates. Format [[x0, y0], [x1, y1], ...] 146 kind select energy to compute: 'specific' or 'total' 147 verbose True if this function is to be verbose 148 149 Returns (time, E) 150 where time is a list of timestep 151 and E isaAverage energy [m] across given segments for all stored times. 152 153 The average velocity is computed for each triangle intersected by the 154 polyline and averaged weighted by segment lengths. 175 155 176 156 The typical usage of this function would be to get average energy of … … 247 227 248 228 249 ##250 # @brief Return highest elevation where depth > 0.251 # @param filename Path to SWW file of interest.252 # @param polygon If specified resrict to points inside this polygon.253 # @param time_interval If specified resrict to within the time specified.254 # @param verbose True if this function is to be verbose.255 229 def get_maximum_inundation_elevation(filename, 256 230 polygon=None, … … 259 233 """Return highest elevation where depth > 0 260 234 235 filename path to SWW file containing ANUGA model output 236 polygon if specified restrict to points inside this polygon 237 time_interval if specified restrict to within the period specified 238 verbose True if this function is to be verbose 239 240 If no inundation is found within polygon and time_interval the return value 241 is None signifying "No Runup" or "Everything is dry". 242 261 243 Usage: 262 244 max_runup = get_maximum_inundation_elevation(filename, … … 265 247 verbose=False) 266 248 267 filename is a NetCDF sww file containing ANUGA model output.268 Optional arguments polygon and time_interval restricts the maximum269 runup calculation270 to a points that lie within the specified polygon and time interval.271 272 If no inundation is found within polygon and time_interval the return value273 is None signifying "No Runup" or "Everything is dry".274 275 249 See general function get_maximum_inundation_data for details. 276 250 """ … … 283 257 284 258 285 ##286 # @brief Return location of highest elevation where h > 0287 # @param filename Path to SWW file to read.288 # @param polygon If specified resrict to points inside this polygon.289 # @param time_interval If specified resrict to within the time specified.290 # @param verbose True if this function is to be verbose.291 259 def get_maximum_inundation_location(filename, 292 260 polygon=None, … … 295 263 """Return location of highest elevation where h > 0 296 264 265 filename path to SWW file containing ANUGA model output 266 polygon if specified restrict to points inside this polygon 267 time_interval if specified restrict to within the period specified 268 verbose True if this function is to be verbose 269 270 If no inundation is found within polygon and time_interval the return value 271 is None signifying "No Runup" or "Everything is dry". 272 297 273 Usage: 298 274 max_runup_location = get_maximum_inundation_location(filename, … … 301 277 verbose=False) 302 278 303 filename is a NetCDF sww file containing ANUGA model output.304 Optional arguments polygon and time_interval restricts the maximum305 runup calculation306 to a points that lie within the specified polygon and time interval.307 308 If no inundation is found within polygon and time_interval the return value309 is None signifying "No Runup" or "Everything is dry".310 311 279 See general function get_maximum_inundation_data for details. 312 280 """ … … 319 287 320 288 321 ##322 # @brief Compute maximum run up height from SWW file.323 # @param filename Path to SWW file to read.324 # @param polygon If specified resrict to points inside this polygon.325 # @param time_interval If specified resrict to within the time specified.326 # @param use_centroid_values327 # @param verbose True if this function is to be verbose.328 # @return (maximal_runup, maximal_runup_location)329 289 def get_maximum_inundation_data(filename, polygon=None, time_interval=None, 330 290 use_centroid_values=False, 331 291 verbose=False): 332 292 """Compute maximum run up height from sww file. 293 294 filename path to SWW file to read 295 polygon if specified resrict to points inside this polygon 296 assumed absolute coordinates and in same zone as 297 domain 298 time_interval if specified resrict to within the period specified 299 use_centroid_values 300 verbose True if this function is to be verbose 301 302 Returns (maximal_runup, maximal_runup_location). 333 303 334 304 Usage: … … 339 309 340 310 Algorithm is as in get_maximum_inundation_elevation from 341 shallow_water_domain except that this function works with the swwfile and311 shallow_water_domain except that this function works with the SWW file and 342 312 computes the maximal runup height over multiple timesteps. 343 344 Optional arguments polygon and time_interval restricts the maximum runup345 calculation to a points that lie within the specified polygon and time346 interval.347 348 Polygon is assumed to be in (absolute) UTM coordinates in the same zone349 as domain.350 313 351 314 If no inundation is found within polygon and time_interval the return value -
trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r8047 r8124 232 232 pass 233 233 else: 234 raise Exception , 'Should have raised an exception'234 raise Exception('Should have raised an exception') 235 235 236 236 # Individual flux tests … … 2131 2131 else: 2132 2132 msg = 'Should have raised exception' 2133 raise Exception , msg2133 raise Exception(msg) 2134 2134 2135 2135 def Xtest_inflow_outflow_conservation(self): … … 4967 4967 else: 4968 4968 msg = 'This should have caught NAN at boundary' 4969 raise Exception , msg4969 raise Exception(msg) 4970 4970 4971 4971 #Cleanup … … 5505 5505 except RuntimeError, e: 5506 5506 msg = 'Test failed: %s' % str(e) 5507 raise Exception, msg5507 raise Exception,(sg) 5508 5508 # clean up in case raise fails 5509 5509 os.remove(meshname) … … 5571 5571 except AssertionError, e: 5572 5572 msg = 'Test failed: %s' % str(e) 5573 raise Exception , msg5573 raise Exception(msg) 5574 5574 # Cleanup in case this failed 5575 5575 os.remove(meshname) … … 5582 5582 except AssertionError, e: 5583 5583 msg = 'Test failed: %s' % str(e) 5584 raise Exception , msg5584 raise Exception(msg) 5585 5585 # Cleanup in case this failed 5586 5586 os.remove(meshname) -
trunk/anuga_core/source/anuga/shallow_water_balanced/swb_domain.py
r8072 r8124 203 203 #Q.extrapolate_second_order_and_limit_by_vertex() 204 204 else: 205 raise 'Unknown order'205 raise Exception('Unknown order: %s' % str(self._order_)) 206 206 207 207 … … 330 330 #Q.extrapolate_second_order_and_limit_by_vertex() 331 331 else: 332 raise 'Unknown order'332 raise Exception('Unknown order: %s' % str(self._order_)) 333 333 334 334 -
trunk/anuga_core/source/anuga/shallow_water_balanced/test_swb_basic.py
r7869 r8124 152 152 pass 153 153 else: 154 raise Exception , 'Should have raised an exception'154 raise Exception('Should have raised an exception') 155 155 156 156 # Individual flux tests … … 677 677 else: 678 678 msg = 'should have caught wrong time interval' 679 raise Exception , msg679 raise Exception(msg) 680 680 681 681 # Check correct time interval … … 768 768 else: 769 769 msg = 'Time interval should have raised an exception' 770 raise Exception , msg770 raise Exception(msg) 771 771 772 772 # Cleanup … … 1979 1979 except RuntimeError, e: 1980 1980 msg = 'Test failed: %s' % str(e) 1981 raise Exception , msg1981 raise Exception(msg) 1982 1982 # clean up in case raise fails 1983 1983 os.remove(meshname) … … 2033 2033 except AssertionError, e: 2034 2034 msg = 'Test failed: %s' % str(e) 2035 raise Exception , msg2035 raise Exception(msg) 2036 2036 # Cleanup in case this failed 2037 2037 os.remove(meshname) … … 2044 2044 except AssertionError, e: 2045 2045 msg = 'Test failed: %s' % str(e) 2046 raise Exception , msg2046 raise Exception(msg) 2047 2047 # Cleanup in case this failed 2048 2048 os.remove(meshname) -
trunk/anuga_core/source/anuga/utilities/compile.py
r7940 r8124 175 175 msg += 'One way to check this is to run %s on ' %compiler 176 176 msg += 'the commandline.' 177 raise Exception , msg177 raise Exception(msg) 178 178 179 179 … … 192 192 open(headerfile, 'r') 193 193 except: 194 raise """Did not find Python header file %s.194 raise Exception("""Did not find Python header file %s. 195 195 Make sure files for Python C-extensions are installed. 196 196 In debian linux, for example, you need to install a 197 package called something like python2.3-dev""" %headerfile 197 package called something like python2.3-dev""" %headerfile) 198 198 199 199 … … 243 243 FN = FN + '.c' 244 244 elif ext.lower() != '.c': 245 raise Exception , "Unrecognised extension: " + FN245 raise Exception("Unrecognised extension: " + FN) 246 246 247 247 try: 248 248 open(FN, 'r') 249 249 except: 250 raise Exception , "Could not open: " + FN250 raise Exception("Could not open: " + FN) 251 251 252 252 if not object_files: root1 = root #Remember first filename … … 293 293 err = os.system(s) 294 294 if err != 0: 295 raise 'Attempting to compile %s failed - please try manually' %FN295 raise Exception('Attempting to compile %s failed - please try manually' %FN) 296 296 except: 297 raise 'Could not compile %s - please try manually' %FN297 raise Exception('Could not compile %s - please try manually' %FN) 298 298 299 299 … … 314 314 err=os.system(s) 315 315 if err != 0: 316 raise 'Attempting to link %s failed - please try manually' %root1 316 raise Exception('Attempting to link %s failed - please try manually' 317 % root1) 317 318 except: 318 raise 'Could not link %s - please try manually' %root1319 raise Exception('Could not link %s - please try manually' % root1) 319 320 320 321 … … 352 353 msg = 'C extension %s seems to compile OK, ' 353 354 msg += 'but it can still not be imported.' 354 raise msg355 raise Exception(msg) 355 356 else: 356 357 C=True … … 441 442 msg = 'Could not compile C extension %s\n' %filename 442 443 msg += str(e) 443 raise Exception , msg444 raise Exception(msg) 444 445 else: 445 446 print 'C extension %s OK' %filename -
trunk/anuga_core/source/anuga/utilities/sparse.py
r7887 r8124 22 22 A = num.array(args[0]) 23 23 except: 24 raise 'Input must be convertable to a numeric array'24 raise Exception('Input must be convertable to a numeric array') 25 25 26 26 assert len(A.shape) == 2, 'Input must be a 2d matrix' … … 37 37 self.N = args[1] 38 38 else: 39 raise 'Invalid construction'39 raise Exception('Invalid construction') 40 40 41 41 self.shape = (self.M, self.N) … … 112 112 except: 113 113 msg = 'FIXME: Only numeric types implemented so far' 114 raise msg114 raise Exception(msg) 115 115 116 116 … … 150 150 151 151 else: 152 raise ValueError , 'Dimension too high: d=%d' %len(B.shape)152 raise ValueError('Dimension too high: d=%d' %len(B.shape)) 153 153 154 154 return R … … 176 176 except: 177 177 msg = 'Sparse matrix can only "right-multiply" onto a scalar' 178 raise TypeError , msg178 raise TypeError(msg) 179 179 else: 180 180 new = self.copy() … … 214 214 215 215 else: 216 raise 'Can only multiply with 1d array'216 raise Exception('Can only multiply with 1d array') 217 217 218 218 return R … … 271 271 self.N = A.N 272 272 else: 273 raise ValueError , "Sparse_CSR(A) expects A == Sparse Matrix"273 raise ValueError("Sparse_CSR(A) expects A == Sparse Matrix") 274 274 275 275 def __repr__(self): -
trunk/anuga_core/source/anuga/utilities/test_file_utils.py
r7847 r8124 62 62 pass 63 63 else: 64 raise 'Should have raised exception'64 raise Exception('Should have raised exception') 65 65 66 66 def test_get_all_swwfiles1(self): -
trunk/anuga_core/source/anuga/utilities/test_numerical_tools.py
r7276 r8124 273 273 compile(FN) 274 274 except: 275 raise 'Could not compile %s' %FN275 raise Exception('Could not compile %s' % FN) 276 276 else: 277 277 import util_ext -
trunk/anuga_core/source/anuga/utilities/test_sparse.py
r7276 r8124 148 148 pass 149 149 else: 150 raise 'Should have failed'150 raise Exception('Should have failed') 151 151 152 152 def test_sparse_addition(self):
Note: See TracChangeset
for help on using the changeset viewer.