Changeset 4174 for anuga_core/source/anuga/fit_interpolate/fit.py
- Timestamp:
- Jan 12, 2007, 3:54:31 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/fit.py
r4165 r4174 30 30 31 31 from anuga.caching import cache 32 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_absolute 32 from anuga.geospatial_data.geospatial_data import Geospatial_data, \ 33 ensure_absolute 33 34 from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate 34 35 from anuga.utilities.sparse import Sparse, Sparse_CSR … … 499 500 return vertex_attributes 500 501 501 502 def obsolete_fit_to_mesh_file(mesh_file, point_file, mesh_output_file,503 alpha=DEFAULT_ALPHA, verbose= False,504 display_errors = True):505 """506 Given a mesh file (tsh) and a point attribute file (xya), fit507 point attributes to the mesh and write a mesh file with the508 results.509 510 511 If data_origin is not None it is assumed to be512 a 3-tuple with geo referenced513 UTM coordinates (zone, easting, northing)514 515 NOTE: Throws IOErrors, for a variety of file problems.516 517 """518 #OBSOLETE519 #Problems with using blocking and knowing the attribute title..520 521 522 # Question523 # should data_origin and mesh_origin be passed in?524 # No they should be in the data structure525 #526 #Should the origin of the mesh be changed using this function?527 # That is overloading this function. Have it as a seperate528 # method, at least initially.529 530 from load_mesh.loadASCII import import_mesh_file, \531 import_points_file, export_mesh_file, \532 concatinate_attributelist533 534 # FIXME: Use geospatial instead of import_points_file535 try:536 mesh_dict = import_mesh_file(mesh_file)537 except IOError,e:538 if display_errors:539 print "Could not load bad file. ", e540 raise IOError #Re-raise exception541 542 vertex_coordinates = mesh_dict['vertices']543 triangles = mesh_dict['triangles']544 if type(mesh_dict['vertex_attributes']) == ArrayType:545 old_point_attributes = mesh_dict['vertex_attributes'].tolist()546 else:547 old_point_attributes = mesh_dict['vertex_attributes']548 549 if type(mesh_dict['vertex_attribute_titles']) == ArrayType:550 old_title_list = mesh_dict['vertex_attribute_titles'].tolist()551 else:552 old_title_list = mesh_dict['vertex_attribute_titles']553 554 if verbose: print 'tsh file %s loaded' %mesh_file555 556 # load in the .pts file557 try:558 #point_dict = import_points_file(point_file, verbose=verbose)559 560 geospatial = Geospatial_data(point_file)561 point_coordinates = geospatial.get_data_points(absolute=False)562 except IOError,e:563 if display_errors:564 print "Could not load bad file. ", e565 raise IOError #Re-raise exception566 567 #point_coordinates = point_dict['pointlist']568 #get_all_attributes569 #title_list,point_attributes = concatinate_attributelist(point_dict['attributelist'])570 title_list,point_attributes = concatinate_attributelist( \571 geospatial.get_all_attributes())572 573 574 if mesh_dict.has_key('geo_reference') and not mesh_dict['geo_reference'] is None:575 mesh_origin = mesh_dict['geo_reference'].get_origin()576 else:577 mesh_origin = (56, 0, 0) #FIXME(DSG-DSG)578 579 if verbose: print "points file loaded"580 if verbose: print "fitting to mesh"581 f = fit_to_mesh(vertex_coordinates,582 triangles,583 point_file,584 alpha = alpha,585 verbose = verbose,586 data_origin = data_origin,587 mesh_origin = mesh_origin)588 if verbose: print "finished fitting to mesh"589 590 # convert array to list of lists591 new_point_attributes = f.tolist()592 #FIXME have this overwrite attributes with the same title - DSG593 #Put the newer attributes last594 if old_title_list <> []:595 old_title_list.extend(title_list)596 #FIXME can this be done a faster way? - DSG597 for i in range(len(old_point_attributes)):598 old_point_attributes[i].extend(new_point_attributes[i])599 mesh_dict['vertex_attributes'] = old_point_attributes600 mesh_dict['vertex_attribute_titles'] = old_title_list601 else:602 mesh_dict['vertex_attributes'] = new_point_attributes603 mesh_dict['vertex_attribute_titles'] = title_list604 605 if verbose: print "exporting to file ", mesh_output_file606 607 try:608 export_mesh_file(mesh_output_file, mesh_dict)609 except IOError,e:610 if display_errors:611 print "Could not write file. ", e612 raise IOError613 614 615 502 def _fit(*args, **kwargs): 616 503 """Private function for use with caching. Reason is that classes
Note: See TracChangeset
for help on using the changeset viewer.