Ignore:
Timestamp:
Sep 22, 2004, 6:04:29 PM (21 years ago)
Author:
duncan
Message:

added 1st iteration of loading a .tsh and .xya file and returning a .tsh with fitted attribute values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/least_squares.py

    r339 r342  
    331331   
    332332    import os, sys
    333     from load_mesh.loadASCII import mesh_file_to_mesh_dictionary
    334     usage = "usage: %s pmesh_file_name" %         os.path.basename(sys.argv[0])
    335 
    336     if len(sys.argv) < 2:
     333    from load_mesh.loadASCII import mesh_file_to_mesh_dictionary, \
     334                 load_xya_file, export_trianglulation_file
     335    usage = "usage: %s mesh_input.tsh point.xya  mesh_output.tsh" %         os.path.basename(sys.argv[0])
     336
     337    if len(sys.argv) < 4:
    337338        print usage
    338339    else:
    339         mesh_file_name = sys.argv[1]
    340 
    341         meshdic = mesh_file_to_mesh_dictionary(mesh_file_name)
    342         vertex_coordinates = meshdic['generatedpointlist']
    343         triangles = meshdic['generatedtrianglelist']
    344        
    345         d1 = [1.0, 1.0]
    346         d2 = [1.0, 3.0]
    347         d3 = [3.0,1.0]
    348         z1 = 2
    349         z2 = 4
    350         z3 = 4
    351         data_coords = [ d1, d2, d3]
    352         z = [z1, z2, z3]
     340        mesh_file = sys.argv[1]
     341        point_file = sys.argv[2]
     342        mesh_output_file = sys.argv[3]
     343
     344        # load in the .tsh file
     345        mesh_dic = mesh_file_to_mesh_dictionary(mesh_file)
     346        vertex_coordinates = mesh_dic['generatedpointlist']
     347        triangles = mesh_dic['generatedtrianglelist']
     348
     349        # load in the .xya file
     350        point_dict = load_xya_file(point_file)
     351        point_coordinates = point_dict['pointlist']
     352        point_attributes = point_dict['pointattributelist']
     353       
    353354       
    354355        f = fit_to_mesh(vertex_coordinates,
    355356                                      triangles,
    356                                       data_coords,
    357                                       z)
    358         print f
    359        
    360 
    361 
    362 
    363 
    364 
    365 
    366 
    367 
    368 
    369 
    370 
     357                                      point_coordinates,
     358                                      point_attributes)
     359        # convert array to list of lists
     360        mesh_dic['generatedpointattributelist'] = f.tolist()
     361        export_trianglulation_file(mesh_output_file, mesh_dic)
     362        #FIXME  do unit test
     363       
     364       
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
Note: See TracChangeset for help on using the changeset viewer.