Changeset 8249 for trunk/anuga_core/source/anuga/file
- Timestamp:
- Nov 15, 2011, 11:37:36 PM (13 years ago)
- Location:
- trunk/anuga_core/source/anuga/file
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file
-
Property
svn:ignore
set to
.python_cache
-
Property
svn:ignore
set to
-
trunk/anuga_core/source/anuga/file/test_mux.py
r7766 r8249 117 117 def delete_mux(self, files): 118 118 for file in files: 119 os.remove(file) 119 try: 120 os.remove(file) 121 except: 122 pass 120 123 121 124 def write_mux2(self, lat_long_points, time_step_count, time_step, -
trunk/anuga_core/source/anuga/file/test_urs.py
r7766 r8249 101 101 102 102 def test_URS_points_northern_hemisphere(self): 103 103 104 104 LL_LAT = 8.0 105 105 LL_LONG = 97.0 … … 130 130 # export_csv=True, 131 131 # verbose=self.verbose) 132 132 133 133 geo=calculate_boundary_points(poly_lat_long, 134 134 ZONE, … … 138 138 isSouthHemisphere=False, 139 139 verbose=self.verbose) 140 140 141 141 results = frozenset(geo.get_data_points(as_lat_long=True, 142 142 isSouthHemisphere=False)) 143 143 144 #print 'results',results 144 145 … … 160 161 if not found: 161 162 assert False 162 163 163 164 164 def covered_in_other_tests_test_URS_points_needed_poly1(self): -
trunk/anuga_core/source/anuga/file/urs.py
r8143 r8249 199 199 200 200 """ 201 201 202 202 msg = "grid_spacing can not be zero" 203 203 assert not grid_spacing == 0, msg … … 207 207 # List of segments. Each segment is two points. 208 208 segs = [i and [a[i-1], a[i]] or [a[len(a)-1], a[0]] for i in range(len(a))] 209 209 210 210 211 # convert the segs to Lat's and longs. … … 213 214 lat_long_set = frozenset() 214 215 for seg in segs: 216 215 217 points_lat_long = points_needed(seg, ll_lat, ll_long, grid_spacing, 216 218 lat_amount, long_amount, zone, 217 219 isSouthHemisphere) 220 218 221 lat_long_set |= frozenset(points_lat_long) 222 219 223 220 224 if lat_long_set == frozenset([]): … … 276 280 for index_lat in range(first_row_lat, last_row_lat + 1): 277 281 for index_long in range(first_row_long, last_row_long + 1): 282 278 283 lat = ll_lat + index_lat*grid_spacing 279 284 long = ll_long + index_long*grid_spacing 285 280 286 281 287 #filter here to keep good points … … 283 289 points_lat_long.append((lat, long)) #must be hashable 284 290 291 285 292 # Now that we have these points, lets throw ones out that are too far away 293 286 294 return points_lat_long 287 295 … … 302 310 x2_1 = x2-x1 303 311 y2_1 = y2-y1 304 try: 305 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/sqrt( \ 306 (x2_1)*(x2_1)+(y2_1)*(y2_1)) 307 except ZeroDivisionError: 308 if sqrt((x2_1)*(x2_1)+(y2_1)*(y2_1)) == 0 \ 309 and abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1)) == 0: 310 return True 311 else: 312 return False 313 314 return d <= max_distance 315 316 317 312 313 314 num = (x2_1)*(x2_1)+(y2_1)*(y2_1) 315 if sqrt(num) == 0 and abs(num) == 0: 316 return True 317 else: 318 d = abs((x2_1)*(y1-y0)-(x1-x0)*(y2_1))/num 319 return d <= max_distance 320 321 322 323
Note: See TracChangeset
for help on using the changeset viewer.