Changeset 4663


Ignore:
Timestamp:
Aug 7, 2007, 2:20:57 PM (16 years ago)
Author:
duncan
Message:

getting rid of xya more. Cleaning up.

Location:
anuga_core/source/anuga
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r4647 r4663  
    949949
    950950    return texfile, elev_output
    951                          
    952 
    953 
    954 #Fixme - Use geospatial to read this file - it's an xya file
    955 #Need to include other information into this filename, so xya + Name - required for report
     951               
    956952def get_gauges_from_file(filename):
    957953    """ Read in gauge information from file
  • anuga_core/source/anuga/alpha_shape/alpha_shape.py

    r4165 r4663  
    3939   
    4040    Inputs:
    41     point_file: File location of the input file, points format (.xya or .pts)
     41    point_file: File location of the input file, points format (.csv or .pts)
    4242    boundary_file: File location of the generated output file
    4343    alpha: The alpha value can be optionally specified.  If it is not specified
     
    676676    Save the boundary to a file.
    677677
    678     usage: alpha_shape.py point_file.xya boundary_file.bnd [alpha]
     678    usage: alpha_shape.py point_file.csv boundary_file.bnd [alpha]
    679679   
    680680    The alpha value is optional.
     
    682682   
    683683    import os, sys
    684     usage = "usage: %s point_file.xya boundary_file.bnd [alpha]"%os.path.basename(sys.argv[0])
     684    usage = "usage: %s point_file.csv boundary_file.bnd [alpha]"%os.path.basename(sys.argv[0])
    685685    if len(sys.argv) < 3:
    686686        print usage
  • anuga_core/source/anuga/alpha_shape/test_alpha_shape.py

    r3514 r4663  
    173173        import tempfile
    174174
    175         fileName = tempfile.mktemp(".xya")
    176         #(h,fileName) = tempfile.mkstemp(".xya")
     175        fileName = tempfile.mktemp(".csv")
    177176        file = open(fileName,"w")
    178         file.write("\n\
     177        file.write("x,y\n\
    1791780.0, 0.0\n\
    1801791.0, 0.0\n\
  • anuga_core/source/anuga/coordinate_transforms/geo_reference.py

    r4470 r4663  
    1515
    1616DEFAULT_ZONE = -1
    17 TITLE = '#geo reference' + "\n" #this title is referred to in the .xya format
     17TITLE = '#geo reference' + "\n" #this title is referred to in the test format
    1818
    1919DEFAULT_PROJECTION = 'UTM'
     
    149149            print "ANUGA does not correct for differences in units."
    150150       
    151         
     151    ### ASCII files with geo-refs are currently not used   
    152152    def write_ASCII(self, fd):
    153153        fd.write(TITLE)
  • anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r4391 r4663  
    88from geo_reference import *
    99from Numeric import allclose,array
    10 
    11 # Ignore these warnings, since we still want to test .xya code.
    12 import warnings
    13 warnings.filterwarnings(action = 'ignore',
    14                         message='.xya format is deprecated.  Please use .txt.',
    15                         category=DeprecationWarning)
    16 
    17 warnings.filterwarnings(action = 'ignore',
    18                         message='Text file format is moving to comma se',
    19                         category=DeprecationWarning)
    2010
    2111
     
    312302 
    313303    def test_bad_ASCII_title(self):     
    314  # create an .xya file
    315         point_file = tempfile.mktemp(".xya")
     304 # create an text file
     305        point_file = tempfile.mktemp(".xxx")
    316306        fd = open(point_file,'w')
    317307        fd.write("# hey! \n")
     
    388378        self.failUnless(g == new_g, 'test_read_write_ASCII failed')
    389379       
    390     def xxtest_good_title(self):     
    391  # create an .xya file
    392         point_file = tempfile.mktemp(".xya")
     380    def test_good_title(self):     
     381 # create an .xxx file
     382        point_file = tempfile.mktemp(".xxx")
    393383        fd = open(point_file,'w')
    394384        fd.write("#Geo crap \n 56\n ")
     
    402392            fd.close()
    403393            os.remove(point_file)
    404         except TitleError:
     394        except ValueError:
    405395            fd.close()
    406396            os.remove(point_file)
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r4650 r4663  
    316316              List of coordinate pairs [x, y] of
    317317              data points or an nx2 Numeric array or a Geospatial_data object
    318               or filename (txt, csv, pts?)
     318              or points file filename
    319319          z: Single 1d vector or array of data at the point_coordinates.
    320320         
     
    568568                     display_errors = True):
    569569    """
    570     Given a mesh file (tsh) and a point attribute file (xya), fit
     570    Given a mesh file (tsh) and a point attribute file, fit
    571571    point attributes to the mesh and write a mesh file with the
    572572    results.
    573573
    574     Note: the .xya files need titles.  If you want anuga to use the tsh file,
     574    Note: the points file needs titles.  If you want anuga to use the tsh file,
    575575    make sure the title is elevation.
    576576
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r4651 r4663  
    324324    The results are written to a csv file.
    325325
    326     In the future let points be a csv or xya file.
     326    In the future let points be a points file.
    327327    And the user choose the quantities.
    328328
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4661 r4663  
    130130        self.geo_reference=None #create the attribute
    131131        self.file_name = file_name
    132         self.max_read_lines = max_read_lines
     132       
     133        if max_read_lines is None:
     134            self.max_read_lines = MAX_READ_LINES
     135        else:
     136            self.max_read_lines = max_read_lines
    133137
    134138        if file_name is None:
     
    545549       
    546550        """
    547         write a points file, file_name, as a text (.xya) or binary (.pts) file
     551        write a points file, file_name, as a text (.csv) or binary (.pts) file
    548552        file_name is the file name, including the extension
    549553        The point_dict is defined at the top of this file.
     
    715719
    716720        # FIXME (Ole): Shouldn't this go into the constructor?
     721        # This method acts like the constructor when blcoking.
    717722        # ... and shouldn't it be called block_size?
     723        #
    718724        if self.max_read_lines is None:
    719725            self.max_read_lines = MAX_READ_LINES
  • anuga_core/source/anuga/load_mesh/loadASCII.py

    r4496 r4663  
    11"""
    2 The format for a .xya file is:
    3 1st line:     [attribute names]
    4 other lines:  x y [attributes]
    5 
    6 for example:
    7 elevation, friction
    8 0.6, 0.7, 4.9, 0.3
    9 1.9, 2.8, 5, 0.3
    10 2.7, 2.4, 5.2, 0.3
    11 
    12 The first two columns are always implicitly assumed to be x, y coordinates.
    13 Use the same delimiter for the attribute names and the data
    14 
    15 An xya file can optionally end with
    16 #geo reference
    17 56
    18 466600.0
    19 8644444.0
    20 
    21 When the 1st # is the zone,
    22 2nd # the xllcorner and
    23 3rd # the yllcorner
     2
    243The format for a Points dictionary is:
    254
     
    4221    segment_tags : [tag,tag,...] list of strings
    4322    triangles : [(v1,v2,v3), (v4,v5,v6),....] lists of points
    44     triangle_tags: [s1,s2,...] A list of list of strings (probably not neccecary.  a list of string should be ok)
     23    triangle_tags: [s1,s2,...] A list of list of strings (probably not
     24    neccecary.  a list of string should be ok)
    4525    triangle_neighbors: [[t1,t2,t3], [t4,t5,t6],..] lists of triangles
    4626       
     
    5838        is relative. This is optional.
    5939
    60     Points files are .xya for ascii and .pts for NetCDF
     40    Points files are .csv for ascii and .pts for NetCDF
    6141    Mesh files are .tsh for ascii and .msh for NetCDF
    6242
  • anuga_core/source/anuga/pmesh/graphical_mesh_generator.py

    r3514 r4663  
    119119       
    120120        self.menuBar.addmenuitem('File', 'command',
    121                                  'Export ASCII xya file',
    122                                  label='Export ASCII xya file...',
     121                                 'Export ASCII csv file',
     122                                 label='Export ASCII csv file...',
    123123                                 command=self.exportPointsFile)
    124124       
     
    11891189           
    11901190        except SyntaxError:
    1191             #this is assuming that the SyntaxError is thrown in
    1192             #loadxyafile
     1191            # This is assuming that the SyntaxError is thrown in
     1192            # importUngenerateFile
    11931193            showerror('File error',
    11941194                      ofile + ' is not in the correct format.')
     
    12261226        ofile = tkFileDialog.asksaveasfilename(initialdir=self.currentPath,
    12271227                                         filetypes=[("point files",
    1228                                                      "*.xya *.pts"),
     1228                                                     "*.csv *.txt *.pts"),
    12291229                                                ("All Files", "*")])
    12301230        if ofile:
    1231             # .xya is the default file format
    1232             if (ofile[-4:] == ".xya" or ofile[-4:] == ".pts"): 
     1231            # .csv is the default file format
     1232            if (ofile[-4:] == ".csv" or ofile[-4:] == ".pts"): 
    12331233                self.currentFilePathName = ofile
    12341234            else:
    1235                 self.currentFilePathName = ofile + ".xya"
     1235                self.currentFilePathName = ofile + ".csv"
    12361236               
    12371237            try:
     
    12481248        ofile = tkFileDialog.askopenfilename(initialdir=self.currentPath,
    12491249                                             filetypes=[ ("text Mesh", "*.tsh *.msh"),
    1250                                                          ("points", "*.xya *.pts"),
     1250                                                         ("points", "*.csv *.txt *.pts"),
    12511251                                           ("All Files", "*")])
    12521252        if ofile == "":
  • anuga_core/source/anuga/pmesh/mesh.py

    r4458 r4663  
    12141214            del v.dupindex
    12151215        return Vertices,counter
    1216    
     1216
     1217    # FIXME (DSG-DSG) Move this to geospatial
    12171218    def thinoutVertices(self, delta):
    12181219        """Pre-condition: There are no user segments
     
    20152016    def exportPointsFile(self,ofile):
    20162017        """
    2017         export a points (.xya or .pts)  file, ofile.
     2018        export a points file, ofile.
    20182019       
    20192020        """
     
    29993000
    30003001def importMeshFromFile(ofile):
    3001     """returns a mesh object, made from a .xya/.pts or .tsh/.msh file
     3002    """returns a mesh object, made from a points file or .tsh/.msh file
    30023003    Often raises IOError,RuntimeError
    30033004    """
    30043005    newmesh = None
    3005     if (ofile[-4:]== ".xya" or ofile[-4:]== ".pts" or ofile[-4:]== ".txt" or \
     3006    if (ofile[-4:]== ".pts" or ofile[-4:]== ".txt" or \
    30063007        ofile[-4:]== ".csv"):
    30073008        geospatial = Geospatial_data(ofile)
  • anuga_core/source/anuga/pmesh/test_all.py

    r3193 r4663  
    7777
    7878if __name__ == '__main__':
    79 
    80     from os import sep
    81 
    82     #Attempt to compile all extensions
    83     execfile('..' + sep + 'utilities' + sep + 'compile.py')
    84 
    85     #FIXME: Temporary measure
    86     os.chdir('..' + sep + 'utilities')
    87     execfile('compile.py')
    88     os.chdir('..' + sep + 'pmesh')   
     79    # Assume everything is compiled
    8980   
    90     #FIXME: Temporary measure
    91     os.chdir('..' + sep + 'mesh_engine')
    92     execfile('compile.py')
    93     os.chdir('..' + sep + 'pmesh')   
    94    
    95     #os.system('python compile.py')
    96 
    9781    #print regressionTest()
    9882    unittest.main(defaultTest='regressionTest')
  • anuga_core/source/anuga/pmesh/test_mesh.py

    r4165 r4663  
    979979
    980980
    981     def test_loadxy(self):
     981    def test_load_csv(self):
    982982        """
    983         To test the mesh side of loading xya files.
    984         Not the loading of xya files
     983        To test the mesh side of loading csv files.
     984        Not the loading of csv files
    985985        """
    986986        import os
     
    10101010        #                'loadxy, test 5 failed')
    10111011       
    1012     def exportPointsFile(self):
     1012    def test_exportPointsFile(self):
    10131013        a = Vertex (0,0)
    10141014        b = Vertex (0,3)
     
    10311031       
    10321032        fileName = tempfile.mktemp(".txt")
    1033         #fileName = 't.xya'
     1033        #fileName = 't.csv'
    10341034        #os.remove(fileName)
    10351035        m.exportPointsFile(fileName)
     
    10371037        lFile = file.read().split('\n')
    10381038        file.close()
    1039 
    10401039        os.remove(fileName)
    1041         self.failUnless(lFile[0] == "x,y" and
    1042                         lFile[1] == "0,0" and
    1043                         lFile[2] == "0,3" and
    1044                         lFile[3] == "3,3"
     1040        self.failUnless(lFile[0] == "x,y," and
     1041                        lFile[1] == "0.0,0.0" and
     1042                        lFile[2] == "0.0,3.0" and
     1043                        lFile[3] == "3.0,3.0"
    10451044                        ,
    1046                         'exported Ascii xya file is wrong')
    1047         self.failUnless(lFile[4] == "1,2" and
    1048                         lFile[5] == "3,1"
     1045                        'exported Ascii csv file is wrong')
     1046        self.failUnless(lFile[4] == "1.0,2.0" and
     1047                        lFile[5] == "3.0,1.0"
    10491048                        ,
    1050                         'exported Ascii xya file is wrong')
     1049                        'exported Ascii csv file is wrong')
    10511050       
    10521051        # vertex e is outside of the outline, so
    10531052        # it is a loner and it is removed.
    10541053        m.generateMesh("Q", maxArea = 2.1)
    1055         fileName = tempfile.mktemp(".xya")
    1056         #fileName = 't.xya'
     1054        fileName = tempfile.mktemp(".txt")
     1055        #fileName = 't.csv'
    10571056        #m.export_mesh_file('m.tsh')
    10581057        m.exportPointsFile(fileName)
     
    10621061        os.remove(fileName)
    10631062       
    1064         self.failUnless(lFile[0] == "" and
     1063        self.failUnless(lFile[0] == "x,y," and
    10651064                        lFile[1] == "0.0,0.0" and
    10661065                        lFile[2] == "0.0,3.0" and
     
    10681067                        lFile[4] == "1.0,2.0"
    10691068                        ,
    1070                         'exported Ascii xya file is wrong')
     1069                        'exported Ascii csv file is wrong')
    10711070     
    10721071    def to_be_test_lone_vert_in_mesh_gen_c_layer(self):
     
    10921091       
    10931092        fileName = tempfile.mktemp(".csv")
    1094         #fileName = 't.xya'
     1093        #fileName = 't.csv'
    10951094        #os.remove(fileName)
    10961095        m.exportPointsFile(fileName)
     
    11051104                        lFile[3] == "3,3"
    11061105                        ,
    1107                         'exported Ascii xya file is wrong')
     1106                        'exported Ascii csv file is wrong')
    11081107        self.failUnless(lFile[4] == "1,2" and
    11091108                        lFile[5] == "3,1"
    11101109                        ,
    1111                         'exported Ascii xya file is wrong')
     1110                        'exported Ascii csv file is wrong')
    11121111       
    11131112        # vertex e is outside of the outline, so
     
    11151114        m.generateMesh("Q", maxArea = 2.1)
    11161115        fileName = tempfile.mktemp(".csv")
    1117         #fileName = 't.xya'
     1116        #fileName = 't.csv'
    11181117        #m.export_mesh_file('m.tsh')
    11191118        m.exportPointsFile(fileName)
     
    11291128                        lFile[4] == "1.0,2.0"
    11301129                        ,
    1131                         'exported Ascii xya file is wrong')
     1130                        'exported Ascii csv file is wrong')
    11321131       
    11331132    def NOT_test_exportPointsFilefile2(self):
     
    11471146        self.failUnless(lFile[0] == ""
    11481147                        ,
    1149                         'exported Ascii xya file is wrong')
     1148                        'exported Ascii csv file is wrong')
    11501149       
    11511150    def test_strings2ints(self):
     
    23392338if __name__ == "__main__":
    23402339    suite = unittest.makeSuite(meshTestCase,'test')
    2341     #suite = unittest.makeSuite(meshTestCase,'test_exportASCIIsegmentoutlinefile')
    2342     #suite = unittest.makeSuite(meshTestCase,'test_e')
    2343     runner = unittest.TextTestRunner() #verbosity=2)
     2340    #suite = unittest.makeSuite(meshTestCase,'test_exportoutlinefile')
     2341    #suite = unittest.makeSuite(meshTestCase,'test_exportPointsFile')
     2342    runner = unittest.TextTestRunner() # verbosity=2)
    23442343    runner.run(suite)
    23452344   
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4636 r4663  
    1111.tms: Netcdf format for storing time series f(t)
    1212
    13 .xya: ASCII format for storing arbitrary points and associated attributes
     13.csv: ASCII format for storing arbitrary points and associated attributes
    1414.pts: NetCDF format for storing arbitrary points and associated attributes
    1515
     
    18171817            format = 'ers'):
    18181818
    1819     """Read SWW file and convert to Digitial Elevation model format (.asc or .ers)
     1819    """Read SWW file and convert to Digitial Elevation model format
     1820    (.asc or .ers)
    18201821
    18211822    Example (ASC):
     
    18591860
    18601861    import sys
    1861     from Numeric import array, Float, concatenate, NewAxis, zeros, reshape, sometrue
     1862    from Numeric import array, Float, concatenate, NewAxis, zeros, reshape, \
     1863         sometrue
    18621864    from Numeric import array2string
    18631865
    1864     from anuga.utilities.polygon import inside_polygon, outside_polygon, separate_points_by_polygon
    1865     from anuga.abstract_2d_finite_volumes.util import apply_expression_to_dictionary
     1866    from anuga.utilities.polygon import inside_polygon, outside_polygon, \
     1867         separate_points_by_polygon
     1868    from anuga.abstract_2d_finite_volumes.util import \
     1869         apply_expression_to_dictionary
    18661870
    18671871    msg = 'Format must be either asc or ers'
     
    19301934
    19311935
    1932     # FIXME: Refactor using code from Interpolation_function.statistics (in interpolate.py)
     1936    # FIXME: Refactor using code from Interpolation_function.statistics
     1937    # (in interpolate.py)
    19331938    # Something like print swwstats(swwname)
    19341939    if verbose:
Note: See TracChangeset for help on using the changeset viewer.