Changeset 393


Ignore:
Timestamp:
Oct 12, 2004, 4:46:17 PM (20 years ago)
Author:
duncan
Message:

no longer overwriting old vert atts

Location:
inundation/ga/storm_surge/pyvolution
Files:
2 edited

Legend:

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

    r389 r393  
    5858    vertex_coordinates = mesh_dict['generatedpointlist']
    5959    triangles = mesh_dict['generatedtrianglelist']
    60        
     60   
     61    old_point_attributes = mesh_dict['generatedpointattributelist']
     62    old_title_list = mesh_dict['generatedpointattributetitlelist']
     63
     64   
    6165    # load in the .xya file
    6266    point_dict = load_xya_file(point_file)
     
    6468    point_attributes = point_dict['pointattributelist']
    6569    title_string = point_dict['title']
    66     title_list = title_string.split(',') #iffy! Hard coding title delimiter
    67     #print "title_list", title_list   
     70    title_list = title_string.split(',') #iffy! Hard coding title delimiter 
    6871    for i in range(len(title_list)):
    6972        title_list[i] = title_list[i].strip()
     
    7477                    point_attributes,
    7578                    alpha = alpha)
     79   
    7680    # convert array to list of lists
    77     mesh_dict['generatedpointattributelist'] = f.tolist()
    78     mesh_dict['generatedpointattributetitlelist'] = title_list
     81    new_point_attributes = f.tolist()
     82
     83    #FIXME have this overwrite attributes with the same title - DSG
     84    #Put the newer attributes last
     85    if old_title_list <> []:
     86        old_title_list.extend(title_list)
     87        #FIXME can this be done a faster way? - DSG
     88        for i in range(len(old_point_attributes)):
     89            old_point_attributes[i].extend(new_point_attributes[i])
     90         
     91    mesh_dict['generatedpointattributelist'] = old_point_attributes
     92    mesh_dict['generatedpointattributetitlelist'] = old_title_list
     93   
    7994    export_trianglulation_file(mesh_output_file, mesh_dict)
    8095       
  • inundation/ga/storm_surge/pyvolution/test_least_squares.py

    r374 r393  
    567567        mesh_dic['generatedsegmentlist'] = [[0, 1], [2, 0], [1, 2]]
    568568        mesh_dic['generatedtriangleattributelist'] = [['']]
    569         mesh_dic['generatedpointattributelist'] = [[], [], []]
     569        mesh_dic['generatedpointattributelist'] = [[1,2], [1,2], [1,2]]
     570        mesh_dic['generatedpointattributetitlelist'] = ['density', 'temp']
    570571        mesh_dic['generatedtriangleneighborlist'] = [[-1, -1, -1]]
    571572        mesh_dic['generatedsegmentmarkerlist'] = ['external',
     
    578579        point_file = tempfile.mktemp(".xya")
    579580        fd = open(point_file,'w')
    580         fd.write("bed_elevation, stage \n 1.0, 1.0,2.,4 \n 1.0, 3.0,4,8 \n 3.0,1.0,4.,8 \n")
     581        fd.write("elevation, stage \n 1.0, 1.0,2.,4 \n 1.0, 3.0,4,8 \n 3.0,1.0,4.,8 \n")
    581582        fd.close()
    582583       
     
    590591
    591592        assert allclose(mesh_dic['generatedpointattributelist'],
    592                         [[0.0, 0.0], [5.0, 10.0], [5.0,10.0]])
     593                        [[1.0, 2.0,0.0, 0.0],
     594                         [1.0, 2.0,5.0, 10.0],
     595                         [1.0, 2.0,5.0,10.0]])
    593596       
    594597        self.failUnless(mesh_dic['generatedpointattributetitlelist']  ==
    595                         ['bed_elevation','stage'],
     598                        ['density', 'temp','elevation','stage'],
    596599                        'test_fit_to_mesh_file failed')
    597600       
Note: See TracChangeset for help on using the changeset viewer.