Changeset 5254
- Timestamp:
- Apr 30, 2008, 4:34:19 PM (17 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
r5253 r5254 4439 4439 ll-long - lower left longitude, in decimal degrees 4440 4440 grid_spacing - in deciamal degrees 4441 lat_amount - number of latitudes 4442 long_amount- number of longs 4441 lat_amount - number of latitudes 4442 long_amount- number of longs 4443 4443 4444 4444 … … 4456 4456 file_name = file_name[:-4] + ".csv" 4457 4457 geo.export_points_file(file_name) 4458 return geo 4458 4459 4459 4460 def URS_points_needed(boundary_polygon, zone, ll_lat, … … 4531 4532 isSouthHemisphere): 4532 4533 """ 4533 seg is one point, in UTM4534 seg is two points, in UTM 4534 4535 return a list of the points, in lats and longs that are needed to 4535 4536 interpolate any point on the segment. … … 4538 4539 #print "zone",zone 4539 4540 geo_reference = Geo_reference(zone=zone) 4541 #print "seg", seg 4540 4542 geo = Geospatial_data(seg,geo_reference=geo_reference) 4541 4543 seg_lat_long = geo.get_data_points(as_lat_long=True, 4542 4544 isSouthHemisphere=isSouthHemisphere) 4545 #print "seg_lat_long", seg_lat_long 4543 4546 # 1.415 = 2^0.5, rounded up.... 4544 4547 sqrt_2_rounded_up = 1.415 … … 4550 4553 min_long = min(seg_lat_long[0][1], seg_lat_long[1][1]) - buffer 4551 4554 4555 #print "min_long", min_long 4556 #print "ll_long", ll_long 4557 #print "grid_spacing", grid_spacing 4552 4558 first_row = (min_long - ll_long)/grid_spacing 4553 4559 # To round up … … 4577 4583 for index_lat in range(first_row_lat, last_row_lat + 1): 4578 4584 for index_long in range(first_row_long, last_row_long + 1): 4585 #print "index_lat", index_lat 4586 #print "index_long", index_long 4579 4587 lat = ll_lat + index_lat*grid_spacing 4580 4588 long = ll_long + index_long*grid_spacing … … 4598 4606 x2 = seg[1][0] 4599 4607 y2 = seg[1][1] 4600 4601 4608 x2_1 = x2-x1 4602 4609 y2_1 = y2-y1 4603 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) 4610 try: 4611 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt( \ 4612 (x2_1)*(x2_1)+(y2_1)*(y2_1)) 4613 except ZeroDivisionError: 4614 #print "seg", seg 4615 #print "x0", x0 4616 #print "y0", y0 4617 if sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) == 0 and \ 4618 abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1)) == 0: 4619 return True 4620 else: 4621 return False 4622 4604 4623 if d <= max_distance: 4605 4624 return True -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5253 r5254 6117 6117 lat_amount, long_amount, 6118 6118 verbose=self.verbose) 6119 6120 def test_URS_points_needed_poly1(self): 6119 6120 def test_URS_points_northern_hemisphere(self): 6121 6122 LL_LAT = 8.0 6123 LL_LONG = 97.0 6124 GRID_SPACING = 2.0/60.0 6125 LAT_AMOUNT = 2 6126 LONG_AMOUNT = 2 6127 ZONE = 47 6128 6129 # 6130 points = [] 6131 for i in range(2): 6132 for j in range(2): 6133 points.append((degminsec2decimal_degrees(8,1+i*2,0), 6134 degminsec2decimal_degrees(97,1+i*2,0))) 6135 #print "points", points 6136 geo_poly = Geospatial_data(data_points=points, 6137 points_are_lats_longs=True) 6138 poly_lat_long = geo_poly.get_data_points(as_lat_long=False, 6139 isSouthHemisphere=False) 6140 #print "seg_lat_long", poly_lat_long 6141 6142 #geo=URS_points_needed_to_file('test_example_poly3', poly_lat_long, 6143 geo=URS_points_needed(poly_lat_long, 6144 ZONE, 6145 LL_LAT, LL_LONG, 6146 GRID_SPACING, 6147 LAT_AMOUNT, LONG_AMOUNT, 6148 isSouthHemisphere=False, 6149 verbose=self.verbose) 6150 results = ImmutableSet(geo.get_data_points(as_lat_long=True, 6151 isSouthHemisphere=False)) 6152 #print 'results',results 6153 6154 # These are a set of points that have to be in results 6155 points = [] 6156 for i in range(2): 6157 for j in range(2): 6158 points.append((degminsec2decimal_degrees(8,i*2,0), 6159 degminsec2decimal_degrees(97,i*2,0))) 6160 #print "answer points", points 6161 answer = ImmutableSet(points) 6162 6163 for point in points: 6164 found = False 6165 for result in results: 6166 if allclose(point, result): 6167 found = True 6168 break 6169 if not found: 6170 assert False 6171 6172 6173 def covered_in_other_tests_test_URS_points_needed_poly1(self): 6121 6174 # Values used for FESA 2007 results 6122 6175 # domain in southern hemisphere zone 51 … … 6141 6194 GRID_SPACING, 6142 6195 LAT_AMOUNT, LONG_AMOUNT, 6143 verbose=self.verbose) 6144 6145 6146 def test_URS_points_needed_poly2(self): 6196 verbose=self.verbose) 6197 6198 6199 6200 def covered_in_other_tests_test_URS_points_needed_poly2(self): 6147 6201 # Values used for 2004 validation work 6148 6202 # domain in northern hemisphere zone 47 … … 7562 7616 suite = unittest.makeSuite(Test_Data_Manager,'test') 7563 7617 #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section') 7564 #suite = unittest.makeSuite(Test_Data_Manager,' Xtest')7618 #suite = unittest.makeSuite(Test_Data_Manager,'covered_') 7565 7619 7566 7620
Note: See TracChangeset
for help on using the changeset viewer.