- Timestamp:
- Jul 17, 2008, 8:32:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r5394 r5518 261 261 # New leaner interface to setting values 262 262 def set_values(self, 263 numeric =None, # List, numeric array or constant264 quantity =None, # Another quantity265 function =None, # Callable object: f(x,y)266 geospatial_data =None, # Arbitrary dataset267 points = None, values = None, data_georef =None, # Obsoleted by use of geo_spatial object268 filename = None, attribute_name =None, #Input from file269 alpha =None,270 location ='vertices',271 polygon =None,272 indices =None,273 smooth =False,274 verbose =False,275 use_cache =False):263 numeric=None, # List, numeric array or constant 264 quantity=None, # Another quantity 265 function=None, # Callable object: f(x,y) 266 geospatial_data=None, # Arbitrary dataset 267 points=None, values=None, data_georef=None, # Obsoleted by use of geo_spatial object 268 filename=None, attribute_name=None, #Input from file 269 alpha=None, 270 location='vertices', 271 polygon=None, 272 indices=None, 273 smooth=False, 274 verbose=False, 275 use_cache=False): 276 276 277 277 """Set values for quantity based on different sources. … … 343 343 internal ordering. 344 344 345 If location is not 'unique vertices' Indices is the 346 set of element ids that the operation applies to. 347 If location is 'unique vertices' Indices is the set 348 of vertex ids that the operation applies to. 345 If location is 'unique vertices' indices refers the set 346 of node ids that the operation applies to. 347 If location is not 'unique vertices' indices refers the 348 set of triangle ids that the operation applies to. 349 349 350 350 351 If selected location is vertices, values for … … 363 364 indices: Restrict update of quantity to locations that are 364 365 identified by indices (e.g. node ids if location 365 is ' vertices')366 is 'unique vertices' or triangle ids otherwise). 366 367 367 368 verbose: True means that output to stdout is generated … … 387 388 # FIXME (Ole): This needs to be generalised and 388 389 # perhaps the notion of location and indices simplified 390 391 # FIXME (Ole): Need to compute indices based on polygon (and location) and 392 # use existing code after that. 389 393 390 394 if polygon is not None: … … 473 477 alpha, 474 478 location, indices, 475 verbose =verbose,476 use_cache =use_cache)479 verbose=verbose, 480 use_cache=use_cache) 477 481 else: 478 482 msg = 'Illegal type for argument numeric: %s' %str(numeric) … … 491 495 alpha, 492 496 location, indices, 493 verbose =verbose,494 use_cache =use_cache)497 verbose=verbose, 498 use_cache=use_cache) 495 499 elif points is not None: 496 500 msg = 'The usage of points in set_values has been deprecated.' +\ … … 507 511 self.set_values_from_file(filename, attribute_name, alpha, 508 512 location, indices, 509 verbose =verbose,513 verbose=verbose, 510 514 max_read_lines=max_read_lines, 511 use_cache =use_cache)515 use_cache=use_cache) 512 516 else: 513 517 raise Exception, 'This can\'t happen :-)' … … 541 545 self.centroid_values[:] = X 542 546 else: 543 # Brute force547 # Brute force 544 548 for i in indices: 545 549 self.centroid_values[i] = X … … 549 553 self.edge_values[:] = X 550 554 else: 551 # Brute force555 # Brute force 552 556 for i in indices: 553 557 self.edge_values[i] = X … … 558 562 else: 559 563 560 # Go through list of unique vertices564 # Go through list of unique vertices 561 565 for unique_vert_id in indices: 562 566 563 567 triangles = self.domain.get_triangles_and_vertices_per_node(node=unique_vert_id) 564 568 565 # In case there are unused points569 # In case there are unused points 566 570 if len(triangles) == 0: 567 571 continue 568 572 569 # Go through all triangle, vertex pairs570 # and set corresponding vertex value573 # Go through all triangle, vertex pairs 574 # and set corresponding vertex value 571 575 for triangle_id, vertex_id in triangles: 572 576 self.vertex_values[triangle_id, vertex_id] = X 573 577 574 # Intialise centroid and edge_values578 # Intialise centroid and edge_values 575 579 self.interpolate() 576 580 else: … … 578 582 self.vertex_values[:] = X 579 583 else: 580 # Brute force584 # Brute force 581 585 for i_vertex in indices: 582 586 self.vertex_values[i_vertex] = X … … 622 626 indices = array(indices).astype(Int) 623 627 msg = 'Number of values must match number of indices:' 624 msg += ' You specified %d values and %d indices'\628 msg += ' You specified %d values and %d indices'\ 625 629 %(values.shape[0], indices.shape[0]) 626 630 assert values.shape[0] == indices.shape[0], msg … … 669 673 670 674 elif len(values.shape) == 2: 671 # Vertex values are given as a triplet for each triangle675 # Vertex values are given as a triplet for each triangle 672 676 673 677 msg = 'Array must be N x 3' … … 723 727 """ 724 728 725 # FIXME: Should check that function returns something sensible and726 # raise a meaningfull exception if it returns None for example727 728 # FIXME: Should supply absolute coordinates729 # FIXME: Should check that function returns something sensible and 730 # raise a meaningfull exception if it returns None for example 731 732 # FIXME: Should supply absolute coordinates 729 733 730 734 … … 785 789 def set_values_from_geospatial_data(self, geospatial_data, alpha, 786 790 location, indices, 787 verbose =False,788 use_cache =False):791 verbose=False, 792 use_cache=False): 789 793 # FIXME: Use this function for the time being. Later move code in here 790 794 791 points = geospatial_data.get_data_points(absolute =False)795 points = geospatial_data.get_data_points(absolute=False) 792 796 values = geospatial_data.get_attributes() 793 797 data_georef = geospatial_data.get_geo_reference() … … 810 814 811 815 812 # Take care of georeferencing816 # Take care of georeferencing 813 817 if data_georef is None: 814 818 data_georef = Geo_reference() … … 819 823 820 824 # Call fit_interpolate.fit function 821 # args = (coordinates, triangles, points, values)825 # args = (coordinates, triangles, points, values) 822 826 args = (points, ) 823 827 kwargs = {'vertex_coordinates': coordinates, … … 841 845 def set_values_from_points(self, points, values, alpha, 842 846 location, indices, 843 data_georef =None,844 verbose =False,845 use_cache =False):847 data_georef=None, 848 verbose=False, 849 use_cache=False): 846 850 """ 847 851 Set quantity values from arbitray data points using … … 854 858 def set_values_from_file(self, filename, attribute_name, alpha, 855 859 location, indices, 856 verbose =False,857 use_cache =False,860 verbose=False, 861 use_cache=False, 858 862 max_read_lines=None): 859 863 """Set quantity based on arbitrary points in a points file … … 1140 1144 indices=range(self.domain.number_of_nodes) 1141 1145 vert_values = [] 1142 1146 1143 1147 # Go through list of unique vertices 1144 1148 for unique_vert_id in indices: … … 1213 1217 """ 1214 1218 1215 A,V = self.get_vertex_values(xy=False, smooth =True)1219 A,V = self.get_vertex_values(xy=False, smooth=True) 1216 1220 self.set_vertex_values(A) 1217 1221 … … 1413 1417 # (either from this module or C-extension) 1414 1418 extrapolate_second_order_and_limit_by_edge(self) 1415 1416 1419 1417 1420 def extrapolate_second_order_and_limit_by_vertex(self):
Note: See TracChangeset
for help on using the changeset viewer.