Changeset 5723
- Timestamp:
- Sep 3, 2008, 2:33:25 PM (16 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/interpolate.py
r5657 r5723 721 721 if verbose is True: 722 722 import sys 723 if sys.platform == 'win32': 723 if sys.platform == 'win32': # FIXME (Ole): Why only Windoze? 724 724 from anuga.utilities.polygon import plot_polygons 725 725 #out_interp_pts = take(interpolation_points,[indices]) 726 726 title = 'Interpolation points fall outside specified mesh' 727 plot_polygons([mesh_boundary_polygon,interpolation_points,out_interp_pts], 728 ['line','point','outside'],figname='points_boundary_out',label=title,verbose=verbose) 727 plot_polygons([mesh_boundary_polygon, 728 interpolation_points, 729 out_interp_pts], 730 ['line','point','outside'], 731 figname='points_boundary_out', 732 label=title, 733 verbose=verbose) 729 734 730 735 # Joaquim Luis suggested this as an Exception, so … … 735 740 print msg 736 741 #raise Exception(msg) 742 737 743 elif triangles is None and vertex_coordinates is not None:#jj 738 744 #Dealing with sts file … … 748 754 from anuga.utilities.polygon import plot_polygons 749 755 title = 'Interpolation function: Polygon and interpolation points' 750 plot_polygons([mesh_boundary_polygon,interpolation_points], 751 ['line','point'],figname='points_boundary',label=title,verbose=verbose) 756 plot_polygons([mesh_boundary_polygon, 757 interpolation_points], 758 ['line','point'], 759 figname='points_boundary', 760 label=title, 761 verbose=verbose) 752 762 753 763 m = len(self.interpolation_points) -
anuga_core/source/anuga/shallow_water/data_manager.py
r5661 r5723 6252 6252 quantities=None, 6253 6253 verbose=False): 6254 """Get and rebuild mesh structure and theassociated quantities from sww file6255 6254 """Get and rebuild mesh structure and associated quantities from sww file 6255 6256 6256 Input: 6257 6257 filename - Name os sww file … … 6263 6263 quantities - arrays with quantity values at each mesh node 6264 6264 time - vector of stored timesteps 6265 6266 6267 This function is used by e.g. get_interpolated_quantities_at_polyline_midpoints 6265 6268 """ 6266 6269 … … 6327 6330 6328 6331 6329 6330 def get_flow_through_cross_section(filename, 6331 polyline, 6332 verbose=False): 6333 """Obtain flow (m^3/s) perpendicular to specified cross section. 6334 6335 Inputs: 6336 filename: Name of sww file 6337 polyline: Representation of desired cross section - it may contain multiple 6338 sections allowing for complex shapes. Assume absolute UTM coordinates. 6339 Format [[x0, y0], [x1, y1], ...] 6332 6333 6334 def get_interpolated_quantities_at_polyline_midpoints(filename, 6335 quantity_names=None, 6336 polyline=None, 6337 verbose=False): 6338 """Get values for quantities interpolated to polyline midpoints from sww file 6339 6340 Input: 6341 filename - Name of sww file 6342 quantity_names - Names of quantities to load 6343 polyline: Representation of desired cross section - it may contain 6344 multiple sections allowing for complex shapes. Assume 6345 absolute UTM coordinates. 6346 Format [[x0, y0], [x1, y1], ...] 6340 6347 6341 6348 Output: 6342 time: All stored times in sww file 6343 Q: Hydrograph of total flow across given segments for all stored times. 6344 6345 The normal flow is computed for each triangle intersected by the polyline and 6346 added up. Multiple segments at different angles are specified the normal flows 6347 may partially cancel each other. 6348 6349 The typical usage of this function would be to get flow through a channel, 6350 and the polyline would then be a cross section perpendicular to the flow. 6351 6352 """ 6353 6349 segments: list of instances of class Triangle_intersection 6350 interpolation_function: Instance of class Interpolation_function 6351 6352 6353 This function is used by get_flow_through_cross_section and 6354 get_energy_through_cross_section 6355 """ 6356 6354 6357 from anuga.fit_interpolate.interpolate import Interpolation_function 6355 6356 quantity_names =['elevation',6357 'stage',6358 'xmomentum',6359 'ymomentum']6360 6358 6361 6359 # Get mesh and quantities from sww file … … 6371 6369 # Find all intersections and associated triangles. 6372 6370 segments = mesh.get_intersecting_segments(polyline, verbose=verbose) 6373 #print 6374 #for x in segments: 6375 # print x 6376 6377 6371 6372 6378 6373 # Then store for each triangle the length of the intersecting segment(s), 6379 6374 # right hand normal(s) and midpoints as interpolation_points. … … 6388 6383 print 'total number of interpolation points = %d'\ 6389 6384 %len(interpolation_points) 6390 6385 6386 6387 6391 6388 I = Interpolation_function(time, 6392 6389 quantities, … … 6396 6393 interpolation_points=interpolation_points, 6397 6394 verbose=verbose) 6395 6396 return segments, I 6397 6398 6399 def get_flow_through_cross_section(filename, 6400 polyline, 6401 verbose=False): 6402 """Obtain flow (m^3/s) perpendicular to specified cross section. 6403 6404 Inputs: 6405 filename: Name of sww file 6406 polyline: Representation of desired cross section - it may contain 6407 multiple sections allowing for complex shapes. Assume 6408 absolute UTM coordinates. 6409 Format [[x0, y0], [x1, y1], ...] 6410 6411 Output: 6412 time: All stored times in sww file 6413 Q: Hydrograph of total flow across given segments for all stored times. 6414 6415 The normal flow is computed for each triangle intersected by the polyline 6416 and added up. Multiple segments at different angles are specified the 6417 normal flows may partially cancel each other. 6418 6419 The typical usage of this function would be to get flow through a channel, 6420 and the polyline would then be a cross section perpendicular to the flow. 6421 6422 """ 6423 6424 quantity_names =['elevation', 6425 'stage', 6426 'xmomentum', 6427 'ymomentum'] 6428 6429 6430 # Get values for quantities at each midpoint of poly line from sww file 6431 X = get_interpolated_quantities_at_polyline_midpoints(filename, 6432 quantity_names=quantity_names, 6433 polyline=polyline, 6434 verbose=verbose) 6435 segments, interpolation_function = X 6436 6437 6438 # Get vectors for time and interpolation_points 6439 time = interpolation_function.time 6440 interpolation_points = interpolation_function.interpolation_points 6398 6441 6399 6442 if verbose: print 'Computing hydrograph' … … 6403 6446 total_flow=0 6404 6447 for i, p in enumerate(interpolation_points): 6405 elevation, stage, uh, vh = I(t, point_id=i)6448 elevation, stage, uh, vh = interpolation_function(t, point_id=i) 6406 6449 normal = segments[i].normal 6407 6450 … … 6418 6461 # Store flow at this timestep 6419 6462 Q.append(total_flow) 6420 6421 6463 6422 6464
Note: See TracChangeset
for help on using the changeset viewer.