Changeset 355


Ignore:
Timestamp:
Oct 5, 2004, 11:52:23 AM (20 years ago)
Author:
duncan
Message:

move export xya out of mesh, into loadASCII

Location:
inundation/ga/storm_surge/pmesh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py

    r350 r355  
    453453    return xya_dict
    454454
     455               
     456def export_xya_file( file_name, xya_dict, title):
     457    """
     458    export a file, ofile, with the format
     459   
     460    First line: Title variable
     461    Following lines:  <vertex #> <x> <y> [attributes]
     462
     463    file_name - the name of the new file
     464    xya_dict - point and point attribute info in a dictionary
     465    title - info to write in the first line
     466    """
     467    #FIXME, move the test for this from meshharness to loadasciiharness
     468    points = xya_dict['pointlist']
     469    pointattributes = xya_dict['pointattributelist']
     470   
     471    fd = open(file_name,'w')
     472   
     473    fd.write(title+"\n")
     474    #<vertex #> <x> <y> [attributes]
     475    for vert, vertatts in map(None, points, pointattributes):
     476        attlist = ""
     477        for att in vertatts:
     478            attlist = attlist + str(att)+" "
     479        attlist.strip()
     480        fd.write( str(vert[0]) + " "
     481                  + str(vert[1]) + " "
     482                  + attlist + "\n")
     483    fd.close()
     484
    455485if __name__ == "__main__":
    456486    m = import_mesh("tee.txt")
  • inundation/ga/storm_surge/pmesh/mesh.py

    r349 r355  
    15281528        Following lines:  <vertex #> <x> <y> [attributes]
    15291529        """
    1530        
     1530        #load_mesh.loadASCII
     1531
    15311532        if self.meshVertices == []:
    15321533            Vertices = self.userVertices
     
    15381539        if Vertices == []:
    15391540            raise RuntimeError
    1540         fd = open(ofile,'w')
    15411541        numVertAttrib = str(len(Vertices[0].attributes))
    1542         fd.write(numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]" + "\n")
    1543         #Vertices = self.userVertices + self.meshVertices
    1544         #[Vertices, counter]=  self.removeDuplicatedVertices(Vertices)
    1545            
    1546         #<vertex #> <x> <y> [attributes]
     1542        title = numVert + " " + numVertAttrib + " # <vertex #> <x> <y> [attributes]"
     1543
     1544        #Convert the Vertices to pointlist and pointattributelist
     1545        xya_dict = {}
     1546        pointattributes = []
     1547        points = []
     1548       
    15471549        for vert in Vertices:
    1548             attlist = ""
    1549             for att in vert.attributes:
    1550                 attlist = attlist + str(att)+" "
    1551             attlist.strip()
    1552             fd.write( str(vert.x) + " "
    1553                      + str(vert.y) + " "
    1554                      + attlist + "\n")
    1555         fd.close()
     1550            points.append([vert.x,vert.y])
     1551            pointattributes.append(vert.attributes)
     1552           
     1553        xya_dict['pointlist'] = points
     1554        xya_dict['pointattributelist'] = pointattributes
     1555
     1556        load_mesh.loadASCII.export_xya_file(ofile, xya_dict, title)
    15561557
    15571558
  • inundation/ga/storm_surge/pmesh/meshHarness.py

    r349 r355  
    721721        lFile = file.read().split('\n')
    722722        file.close()
     723
     724        #print "**********************"
     725        #print lFile
     726        #print "**********************"
     727       
    723728        os.remove(fileName)
    724729        self.failUnless(lFile[0] == "5 0 # <vertex #> <x> <y> [attributes]" and
Note: See TracChangeset for help on using the changeset viewer.