Changeset 4659


Ignore:
Timestamp:
Aug 7, 2007, 10:20:18 AM (10 years ago)
Author:
duncan
Message:

remove the .xya file format.

Location:
anuga_core/source/anuga
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/test_fit.py

    r4590 r4659  
    660660
    661661        #Fit surface to mesh
    662         interp = Fit(points, triangles,
    663                                alpha=0.0) #,
    664                                # mesh_origin = mesh_origin)
    665 
    666         f1 = interp.fit(data_points1,z) #Fitted values at vertices (using same z as before)
     662        interp = Fit(points, triangles, alpha=0.0)
     663        #Fitted values at vertices (using same z as before)
     664        f1 = interp.fit(data_points1,z)
    667665
    668666        assert allclose(f,f1), 'Fit should have been unaltered'
     
    752750        export_mesh_file(mesh_file,mesh_dic)
    753751
    754         # create an .xya file
    755         point_file = tempfile.mktemp(".xya")
     752        # create a points .csv file
     753        point_file = tempfile.mktemp(".csv")
    756754        fd = open(point_file,'w')
    757         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")
     755        fd.write("x,y, elevation, stage \n\
     756        1.0, 1.0,2.,4 \n\
     757        1.0, 3.0,4,8 \n\
     758        3.0,1.0,4.,8 \n")
    758759        fd.close()
    759760
     
    808809        export_mesh_file(mesh_file,mesh_dic)
    809810
    810         # create an .xya file
    811         point_file = tempfile.mktemp(".xya")
     811        # create a points .csv file
     812        point_file = tempfile.mktemp(".csv")
    812813        fd = open(point_file,'w')
    813         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")
     814        fd.write("x,y, elevation, stage \n\
     815        1.0, 1.0,2.,4 \n\
     816        1.0, 3.0,4,8 \n\
     817        3.0,1.0,4.,8 \n")
    814818        fd.close()
    815 
     819       
    816820        mesh_output_file = tempfile.mktemp(".tsh")
    817821        fit_to_mesh_file(mesh_file,
     
    825829              [5.0, 10.0],
    826830              [5.0,10.0]]
    827         assert allclose(mesh_dic['vertex_attributes'],ans)
    828 
    829         self.failUnless(mesh_dic['vertex_attribute_titles']  ==
    830                         ['elevation','stage'],
    831                         'test_fit_to_mesh_file failed')
    832 
    833         #clean up
    834         os.remove(mesh_file)
    835         os.remove(point_file)
    836         os.remove(mesh_output_file)
    837 
    838     def test_fit_to_mesh_file4(self):
    839         from load_mesh.loadASCII import import_mesh_file, \
    840              export_mesh_file
    841         import tempfile
    842         import os
    843 
    844         # create a .tsh file, no user outline
    845         mesh_dic = {}
    846         mesh_dic['vertices'] = [[0.76, 0.76],
    847                                 [0.76, 5.76],
    848                                 [5.76, 0.76]]
    849         mesh_dic['triangles'] =  [[0, 2, 1]]
    850         mesh_dic['segments'] = [[0, 1], [2, 0], [1, 2]]
    851         mesh_dic['triangle_tags'] = ['']
    852         mesh_dic['vertex_attributes'] = [[], [], []]
    853         mesh_dic['vertiex_attribute_titles'] = []
    854         mesh_dic['triangle_neighbors'] = [[-1, -1, -1]]
    855         mesh_dic['segment_tags'] = ['external',
    856                                     'external',
    857                                     'external']
    858         mesh_dic['geo_reference'] = Geo_reference(56,-0.76,-0.76)
    859         mesh_file = tempfile.mktemp(".tsh")
    860         export_mesh_file(mesh_file,mesh_dic)
    861 
    862         geo_ref = Geo_reference(56,-200,-400)
    863         # create an .xya file
    864         point_file = tempfile.mktemp(".xya")
    865         fd = open(point_file,'w')
    866         fd.write("elevation, stage \n 201.0, 401.0,2.,4 \n 201.0, 403.0,4,8 \n 203.0, 401.0,4.,8 \n")
    867         geo_ref.write_ASCII(fd)
    868         fd.close()
    869 
    870         mesh_output_file = tempfile.mktemp(".tsh")
    871         fit_to_mesh_file(mesh_file,
    872                          point_file,
    873                          mesh_output_file,
    874                          alpha = 0.0)
    875         # load in the .tsh file we just wrote
    876         mesh_dic = import_mesh_file(mesh_output_file)
    877         #print "mesh_dic",mesh_dic
    878         ans =[[0.0, 0.0],
    879               [5.0, 10.0],
    880               [5.0, 10.0]]
    881831        assert allclose(mesh_dic['vertex_attributes'],ans)
    882832
     
    913863        export_mesh_file(mesh_file,mesh_dic)
    914864
    915         # create an .xya file
    916         point_file = tempfile.mktemp(".xya")
     865        # create a points .csv file
     866        point_file = tempfile.mktemp(".csv")
    917867        fd = open(point_file,'w')
    918         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")
     868        fd.write("x,y,elevation, stage \n\
     869        1.0, 1.0,2.,4 \n\
     870        1.0, 3.0,4,8 \n\
     871        3.0,1.0,4.,8 \n")
    919872        fd.close()
    920873
     
    959912        export_mesh_file(mesh_file,mesh_dic)
    960913
    961         # create an .xya file
    962         point_file = tempfile.mktemp(".xya")
     914        # create a bad points .csv file
     915        point_file = tempfile.mktemp(".csv")
    963916        fd = open(point_file,'w')
    964         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")
     917        fd.write("x,y,elevation stage \n\
     918        1.0, 1.0,2.,4 \n\
     919        1.0, 3.0,4,8 \n\
     920        3.0,1.0,4.,8 \n")
    965921        fd.close()
    966922
     
    969925            fit_to_mesh_file(mesh_file, point_file,
    970926                             mesh_output_file, display_errors = False)
    971         except IOError:
     927        except SyntaxError:
    972928            pass
    973929        else:
     
    990946        fd.close()
    991947
    992         # create an .xya file
    993         point_file = tempfile.mktemp(".xya")
     948        # create a points .csv file
     949        point_file = tempfile.mktemp(".csv")
    994950        fd = open(point_file,'w')
    995         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")
     951        fd.write("x,y,elevation, stage \n\
     952        1.0, 1.0,2.,4 \n\
     953        1.0, 3.0,4,8 \n\
     954        3.0,1.0,4.,8 \n")
    996955        fd.close()
    997956
     
    1027986        export_mesh_file(mesh_file,mesh_dic)
    1028987
    1029         # create an .xya file
    1030         point_file = tempfile.mktemp(".xya")
     988
     989        # create a points .csv file
     990        point_file = tempfile.mktemp(".csv")
    1031991        fd = open(point_file,'w')
    1032         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")
     992        fd.write("x,y,elevation, stage \n\
     993        1.0, 1.0,2.,4 \n\
     994        1.0, 3.0,4,8 \n\
     995        3.0,1.0,4.,8 \n")
    1033996        fd.close()
    1034997
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4642 r4659  
    102102            2.7, 2.4, 5.2, 0.3
    103103
    104         The first two columns are always  assumed to be x, y
     104        The first two columns have to be x, y or lat, long
    105105        coordinates.
    106106     
    107         An issue with the xya format is that the attribute column order
    108         is not be controlled.  The info is stored in a dictionary and it's
    109         written in an order dependent on the hash order
    110107       
    111108        The format for a Points dictionary is:
     
    177174            self.set_default_attribute_name(default_attribute_name)
    178175
    179 
    180         #Why?   
    181         #assert self.attributes is None or isinstance(self.attributes, DictType)
    182         #This is a hassle when blocking, so I've removed it.
    183 
    184 
    185176        if verbose is True:
    186177            if file_name is not None:
     
    515506
    516507    def import_points_file(self, file_name, delimiter=None, verbose=False):
    517         """ load an .txt, .csv or .xya or .pts file
    518         Note: will throw an IOError if it can't load the file.
     508        """ load an .txt, .csv or .pts file
     509        Note: will throw an IOError/SyntaxError if it can't load the file.
    519510        Catch these!
    520511
     
    527518       
    528519        attributes = {}
    529         if file_name[-4:]== ".xya":
    530             # Maybe not phase-out, so we can load in geo-ref info
    531             #msg = 'Text file format is moving to comma seperated .txt files.'
    532             #warn(msg, DeprecationWarning)
    533             try:
    534                 if delimiter == None:
    535                     try:
    536                         fd = open(file_name)
    537                         data_points, attributes, geo_reference =\
    538                                      _read_xya_file(fd, ',')
    539                     except TitleError:
    540                         fd.close()
    541                         fd = open(file_name)
    542                         data_points, attributes, geo_reference =\
    543                                      _read_xya_file(fd, ' ')
    544                 else:
    545                     fd = open(file_name)
    546                     data_points, attributes, geo_reference =\
    547                                  _read_xya_file(fd, delimiter)
    548                 fd.close()
    549             except (IndexError,ValueError,SyntaxError):
    550                 fd.close()   
    551                 msg = 'Could not open file %s ' %file_name
    552                 msg += 'Check the file location.'
    553                 raise IOError, msg
    554             except IOError, e:
    555                 fd.close() 
    556                 # Catch this to add an error message
    557                 msg = 'Could not open file or incorrect file format %s:%s'\
    558                       %(file_name, e)
    559                 raise IOError, msg
    560                
    561         elif file_name[-4:]== ".pts":
     520        if file_name[-4:]== ".pts":
    562521            try:
    563522                data_points, attributes, geo_reference =\
     
    614573        """
    615574
    616         if absolute is False and file_name[-4:] == ".xya":
    617             msg = 'The text file values must be absolute.   '
    618             msg += 'Text file format is moving to comma seperated .txt files.'
    619             warn(msg, DeprecationWarning)
    620 
    621         if (file_name[-4:] == ".xya"):
    622             msg = '.xya format is deprecated.  Please use .txt.'
    623             warn(msg, DeprecationWarning)
    624             if absolute is True:     
    625                 geo_ref = deepcopy(self.geo_reference)
    626                 geo_ref.xllcorner = 0
    627                 geo_ref.yllcorner = 0   
    628                 _write_xya_file(file_name,
    629                                 self.get_data_points(absolute=True),
    630                                 self.get_all_attributes(),
    631                                 geo_ref)
    632             else:
    633                 _write_xya_file(file_name,
    634                                 self.get_data_points(absolute=False),
    635                                 self.get_all_attributes(),
    636                                 self.get_geo_reference())
    637                                    
    638         elif (file_name[-4:] == ".pts"):
     575        if (file_name[-4:] == ".pts"):
    639576            if absolute is True:
    640577                geo_ref = deepcopy(self.geo_reference)
     
    699636   
    700637    def split(self, factor=0.5, verbose=False):
    701         """Returns two geospatial_data object, first is the size of the 'factor'
    702         smaller the original and the second is the remainder. The two new
    703         object are disjoin set of each other.
     638        """Returns two
     639        geospatial_data object, first is the size of the 'factor'
     640        smaller the original and the second is the remainder. The two
     641        new object are disjoin set of each other.
    704642       
    705643        Points of the two new object have selected RANDOMLY.
    706644        AND if factor is a decimal it will round (2.25 to 2 and 2.5 to 3)
    707645       
    708         This method create two lists of indices which are passed into get_sample.
    709         The lists are created using random numbers, and they are unique sets eg.
    710         total_list(1,2,3,4,5,6,7,8,9)  random_list(1,3,6,7,9) and remainder_list(0,2,4,5,8)
     646        This method create two lists of indices which are passed into
     647        get_sample.  The lists are created using random numbers, and
     648        they are unique sets eg.  total_list(1,2,3,4,5,6,7,8,9)
     649        random_list(1,3,6,7,9) and remainder_list(0,2,4,5,8)
    711650               
    712651        Input - the factor which to split the object, if 0.1 then 10% of the
    713             object will be returned
     652together             object will be returned
    714653       
    715654        Output - two geospatial_data objects that are disjoint sets of the
     
    747686        k=1
    748687        remainder_list = total_list[:]
    749         #pops array index (random_num) from remainder_list (which starts as the
     688        #pops array index (random_num) from remainder_list
     689        # (which starts as the
    750690        #total_list and appends to random_list 
    751691        random_num_len = len(random_num)
     
    765705        test_total.extend(remainder_list)
    766706        test_total.sort()
    767         msg = 'The two random lists made from the original list when added together '\
    768          'DO NOT equal the original list'
     707        msg = 'The two random lists made from the original list when added '\
     708         'together DO NOT equal the original list'
    769709        assert (total_list==test_total),msg
    770710
     
    791731            self.max_read_lines = MAX_READ_LINES
    792732       
    793 
    794         if self.file_name[-4:] == ".xya":
    795             # FIXME (Ole): shouldn't the xya format be replaced by txt/csv?
    796             #  Currently both file formats are used.
    797 
    798             # FIXME (Ole): This has to go - it caused Ted Rigby to waste
    799             # time trying to read in his data in xya format with an
    800             # inevitable memory error appearing.
    801            
    802             #let's just read it all
    803             msg = 'The xya format is deprecated. Use csv or pts.'
    804             warn(msg, DeprecationWarning)             
    805            
    806         elif self.file_name[-4:] == ".pts":
     733        if self.file_name[-4:] == ".pts":
    807734           
    808735            # see if the file is there.  Throw a QUIET IO error if it isn't
     
    846773        """ read a block, instanciate a new geospatial and return it"""
    847774       
    848         if self.file_name[-4:]== ".xya" :
    849             # FIXME (Ole): shouldn't the xya format be replaced by txt/csv?
    850             #  Currently both file formats are used.
    851            
    852             if not hasattr(self,'finished_reading') or \
    853                    self.finished_reading is False:
    854                 #let's just read it all
    855                 geo = Geospatial_data(self.file_name)
    856                 self.finished_reading = True
    857             else:
    858                 raise StopIteration
    859                 self.finished_reading = False
    860                
    861         elif self.file_name[-4:] == ".pts":
     775        if self.file_name[-4:] == ".pts":
    862776            if self.start_row == self.last_row:
    863777                # read the end of the file last iteration
     
    12061120    return pointlist, attributes
    12071121   
    1208    
    1209 def _read_xya_file(fd, delimiter):
    1210     points = []
    1211     pointattributes = []
    1212     title = fd.readline()
    1213     att_names = clean_line(title,delimiter)
    1214     att_dict = {}
    1215     line = fd.readline()
    1216     numbers = clean_line(line,delimiter)
    1217    
    1218     while len(numbers) > 1 and line[0] <> '#':
    1219         if numbers != []:
    1220             try:
    1221                 x = float(numbers[0])
    1222                 y = float(numbers[1])
    1223                 points.append([x,y])
    1224                 numbers.pop(0)
    1225                 numbers.pop(0)
    1226                 if len(att_names) != len(numbers):
    1227                     fd.close()
    1228                     # It might not be a problem with the title
    1229                     #raise TitleAmountError
    1230                     raise IOError
    1231                 for i,num in enumerate(numbers):
    1232                     num.strip()
    1233                     if num != '\n' and num != '':
    1234                         #attributes.append(float(num))
    1235                         att_dict.setdefault(att_names[i],[]).append(float(num))
    1236             except ValueError:
    1237                 raise SyntaxError
    1238         line = fd.readline()
    1239         numbers = clean_line(line,delimiter)
    1240    
    1241     if line == '':
    1242         geo_reference = None
    1243     else:
    1244         geo_reference = Geo_reference(ASCIIFile=fd,read_title=line)
    1245        
    1246    
    1247     pointlist = array(points).astype(Float)
    1248     for key in att_dict.keys():
    1249         att_dict[key] = array(att_dict[key]).astype(Float)
    1250    
    1251     return pointlist, att_dict, geo_reference
    1252 
    12531122def _write_pts_file(file_name,
    12541123                    write_data_points,
     
    13031172    outfile.close()
    13041173 
    1305 
    1306 
    1307 def _write_xya_file(file_name,
    1308                     write_data_points,
    1309                     write_attributes=None,
    1310                     write_geo_reference=None,
    1311                     delimiter=','):
    1312     """
    1313     export a file, file_name, with the xya format
    1314    
    1315     """
    1316     points = write_data_points
    1317     pointattributes = write_attributes
    1318    
    1319     fd = open(file_name,'w')
    1320     titlelist = ""
    1321     if pointattributes is not None:   
    1322         for title in pointattributes.keys():
    1323             titlelist = titlelist + title + delimiter
    1324         titlelist = titlelist[0:-len(delimiter)] # remove the last delimiter
    1325     fd.write(titlelist+"\n")
    1326    
    1327     #<vertex #> <x> <y> [attributes]
    1328     for i, vert in enumerate( points):
    1329 
    1330 
    1331         if pointattributes is not None:           
    1332             attlist = ","
    1333             for att in pointattributes.keys():
    1334                 attlist = attlist + str(pointattributes[att][i])+ delimiter
    1335             attlist = attlist[0:-len(delimiter)] # remove the last delimiter
    1336             attlist.strip()
    1337         else:
    1338             attlist = ''
    1339 
    1340         fd.write(str(vert[0]) + delimiter +
    1341                  str(vert[1]) + attlist + "\n")
    1342 
    1343     if  write_geo_reference is not None:
    1344         write_geo_reference = ensure_geo_reference(write_geo_reference)
    1345         write_geo_reference.write_ASCII(fd)
    1346     fd.close()
    1347 
    1348 
    13491174def _write_csv_file(file_name,
    13501175                    write_data_points,
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4641 r4659  
    1313from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees
    1414from anuga.utilities.anuga_exceptions import ANUGAError
    15 # Ignore these warnings, since we still want to test .xya code.
    16 import warnings
    17 warnings.filterwarnings(action = 'ignore',
    18                         message='.xya format is deprecated.  Please use .txt.',
    19                         category=DeprecationWarning)
    20 
    21 warnings.filterwarnings(action = 'ignore',
    22                         message='The text file values must be ab',
    23                         category=DeprecationWarning)
    24 
    25 warnings.filterwarnings(action = 'ignore',
    26                         message='Text file format is moving to comma se',
    27                         category=DeprecationWarning)
    28 
    29 warnings.filterwarnings(action = 'ignore',
    30                         message='Specifying delimiters will be removed.',
    31                         category=DeprecationWarning)
    3215
    3316class Test_Geospatial_data(unittest.TestCase):
    3417    def setUp(self):
    35         import warnings
    36         warnings.filterwarnings(action = 'ignore',
    37                                 message='.xya format is deprecated.  Please use .txt.',
    38                                 category=DeprecationWarning)
    39        
    40         warnings.filterwarnings(action = 'ignore',
    41                                 message='The text file values must be ab',
    42                                 category=DeprecationWarning)
    43    
    44         warnings.filterwarnings(action = 'ignore',
    45                                 message='Text file format is moving to comma se',
    46                                 category=DeprecationWarning)
    47    
    48         warnings.filterwarnings(action = 'ignore',
    49                                 message='Specifying delimiters will be removed.',
    50                                 category=DeprecationWarning)
     18        pass
    5119
    5220    def tearDown(self):
     
    772740
    773741       
    774     def test_create_from_xya_file(self):
    775         """Check that object can be created from a points file (.pts and .xya)
    776         """
    777 
    778         points = [[1.0, 2.1], [3.0, 5.3], [5.0, 6.1], [6.0, 3.3]]
    779         attributes = [2, 4, 5, 76]
    780         '''
    781         # Use old pointsdict format
    782         pointsdict = {'pointlist': points,
    783                       'attributelist': {'att1': attributes,
    784                                         'att2': array(attributes) + 1}}
    785         '''
    786         att_dict = {'att1': attributes,
    787                     'att2': array(attributes) +1}
    788                    
    789         # Create points as an xya file
    790         FN = 'test_points.xya'
    791         G1 = Geospatial_data(points, att_dict)
    792         G1.export_points_file(FN)
    793 #        G1.export_points_file(ofile)
    794 
    795         #Create object from file
    796         G = Geospatial_data(file_name = FN)
    797        
    798         assert allclose(G.get_data_points(), points)
    799         assert allclose(G.get_attributes('att1'), attributes)
    800         assert allclose(G.get_attributes('att2'), array(attributes) + 1)
    801        
    802         os.remove(FN)
    803 
    804     def test_create_from_xya_file1(self):
    805         """
    806         Check that object can be created from an Absolute xya file
    807         """
    808 
    809         points = [[1.0, 2.1], [3.0, 5.3], [5.0, 6.1], [6.0, 3.3]]
    810         attributes = [2, 4, 5, 76]
    811 
    812         att_dict = {'att1': attributes,
    813                     'att2': array(attributes) +1}
    814 
    815         geo_ref = Geo_reference(56, 10, 5)
    816                    
    817         # Create points as an xya file
    818         FN = 'test_points.xya'
    819         G1 = Geospatial_data(points, att_dict, geo_ref)
    820 
    821         G1.export_points_file(FN, absolute=True)
    822 
    823         #Create object from file
    824         G = Geospatial_data(file_name = FN)
    825        
    826         assert allclose(G.get_data_points(absolute=True),
    827                         G1.get_data_points(absolute=True))
    828         assert allclose(G.get_attributes('att1'), attributes)
    829         assert allclose(G.get_attributes('att2'), array(attributes) + 1)
    830        
    831         os.remove(FN)
    832    
    833742    def test_load_csv(self):
    834743       
     
    844753        file.close()
    845754        #print fileName
    846         results = Geospatial_data(fileName, delimiter=',')
     755        results = Geospatial_data(fileName)
    847756        os.remove(fileName)
    848757#        print 'data', results.get_data_points()
     
    853762        assert allclose(results.get_attributes(attribute_name='speed'),
    854763                        [0.0, 10.0, 40.0])
    855 
    856        
    857     def test_load_xya(self):
    858         """ test_load_xya(self):
    859         comma delimited
    860         """
    861         fileName = tempfile.mktemp(".xya")
    862         file = open(fileName,"w")
    863         file.write("elevation  , speed \n\
    864 1.0, 0.0, 10.0, 0.0\n\
    865 0.0, 1.0, 0.0, 10.0\n\
    866 1.0, 0.0, 10.4, 40.0\n")
    867         file.close()
    868         results = Geospatial_data(fileName, delimiter=',')
    869         os.remove(fileName)
    870 #        print 'data', results.get_data_points()
    871         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    872         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    873         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    874 
    875     def test_loadxya2(self):
    876         """ test_loadxya2(self):
    877         space delimited
    878         """
    879         import os
    880        
    881         fileName = tempfile.mktemp(".xya")
    882         file = open(fileName,"w")
    883         file.write("  elevation   speed \n\
    884 1.0 0.0 10.0 0.0\n\
    885 0.0 1.0 0.0 10.0\n\
    886 1.0 0.0 10.4 40.0\n")
    887         file.close()
    888 
    889         results = Geospatial_data(fileName, delimiter=' ')
    890 
    891         os.remove(fileName)
    892 
    893         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    894         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    895         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    896      
    897     def test_loadxya3(self):
    898         """
    899         test_loadxya3(self):
    900         space delimited
    901         """
    902         import os
    903        
    904         fileName = tempfile.mktemp(".xya")
    905         file = open(fileName,"w")
    906         file.write("  elevation   speed \n\
    907 1.0 0.0 10.0 0.0\n\
    908 0.0 1.0 0.0 10.0\n\
    909 1.0 0.0 10.4 40.0\n\
    910 #geocrap\n\
    911 56\n\
    912 56.6\n\
    913 3\n")
    914         file.close()
    915 
    916         results = Geospatial_data(fileName, delimiter=' ')
    917 
    918         os.remove(fileName)
    919         assert allclose(results.get_data_points(absolute=False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    920         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    921         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    922 
    923     def BADtest_loadxya4(self):
    924         """
    925         comma delimited
    926         """
    927         fileName = tempfile.mktemp(".xya")
    928         file = open(fileName,"w")
    929         file.write("elevation  , speed \n\
    930 1.0, 0.0, splat, 0.0\n\
    931 0.0, 1.0, 0.0, 10.0\n\
    932 1.0, 0.0, 10.4, 40.0\n")
    933         file.close()
    934         results = Geospatial_data(fileName, delimiter=',')
    935         os.remove(fileName)
    936 #        print 'data', results.get_data_points()
    937         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    938         assert allclose(results.get_attributes(attribute_name='elevation'), ["splat", 0.0, 10.4])
    939         assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
    940        
    941     def test_read_write_points_file_bad2(self):
    942         att_dict = {}
    943         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    944         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    945         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    946         geo_reference=Geo_reference(56,1.9,1.9)
    947        
    948         G = Geospatial_data(pointlist, att_dict, geo_reference)
    949        
    950         try:
    951             G.export_points_file("_???/yeah.xya")
    952            
    953         except IOError:
    954             pass
    955         else:
    956             msg = 'bad points file extension did not raise error!'
    957             raise msg
    958 #            self.failUnless(0 == 1,
    959 #                        'bad points file extension did not raise error!')
    960                    
    961     def test_loadxy_bad(self):
    962         import os
    963        
    964         fileName = tempfile.mktemp(".xya")
    965         file = open(fileName,"w")
    966         file.write("  elevation   \n\
    967 1.0 0.0 10.0 0.0\n\
    968 0.0 1.0 0.0 10.0\n\
    969 1.0 0.0 10.4 40.0\n")
    970         file.close()
    971         #print fileName
    972         try:
    973             results = Geospatial_data(fileName, delimiter=' ')
    974         except IOError:
    975             pass
    976         else:
    977             msg = 'bad xya file did not raise error!'
    978             raise msg
    979 #            self.failUnless(0 == 1,
    980 #                        'bad xya file did not raise error!')
    981         os.remove(fileName)
    982        
    983     def test_loadxy_bad2(self):
    984         import os
    985        
    986         fileName = tempfile.mktemp(".xya")
    987         file = open(fileName,"w")
    988         file.write("elevation\n\
    989 1.0 0.0 10.0 \n\
    990 0.0 1.0\n\
    991 1.0 \n")
    992         file.close()
    993         #print fileName
    994         try:
    995             results = Geospatial_data(fileName, delimiter=' ')
    996         except IOError:
    997             pass
    998         else:
    999             msg = 'bad xya file did not raise error!'
    1000             raise msg
    1001         os.remove(fileName)
    1002    
    1003     def test_loadxy_bad3(self):
    1004         """ test_loadxy_bad3(self):
    1005         specifying wrong delimiter
    1006         """
    1007         import os
    1008        
    1009         fileName = tempfile.mktemp(".xya")
    1010         file = open(fileName,"w")
    1011         file.write("  elevation  , speed \n\
    1012 1.0, 0.0, 10.0, 0.0\n\
    1013 0.0, 1.0, 0.0, 10.0\n\
    1014 1.0, 0.0, 10.4, 40.0\n")
    1015         file.close()
    1016         try:
    1017             results = Geospatial_data(fileName, delimiter=' ')
    1018         except IOError:
    1019             pass
    1020         else:
    1021             msg = 'bad xya file did not raise error!'
    1022             raise msg
    1023         os.remove(fileName)
    1024      
    1025     def test_loadxy_bad4(self):
    1026         """ test_loadxy_bad4(self):
    1027          specifying wrong delimiter
    1028         """
    1029         import os
    1030         fileName = tempfile.mktemp(".xya")
    1031         file = open(fileName,"w")
    1032         file.write("  elevation   speed \n\
    1033 1.0 0.0 10.0 0.0\n\
    1034 0.0 1.0 0.0 10.0\n\
    1035 1.0 0.0 10.4 40.0\n\
    1036 #geocrap\n\
    1037 56\n\
    1038 56.6\n\
    1039 3\n"
    1040 )
    1041         file.close()
    1042         try:
    1043             results = Geospatial_data(fileName, delimiter=',')
    1044         except IOError:
    1045             pass
    1046         else:
    1047             msg = 'bad xya file did not raise error!'
    1048             raise msg
    1049 
    1050         os.remove(fileName)
    1051 
    1052     def test_loadxy_bad5(self):
    1053         """ test_loadxy_bad5(self):
    1054         specifying wrong delimiter
    1055         """
    1056         import os
    1057        
    1058         fileName = tempfile.mktemp(".xya")
    1059         file = open(fileName,"w")
    1060         file.write("  elevation   speed \n\
    1061 1.0 0.0 10.0 0.0\n\
    1062 0.0 1.0 0.0 10.0\n\
    1063 1.0 0.0 10.4 40.0\n\
    1064 #geocrap\n\
    1065 crap")
    1066         file.close()
    1067         try:
    1068 #            dict = import_points_file(fileName,delimiter=' ')
    1069 #            results = Geospatial_data()
    1070             results = Geospatial_data(fileName, delimiter=' ', verbose=False)
    1071 #            results.import_points_file(fileName, delimiter=' ')
    1072         except IOError:
    1073             pass
    1074         else:
    1075             msg = 'bad xya file did not raise error!'
    1076             raise msg
    1077 
    1078 #            self.failUnless(0 ==1,
    1079 #                        'bad xya file did not raise error!')   
    1080         os.remove(fileName)             
    1081 
    1082     def test_loadxy_bad_no_file_xya(self):
    1083         import os
    1084        
    1085         fileName = tempfile.mktemp(".xya")
    1086         try:
    1087             results = Geospatial_data(fileName, delimiter=' ')
    1088         except IOError:
    1089             pass
    1090         else:
    1091             msg = 'imaginary file did not raise error!'
    1092             raise msg
    1093 
    1094 #        except IOError:
    1095 #            pass
    1096 #        else:
    1097 #            self.failUnless(0 == 1,
    1098 #                        'imaginary file did not raise error!')
    1099764
    1100765
     
    14041069       
    14051070       
    1406     def test_export_xya_file(self):
    1407         # depreciated since it's testing using geo refs in a text file
    1408 #        dict = {}
    1409         att_dict = {}
    1410         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1411         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1412         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1413 #        dict['attributelist'] = att_dict
    1414         geo_reference=Geo_reference(56,1.9,1.9)
    1415        
    1416        
    1417         fileName = tempfile.mktemp(".xya")
    1418         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1419         G.export_points_file(fileName, False)
    1420 
    1421 #        dict2 = import_points_file(fileName)
    1422         results = Geospatial_data(file_name = fileName)
    1423         #print "fileName",fileName
    1424         os.remove(fileName)
    1425        
    1426         assert allclose(results.get_data_points(absolute=False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1427         assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
    1428         answer = [10.0, 0.0, 10.4]
    1429         assert allclose(results.get_attributes(attribute_name='brightness'), answer)
    1430         #print "dict2['geo_reference']",dict2['geo_reference']
    1431         self.failUnless(results.get_geo_reference() == geo_reference,
    1432                          'test_writepts failed. Test geo_reference')
    1433 
    1434     def test_export_xya_file2(self):
    1435         """ test_export_xya_file2(self):
    1436         test absolute xya file
    1437         """
    1438         att_dict = {}
    1439         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1440         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1441         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1442        
    1443         fileName = tempfile.mktemp(".xya")
    1444         G = Geospatial_data(pointlist, att_dict)
    1445         G.export_points_file(fileName)
    1446         results = Geospatial_data(file_name = fileName)
    1447 #        dict2 = import_points_file(fileName)
    1448         os.remove(fileName)
    1449        
    1450         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1451         assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
    1452         answer = [10.0, 0.0, 10.4]
    1453         assert allclose(results.get_attributes('brightness'), answer)
    1454 
    1455     def test_export_xya_file3(self):
    1456         """ test_export_xya_file3(self):
    1457         test absolute xya file with geo_ref
    1458         """
    1459         att_dict = {}
    1460         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1461         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1462         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1463         geo_reference=Geo_reference(56,1.9,1.9)
    1464        
    1465        
    1466         fileName = tempfile.mktemp(".xya")
    1467         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1468        
    1469         G.export_points_file(fileName, absolute=True)
    1470        
    1471         results = Geospatial_data(file_name = fileName)
    1472         os.remove(fileName)
    1473 
    1474         assert allclose(results.get_data_points(),
    1475                         [[2.9, 1.9],[1.9, 2.9],[2.9, 1.9]])
    1476         assert allclose(results.get_attributes(attribute_name='elevation'),
    1477                          [10.0, 0.0, 10.4])
    1478         answer = [10.0, 0.0, 10.4]
    1479         assert allclose(results.get_attributes(attribute_name='brightness'), answer)
    1480         self.failUnless(results.get_geo_reference() == geo_reference,
    1481                          'test_writepts failed. Test geo_reference')                         
    1482                        
    1483                        
    1484                        
     1071
    14851072    def test_new_export_pts_file(self):
    14861073        att_dict = {}
     
    15851172                         'test_writepts failed. Test geo_reference')
    15861173
    1587     def test_write_xya_attributes(self):
    1588         #test_write xya: Test that storage of x,y,attributes works
     1174    def test_write_csv_attributes(self):
     1175        #test_write : Test that storage of x,y,attributes works
    15891176       
    15901177        att_dict = {}
     
    15931180        att_dict['brightness'] = array([10.0, 0.0, 10.4])
    15941181        geo_reference=Geo_reference(56,0,0)
    1595         # Test xya format
    1596         fileName = tempfile.mktemp(".xya")
    1597         G = Geospatial_data(pointlist, att_dict, geo_reference)
    1598         G.export_points_file(fileName)
    1599         results = Geospatial_data(file_name=fileName)
    1600         os.remove(fileName)
    1601         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1602         assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
    1603         answer = [10.0, 0.0, 10.4]
    1604         assert allclose(results.get_attributes('brightness'), answer)
    1605         self.failUnless(geo_reference == geo_reference,
    1606                          'test_writepts failed. Test geo_reference')
    1607 
    1608     def test_write_csv_attributes(self):
    1609         #test_write : Test that storage of x,y,attributes works
    1610        
    1611         att_dict = {}
    1612         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1613         att_dict['elevation'] = array([10.0, 0.0, 10.4])
    1614         att_dict['brightness'] = array([10.0, 0.0, 10.4])
    1615         geo_reference=Geo_reference(56,0,0)
    1616         # Test xya format
     1182        # Test txt format
    16171183        fileName = tempfile.mktemp(".txt")
    16181184        G = Geospatial_data(pointlist, att_dict, geo_reference)
     
    16661232                         'test_writepts failed. Test geo_reference')
    16671233       
    1668     def test_write_xya_no_attributes(self):
    1669         #test_write xya _no_attributes: Test that storage of x,y alone works
     1234       
     1235    def test_write_csv_no_attributes(self):
     1236        #test_write txt _no_attributes: Test that storage of x,y alone works
    16701237       
    16711238        att_dict = {}
    16721239        pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    16731240        geo_reference=Geo_reference(56,0,0)
    1674         # Test xya format
    1675         fileName = tempfile.mktemp(".xya")
    1676         G = Geospatial_data(pointlist, None, geo_reference)
    1677         G.export_points_file(fileName)
    1678         results = Geospatial_data(file_name=fileName)
    1679         os.remove(fileName)
    1680         assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1681         self.failUnless(geo_reference == geo_reference,
    1682                          'test_writepts failed. Test geo_reference')
    1683 
    1684        
    1685     def test_write_csv_no_attributes(self):
    1686         #test_write xya _no_attributes: Test that storage of x,y alone works
    1687        
    1688         att_dict = {}
    1689         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    1690         geo_reference=Geo_reference(56,0,0)
    1691         # Test xya format
     1241        # Test format
    16921242        fileName = tempfile.mktemp(".txt")
    16931243        G = Geospatial_data(pointlist, None, geo_reference)
     
    18121362    def test_add_(self):
    18131363        '''test_add_(self):
    1814         adds an xya and pts files, reads the files and adds them
     1364        adds an txt and pts files, reads the files and adds them
    18151365           checking results are correct
    18161366        '''
     
    18311381        G2 = Geospatial_data(pointlist2, att_dict2, geo_reference2)
    18321382       
    1833         fileName1 = tempfile.mktemp(".xya")
     1383        fileName1 = tempfile.mktemp(".txt")
    18341384        fileName2 = tempfile.mktemp(".pts")
    18351385
     
    19251475        assert allclose(new_points, ab_points)
    19261476
    1927        
    1928         fileName = tempfile.mktemp(".xya")
    1929         file = open(fileName,"w")
    1930         file.write("  elevation   speed \n\
    1931 1.0 0.0 10.0 0.0\n\
    1932 0.0 1.0 0.0 10.0\n\
    1933 1.0 0.0 10.4 40.0\n\
    1934 #geocrap\n\
    1935 56\n\
    1936 10\n\
    1937 20\n")
    1938         file.close()
    1939        
    1940         ab_points = ensure_absolute(fileName)
    1941         actual =  [[11, 20.0],[10.0, 21.0],[11.0, 20.0]]
    1942         assert allclose(ab_points, actual)
    1943         os.remove(fileName)
    19441477
    19451478       
     
    20101543        import os
    20111544       
    2012         fileName = tempfile.mktemp(".xya")
     1545        fileName = tempfile.mktemp(".csv")
    20131546        file = open(fileName,"w")
    2014         file.write("  elevation   speed \n\
    2015 1.0 0.0 10.0 0.0\n\
    2016 0.0 1.0 0.0 10.0\n\
    2017 1.0 0.0 10.4 40.0\n\
    2018 #geocrap\n\
    2019 56\n\
    2020 56.6\n\
    2021 3\n")
     1547        file.write("x,y,  elevation ,  speed \n\
     15481.0, 0.0, 10.0, 0.0\n\
     15490.0, 1.0, 0.0, 10.0\n\
     15501.0, 0.0, 10.4, 40.0\n")
    20221551        file.close()
    20231552
    20241553        results = Geospatial_data(fileName)
    2025         assert allclose(results.get_data_points(absolute=False), \
     1554        assert allclose(results.get_data_points(absolute=True), \
    20261555                        [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
    20271556        assert allclose(results.get_attributes(attribute_name='elevation'), \
     
    20321561        os.remove(fileName)
    20331562       
    2034     def test_delimiter(self):
    2035        
    2036         try:
    2037             G = Geospatial_data(delimiter=',')
    2038 #            results = Geospatial_data(file_name = fileName)
    2039 #            dict = import_points_file(fileName)
    2040         except ValueError:
    2041             pass
    2042         else:
    2043             msg = 'Instance with No fileName but has a delimiter\
    2044                   did not raise error!'
    2045             raise msg
    20461563
    20471564    def test_no_constructors(self):
     
    20571574            raise msg       
    20581575
    2059     def test_check_geo_reference(self):
    2060         """
    2061         checks geo reference details are OK. eg can be called '#geo reference'
    2062         if not throws a clear error message
    2063         """
    2064         import os
    2065         fileName = tempfile.mktemp(".xya")
    2066         file = open(fileName,"w")
    2067         file.write("  elevation  \n\
    2068 1.0 0.0 10.0\n\
    2069 0.0 1.0 0.0\n\
    2070 1.0 0.0 10.4\n\
    2071 #ge oreference\n\
    2072 56\n\
    2073 1.1\n\
    2074 1.0\n")
    2075 
    2076         file.close()
    2077         results = Geospatial_data(fileName)
    2078         assert allclose(results.get_geo_reference().get_xllcorner(), 1.1)
    2079         assert allclose(results.get_geo_reference().get_yllcorner(), 1.0)
    2080 
    2081         os.remove(fileName)
    2082        
    2083         fileName = tempfile.mktemp(".xya")
    2084         file = open(fileName,"w")
    2085         file.write("  elevation  \n\
    2086 1.0 0.0 10.0\n\
    2087 0.0 1.0 0.0\n\
    2088 1.0 0.0 10.4\n")
    2089 
    2090         file.close()
    2091         results = Geospatial_data(fileName)
    2092        
    2093         os.remove(fileName)
    2094        
    2095     def test_check_geo_reference1(self):
    2096         """
    2097         checks geo reference details are OK. eg can be called '#geo reference'
    2098         if not throws a clear error message
    2099         """
    2100         import os
    2101         fileName = tempfile.mktemp(".xya")
    2102         file = open(fileName,"w")
    2103         file.write("  elevation  \n\
    2104 1.0 0.0 10.0\n\
    2105 0.0 1.0 0.0\n\
    2106 1.0 0.0 10.4\n\
    2107 #geo t t\n\
    2108 56\n\
    2109 1.1\n"
    2110 )
    2111         file.close()
    2112 
    2113         try:
    2114             results = Geospatial_data(fileName, delimiter = " ")
    2115         except IOError:
    2116             pass
    2117         else:
    2118             msg = 'Geo reference data format is incorrect'
    2119             raise msg       
    2120 
    2121 
    2122         os.remove(fileName)
    2123 
    2124 
    21251576    def test_load_csv_lat_long(self):
    21261577        """
     
    21341585150.0,-34,459.126000, 10\n")
    21351586        file.close()
    2136         results = Geospatial_data(fileName, delimiter=',')
     1587        results = Geospatial_data(fileName)
    21371588        os.remove(fileName)
    21381589        points = results.get_data_points()
     
    21551606-34,150.0,459.126000\n")
    21561607        file.close()
    2157         results = Geospatial_data(fileName, delimiter=',')
     1608        results = Geospatial_data(fileName)
    21581609        os.remove(fileName)
    21591610        points = results.get_data_points()
     
    21771628        file.close()
    21781629        try:
    2179             results = Geospatial_data(fileName, delimiter=',')
     1630            results = Geospatial_data(fileName)
    21801631        except ANUGAError:
    21811632            pass
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4631 r4659  
    600600
    601601    def test_dem2pts_bounding_box_v2(self):
    602         """Test conversion from dem in ascii format to native NetCDF xya format
     602        """Test conversion from dem in ascii format to native NetCDF format
    603603        """
    604604
     
    714714
    715715    def test_dem2pts_bounding_box_removeNullvalues_v2(self):
    716         """Test conversion from dem in ascii format to native NetCDF xya format
     716        """Test conversion from dem in ascii format to native NetCDF format
    717717        """
    718718
     
    844844
    845845    def test_dem2pts_bounding_box_removeNullvalues_v3(self):
    846         """Test conversion from dem in ascii format to native NetCDF xya format
     846        """Test conversion from dem in ascii format to native NetCDF format
    847847        Check missing values on clipping boundary
    848848        """
     
    40204020
    40214021    def test_read_asc(self):
    4022         """Test conversion from dem in ascii format to native NetCDF xya format
     4022        """Test conversion from dem in ascii format to native NetCDF format
    40234023        """
    40244024
     
    50255025########## testing nbed class ##################
    50265026    def test_exposure_csv_loading(self):
    5027         file_name = tempfile.mktemp(".xya")
     5027        file_name = tempfile.mktemp(".csv")
    50285028        file = open(file_name,"w")
    50295029        file.write("LATITUDE, LONGITUDE ,sound  , speed \n\
     
    50455045       
    50465046
    5047         file_name = tempfile.mktemp(".xya")
     5047        file_name = tempfile.mktemp(".txt")
    50485048        file = open(file_name,"w")
    50495049        file.write("LATITUDE, LONGITUDE ,sound  , speed \n\
     
    50685068        if sys.platform == 'win32':
    50695069            file_name = tempfile.gettempdir() + \
    5070                     "test_exposure_csv_loading_title_check_list.xya"
     5070                    "test_exposure_csv_loading_title_check_list.csv"
    50715071        else:
    5072             file_name = tempfile.mktemp(".xya")
     5072            file_name = tempfile.mktemp(".csv")
    50735073        file = open(file_name,"w")
    50745074        file.write("LATITUDE, LONGITUDE ,sound  , speed \n\
     
    50885088       
    50895089    def test_exposure_csv_cmp(self):
    5090         file_name = tempfile.mktemp(".xya")
     5090        file_name = tempfile.mktemp(".csv")
    50915091        file = open(file_name,"w")
    50925092        file.write("LATITUDE, LONGITUDE ,sound  , speed \n\
     
    51065106                        'FAILED!')
    51075107       
    5108         file_name = tempfile.mktemp(".xya")
     5108        file_name = tempfile.mktemp(".csv")
    51095109        file = open(file_name,"w")
    51105110        # Note, this has less spaces in the title,
     
    51215121                        'FAILED!')
    51225122       
    5123         file_name = tempfile.mktemp(".xya")
     5123        file_name = tempfile.mktemp(".csv")
    51245124        file = open(file_name,"w")
    51255125        # Note, 40 changed to 44 .
     
    51365136                        'FAILED!')
    51375137       
    5138         file_name = tempfile.mktemp(".xya")
     5138        file_name = tempfile.mktemp(".csv")
    51395139        file = open(file_name,"w")
    51405140        # Note, the first two columns are swapped.
     
    51535153       
    51545154
    5155         file_name = tempfile.mktemp(".xya")
     5155        file_name = tempfile.mktemp(".csv")
    51565156        file = open(file_name,"w")
    51575157        file.write("LATITUDE, LONGITUDE ,sound  , speed \n\
     
    51625162        e1 = Exposure_csv(file_name)
    51635163       
    5164         file_name2 = tempfile.mktemp(".xya")
     5164        file_name2 = tempfile.mktemp(".csv")
    51655165        e1.save(file_name = file_name2)
    51665166        e2 = Exposure_csv(file_name2)
     
    51725172
    51735173    def test_exposure_csv_get_location(self):
    5174         file_name = tempfile.mktemp(".xya")
     5174        file_name = tempfile.mktemp(".csv")
    51755175        file = open(file_name,"w")
    51765176        file.write("LONGITUDE , LATITUDE, sound  , speed \n\
     
    51945194       
    51955195    def test_exposure_csv_set_column_get_column(self):
    5196         file_name = tempfile.mktemp(".xya")
     5196        file_name = tempfile.mktemp(".csv")
    51975197        file = open(file_name,"w")
    51985198        file.write("LONGITUDE , LATITUDE, sound  , speed \n\
     
    52105210                        ' Error!')
    52115211       
    5212         file_name2 = tempfile.mktemp(".xya")
     5212        file_name2 = tempfile.mktemp(".csv")
    52135213        e1.save(file_name = file_name2)
    52145214        e2 = Exposure_csv(file_name2)
     
    52195219
    52205220    def test_exposure_csv_set_column_get_column_error_checking(self):
    5221         file_name = tempfile.mktemp(".xya")
     5221        file_name = tempfile.mktemp(".csv")
    52225222        file = open(file_name,"w")
    52235223        file.write("LONGITUDE , LATITUDE, sound  , speed \n\
     
    52595259        else:
    52605260            self.failUnless(0 ==1,  'Error not thrown error!')
    5261         file_name2 = tempfile.mktemp(".xya")
     5261        file_name2 = tempfile.mktemp(".csv")
    52625262        e1.save(file_name = file_name2)
    52635263        e2 = Exposure_csv(file_name2)
     
    52785278       
    52795279
    5280         file_name = tempfile.mktemp(".xya")
     5280        file_name = tempfile.mktemp(".csv")
    52815281        file = open(file_name,"w")
    52825282        file.write("x, y ,sound  , speed \n\
Note: See TracChangeset for help on using the changeset viewer.