Changeset 3336
- Timestamp:
- Jul 14, 2006, 4:47:35 PM (18 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/data_manager.py
r3312 r3336 725 725 LAT_TITLE = 'LATITUDE' 726 726 LONG_TITLE = 'LONGITUDE' 727 X_TITLE = 'x' 728 Y_TITLE = 'y' 727 729 class Exposure_csv: 728 730 def __init__(self,file_name, latitude_title=LAT_TITLE, 729 longitude_title=LONG_TITLE, refine_polygon=None): 731 longitude_title=LONG_TITLE, is_x_y_locations=False, 732 x_title=X_TITLE, y_title=Y_TITLE, 733 refine_polygon=None): 730 734 """ 731 735 This class is for handling the exposure csv file. … … 777 781 self._geospatial = Geospatial_data(latitudes = lats, 778 782 longitudes = longs) 783 784 if is_x_y_locations: 785 if self._geospatial is not None: 786 pass #fixme throw an error 787 try: 788 xs = self._attribute_dic[x_title] 789 ys = self._attribute_dic[y_title] 790 points = [[float(i),float(j)] for i,j in map(None,xs,ys)] 791 except KeyError: 792 # maybe a warning.. 793 raise TitleValueError, msg 794 else: 795 self._geospatial = Geospatial_data(data_points=points) 779 796 780 797 # create a list of points that are in the refining_polygon -
inundation/pyvolution/test_data_manager.py
r3308 r3336 4659 4659 4660 4660 4661 4661 ########## testing nbed class ################## 4662 4662 def test_exposure_csv_loading(self): 4663 4663 … … 4887 4887 else: 4888 4888 self.failUnless(0 ==1, 'Error not thrown error!') 4889 4890 def test_exposure_csv_loading_x_y(self): 4889 4891 4892 4893 file_name = tempfile.mktemp(".xya") 4894 file = open(file_name,"w") 4895 file.write("x, y ,sound , speed \n\ 4896 115.0, 7, splat, 0.0\n\ 4897 114.0, 8.0, pow, 10.0\n\ 4898 114.5, 9., bang, 40.0\n") 4899 file.close() 4900 e1 = Exposure_csv(file_name, is_x_y_locations=True) 4901 gsd = e1.get_location() 4902 4903 points = gsd.get_data_points(absolute=True) 4904 4905 assert allclose(points[0][0], 115) 4906 assert allclose(points[0][1], 7) 4907 assert allclose(points[1][0], 114) 4908 assert allclose(points[1][1], 8) 4909 assert allclose(points[2][0], 114.5) 4910 assert allclose(points[2][1], 9) 4911 self.failUnless(gsd.get_geo_reference().get_zone() == -1, 4912 'Bad zone error!') 4913 4914 os.remove(file_name) 4890 4915 4891 4916 #------------------------------------------------------------- 4892 4917 if __name__ == "__main__": 4893 #suite = unittest.makeSuite(Test_Data_Manager,'test_exposure_csv ')4918 #suite = unittest.makeSuite(Test_Data_Manager,'test_exposure_csv_loadiny') 4894 4919 suite = unittest.makeSuite(Test_Data_Manager,'test') 4895 4920 runner = unittest.TextTestRunner()
Note: See TracChangeset
for help on using the changeset viewer.