Changeset 4326 for anuga_core/source/anuga/shallow_water
- Timestamp:
- Mar 26, 2007, 3:55:11 PM (18 years ago)
- Location:
- anuga_core/source/anuga/shallow_water
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r4318 r4326 750 750 751 751 752 #### NED is national exposure database 752 #### NED is national exposure database (name changed to NEXIS) 753 753 754 754 LAT_TITLE = 'LATITUDE' … … 760 760 longitude_title=LONG_TITLE, is_x_y_locations=None, 761 761 x_title=X_TITLE, y_title=Y_TITLE, 762 refine_polygon=None ):762 refine_polygon=None, title_check_list=None): 763 763 """ 764 764 This class is for handling the exposure csv file. … … 799 799 #The values are the index positions of file columns. 800 800 self._attribute_dic, self._title_index_dic = \ 801 self._load_exposure_csv(self._file_name) 801 self._load_exposure_csv(self._file_name, 802 title_check_list=title_check_list) 802 803 try: 803 804 #Have code here that handles caps or lower … … 857 858 return 1 858 859 859 def _load_exposure_csv(self, file_name ):860 def _load_exposure_csv(self, file_name, title_check_list=None): 860 861 """ 861 862 Load in the csv as a dic, title as key and column info as value, . … … 867 868 title_index_dic = {} 868 869 titles_stripped = [] # list of titles 869 870 870 reader = csv.reader(file(file_name)) 871 871 … … 877 877 title_count = len(titles_stripped) 878 878 #print "title_index_dic",title_index_dic 879 879 if title_check_list is not None: 880 for title_check in title_check_list: 881 #msg = "Reading error. This row is not present ", title_check 882 #assert title_index_dic.has_key(title_check), msg 883 if not title_index_dic.has_key(title_check): 884 #reader.close() 885 msg = "Reading error. This row is not present ", \ 886 title_check 887 raise IOError, msg 888 889 880 890 881 891 #create a dic of colum values, indexed by column title -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4318 r4326 4407 4407 114.5, -21.4, bang, 40.0\n") 4408 4408 file.close() 4409 exposure = Exposure_csv(file_name )4409 exposure = Exposure_csv(file_name, title_check_list = ['speed','sound']) 4410 4410 exposure.get_column("sound") 4411 4411 … … 4436 4436 4437 4437 os.remove(file_name) 4438 4438 4439 def test_exposure_csv_loading_title_check_list(self): 4440 4441 # I can't get cvs.reader to close the exposure file 4442 # The hacks below are to get around this. 4443 if sys.platform == 'win32': 4444 file_name = tempfile.gettempdir() + \ 4445 "test_exposure_csv_loading_title_check_list.xya" 4446 else: 4447 file_name = tempfile.mktemp(".xya") 4448 file = open(file_name,"w") 4449 file.write("LATITUDE, LONGITUDE ,sound , speed \n\ 4450 115.0, -21.0, splat, 0.0\n\ 4451 114.0, -21.7, pow, 10.0\n\ 4452 114.5, -21.4, bang, 40.0\n") 4453 file.close() 4454 try: 4455 exposure = Exposure_csv(file_name, title_check_list = ['SOUND']) 4456 except IOError: 4457 pass 4458 else: 4459 self.failUnless(0 ==1, 'Assertion not thrown error!') 4460 4461 if not sys.platform == 'win32': 4462 os.remove(file_name) 4463 4439 4464 def test_exposure_csv_cmp(self): 4440 4465 file_name = tempfile.mktemp(".xya")
Note: See TracChangeset
for help on using the changeset viewer.