Changeset 4252
- Timestamp:
- Feb 9, 2007, 4:49:27 PM (17 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r4220 r4252 717 717 location, indices, 718 718 verbose = False, 719 use_cache = False): 719 use_cache = False, 720 max_read_lines=None): 720 721 """Set quantity based on arbitrary points in a points file 721 722 using attribute_name selects name of attribute … … 747 748 'attribute_name': attribute_name, 748 749 'use_cache': False, 749 'verbose': verbose}, 750 'verbose': verbose, 751 'max_read_lines':max_read_lines}, 750 752 verbose=verbose) 751 753 else: … … 754 756 attribute_name=attribute_name, 755 757 use_cache=use_cache, 756 verbose=verbose) 758 verbose=verbose, 759 max_read_lines=max_read_lines) 757 760 758 761 -
anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py
r4203 r4252 652 652 import os 653 653 os.remove(txt_file) 654 655 def test_set_values_from_UTM(self): 654 655 def test_set_values_from_lat_long(self): 656 quantity = Quantity(self.mesh_onslow) 657 658 #Get (enough) datapoints 659 data_points = [[-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 660 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6]] 661 662 data_geo_spatial = Geospatial_data(data_points, 663 points_are_lats_longs=True) 664 points_UTM = data_geo_spatial.get_data_points(absolute=True) 665 attributes = linear_function(points_UTM) 666 att = 'elevation' 667 668 #Create .txt file 669 txt_file = tempfile.mktemp(".txt") 670 file = open(txt_file,"w") 671 file.write(" lat,long," + att + " \n") 672 for data_point, attribute in map(None, data_points, attributes): 673 row = str(data_point[0]) + ',' + str(data_point[1]) \ 674 + ',' + str(attribute) 675 #print "row", row 676 file.write(row + "\n") 677 file.close() 678 679 680 #Check that values can be set from file 681 quantity.set_values(filename = txt_file, 682 attribute_name = att, alpha = 0) 683 answer = linear_function(quantity.domain.get_vertex_coordinates()) 684 685 #print "quantity.vertex_values.flat", quantity.vertex_values.flat 686 #print "answer",answer 687 688 assert allclose(quantity.vertex_values.flat, answer) 689 690 691 #Check that values can be set from file using default attribute 692 quantity.set_values(filename = txt_file, alpha = 0) 693 assert allclose(quantity.vertex_values.flat, answer) 694 695 #Cleanup 696 import os 697 os.remove(txt_file) 698 699 def test_set_values_from_UTM_pts(self): 656 700 quantity = Quantity(self.mesh_onslow) 657 701 … … 678 722 679 723 724 pts_file = tempfile.mktemp(".pts") 725 convert = Geospatial_data(txt_file) 726 convert.export_points_file(pts_file) 727 680 728 #Check that values can be set from file 681 quantity.set_values_from_file( txt_file, att, 0,729 quantity.set_values_from_file(pts_file, att, 0, 682 730 'vertices', None) 683 731 answer = linear_function(quantity.domain.get_vertex_coordinates()) … … 687 735 688 736 #Check that values can be set from file 689 quantity.set_values(filename = txt_file,737 quantity.set_values(filename = pts_file, 690 738 attribute_name = att, alpha = 0) 691 739 answer = linear_function(quantity.domain.get_vertex_coordinates()) … … 702 750 import os 703 751 os.remove(txt_file) 752 os.remove(pts_file) 753 754 def verbose_test_set_values_from_UTM_pts(self): 755 quantity = Quantity(self.mesh_onslow) 756 757 #Get (enough) datapoints 758 data_points = [[-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 759 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 760 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 761 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 762 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 763 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 764 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 765 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 766 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 767 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 768 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 769 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 770 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 771 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 772 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 773 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 774 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 775 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 776 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 777 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 778 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 779 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 780 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 781 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 782 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 783 [-21.5, 114.5],[-21.4, 114.6],[-21.45,114.65], 784 [-21.35, 114.65],[-21.45, 114.55],[-21.45,114.6], 785 ] 786 787 data_geo_spatial = Geospatial_data(data_points, 788 points_are_lats_longs=True) 789 points_UTM = data_geo_spatial.get_data_points(absolute=True) 790 attributes = linear_function(points_UTM) 791 att = 'elevation' 792 793 #Create .txt file 794 txt_file = tempfile.mktemp(".txt") 795 file = open(txt_file,"w") 796 file.write(" x,y," + att + " \n") 797 for data_point, attribute in map(None, points_UTM, attributes): 798 row = str(data_point[0]) + ',' + str(data_point[1]) \ 799 + ',' + str(attribute) 800 #print "row", row 801 file.write(row + "\n") 802 file.close() 803 804 805 pts_file = tempfile.mktemp(".pts") 806 convert = Geospatial_data(txt_file) 807 convert.export_points_file(pts_file) 808 809 #Check that values can be set from file 810 quantity.set_values_from_file(pts_file, att, 0, 811 'vertices', None, verbose = True, 812 max_read_lines=2) 813 answer = linear_function(quantity.domain.get_vertex_coordinates()) 814 #print "quantity.vertex_values.flat", quantity.vertex_values.flat 815 #print "answer",answer 816 assert allclose(quantity.vertex_values.flat, answer) 817 818 #Check that values can be set from file 819 quantity.set_values(filename = pts_file, 820 attribute_name = att, alpha = 0) 821 answer = linear_function(quantity.domain.get_vertex_coordinates()) 822 #print "quantity.vertex_values.flat", quantity.vertex_values.flat 823 #print "answer",answer 824 assert allclose(quantity.vertex_values.flat, answer) 825 826 827 #Check that values can be set from file using default attribute 828 quantity.set_values(filename = txt_file, alpha = 0) 829 assert allclose(quantity.vertex_values.flat, answer) 830 831 #Cleanup 832 import os 833 os.remove(txt_file) 834 os.remove(pts_file) 704 835 705 836 def test_set_values_from_file_with_georef1(self): … … 1870 2001 #suite = unittest.makeSuite(Test_Quantity, 'test_set_values_from_UTM') 1871 2002 #print "restricted test" 1872 #suite = unittest.makeSuite(Test_Quantity,' test_set_values_from_file_with_georef2')2003 #suite = unittest.makeSuite(Test_Quantity,'verbose_test_set_values_from_UTM_pts') 1873 2004 runner = unittest.TextTestRunner() 1874 2005 runner.run(suite) -
anuga_core/source/anuga/fit_interpolate/fit.py
r4214 r4252 329 329 verbose=verbose)): 330 330 if verbose is True and 0 == i%200: # round every 5 minutes 331 # But this is dependant on the # of Triangles, so it 332 #isn't every 5 minutes. 331 333 print 'Block %i' %i 332 334 # build the array -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r4245 r4252 724 724 _read_pts_file_header(self.fid, self.verbose) 725 725 self.start_row=0 726 self.show_verbose = 0 727 self.verbose_block_size = (self.last_row +10) /10 726 728 else: 727 729 file_pointer = open(self.file_name) … … 761 763 fin_row = self.last_row 762 764 763 if self.verbose is True and \ 764 0==self.start_row%(( self.last_row+10)/10)==0: 765 766 767 if self.verbose is True: 768 if self.show_verbose >= self.start_row and \ 769 self.show_verbose < fin_row: 765 770 print 'Doing %d of %d' %(self.start_row, self.last_row+10) 771 self.show_verbose += max(self.max_read_lines, 772 self.verbose_block_size) 766 773 #call stuff 767 774 pointlist, att_dict, = \ -
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r4238 r4252 1050 1050 1051 1051 def test_load_pts_blocking(self): 1052 """ test_load_csv(self): 1053 space delimited 1054 """ 1052 #This is pts! 1053 1055 1054 import os 1056 1055 -
anuga_validation/automated_validation_tests/okushiri_tank_validation/loading_pts_test.py
r4237 r4252 48 48 t0 = time.time() 49 49 bathymetry_filename=project.bathymetry_filename 50 bathymetry_filename='Benchmark_2_Bathymetry_very_thin.pts' 50 51 print 'Starting domain.set_quantity. Loading ', bathymetry_filename 51 52 s = "domain.set_quantity('elevation',filename=bathymetry_filename,alpha=0.02,verbose=True,use_cache=False)"
Note: See TracChangeset
for help on using the changeset viewer.