Changeset 5253
- Timestamp:
- Apr 30, 2008, 11:44:10 AM (17 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r5251 r5253 902 902 if data_points is not None and not points_are_lats_longs: 903 903 msg = """Data points are specified yet latitude and 904 longitude are also specified !"""904 longitude are also specified.""" 905 905 raise ValueError, msg 906 906 907 907 if points_are_lats_longs: 908 908 if data_points is None: 909 msg = """Data points are not specified !"""909 msg = """Data points are not specified.""" 910 910 raise ValueError, msg 911 911 lats_longs = ensure_numeric(data_points) 912 913 912 latitudes = ravel(lats_longs[:,0:1]) 914 913 longitudes = ravel(lats_longs[:,1:]) 915 914 916 915 if latitudes is None and longitudes is None: 917 msg = """Latitudes and Longitudes are not ."""916 msg = """Latitudes and Longitudes are not specified.""" 918 917 raise ValueError, msg 919 918 920 919 if latitudes is None: 921 msg = """Longitudes are specified yet latitudes aren't !"""920 msg = """Longitudes are specified yet latitudes aren't.""" 922 921 raise ValueError, msg 923 922 924 923 if longitudes is None: 925 msg = """Latitudes are specified yet longitudes aren't !"""924 msg = """Latitudes are specified yet longitudes aren't.""" 926 925 raise ValueError, msg 927 926 -
anuga_core/source/anuga/shallow_water/data_manager.py
r5250 r5253 4420 4420 grid_spacing, 4421 4421 lat_amount, long_amount, 4422 isSouthernHemisphere=True, 4422 4423 export_csv=False, use_cache=False, 4423 4424 verbose=False): 4424 4425 """ 4426 Given the info to replicate the URS grid and a polygon output 4427 a file that specifies the cloud of boundary points for URS. 4428 4429 Note: The polygon cannot cross zones or hemispheres. 4430 4425 4431 file_name - name of the urs file produced for David. 4426 4432 boundary_polygon - a list of points that describes a polygon. … … 4429 4435 4430 4436 This is info about the URS model that needs to be inputted. 4431 If you do not, default values will be used, which may be incorrect.4437 4432 4438 ll_lat - lower left latitude, in decimal degrees 4433 4439 ll-long - lower left longitude, in decimal degrees … … 4441 4447 geo = URS_points_needed(boundary_polygon, zone, ll_lat, ll_long, 4442 4448 grid_spacing, 4443 lat_amount, long_amount,use_cache, verbose) 4449 lat_amount, long_amount, isSouthernHemisphere, 4450 use_cache, verbose) 4444 4451 if not file_name[-4:] == ".urs": 4445 4452 file_name += ".urs" 4446 geo.export_points_file(file_name )4453 geo.export_points_file(file_name, isSouthHemisphere=isSouthernHemisphere) 4447 4454 if export_csv: 4448 4455 if file_name[-4:] == ".urs": … … 4452 4459 def URS_points_needed(boundary_polygon, zone, ll_lat, 4453 4460 ll_long, grid_spacing, 4454 lat_amount, long_amount, 4461 lat_amount, long_amount, isSouthHemisphere=True, 4455 4462 use_cache=False, verbose=False): 4456 4463 args = (boundary_polygon, 4457 zone) 4458 kwargs = {'ll_lat': ll_lat, 4459 'll_long': ll_long, 4460 'grid_spacing': grid_spacing, 4461 'lat_amount': lat_amount, 4462 'long_amount': long_amount} 4464 zone, ll_lat, 4465 ll_long, grid_spacing, 4466 lat_amount, long_amount, isSouthHemisphere) 4467 kwargs = {} 4463 4468 if use_cache is True: 4464 4469 try: … … 4475 4480 compression=False) 4476 4481 else: 4477 #I was getting 'got multiple values for keyword argument' errors 4478 #geo = apply(_URS_points_needed, args, kwargs) 4479 geo = _URS_points_needed(boundary_polygon, 4480 zone, ll_lat, 4481 ll_long, grid_spacing, 4482 lat_amount, long_amount) 4482 geo = apply(_URS_points_needed, args, kwargs) 4483 4483 4484 4484 return geo … … 4487 4487 zone, ll_lat, 4488 4488 ll_long, grid_spacing, 4489 lat_amount, long_amount ):4490 """4491 4489 lat_amount, long_amount, 4490 isSouthHemisphere): 4491 """ 4492 4492 boundary_polygon - a list of points that describes a polygon. 4493 4493 The last point is assumed ot join the first point. … … 4507 4507 # List of segments. Each segment is two points. 4508 4508 segs = [i and [a[i-1], a[i]] or [a[len(a)-1], a[0]] for i in range(len(a))] 4509 4510 4509 # convert the segs to Lat's and longs. 4511 4510 … … 4516 4515 for seg in segs: 4517 4516 points_lat_long = points_needed(seg, ll_lat, ll_long, grid_spacing, 4518 lat_amount, long_amount, zone )4517 lat_amount, long_amount, zone, isSouthHemisphere) 4519 4518 lat_long_set |= ImmutableSet(points_lat_long) 4520 #print "lat_long_set",lat_long_set 4519 if lat_long_set == ImmutableSet([]): 4520 msg = """URS region specified and polygon does not overlap.""" 4521 raise ValueError, msg 4522 4523 # Warning there is no info in geospatial saying the hemisphere of 4524 # these points. There should be. 4521 4525 geo = Geospatial_data(data_points=list(lat_long_set), 4522 4526 points_are_lats_longs=True) … … 4524 4528 4525 4529 def points_needed(seg, ll_lat, ll_long, grid_spacing, 4526 lat_amount, long_amount, zone): 4527 """ 4530 lat_amount, long_amount, zone, 4531 isSouthHemisphere): 4532 """ 4533 seg is one point, in UTM 4528 4534 return a list of the points, in lats and longs that are needed to 4529 4535 interpolate any point on the segment. … … 4532 4538 #print "zone",zone 4533 4539 geo_reference = Geo_reference(zone=zone) 4534 #print "seg",seg4535 4540 geo = Geospatial_data(seg,geo_reference=geo_reference) 4536 seg_lat_long = geo.get_data_points(as_lat_long=True )4537 #print "seg_lat_long", seg_lat_long4541 seg_lat_long = geo.get_data_points(as_lat_long=True, 4542 isSouthHemisphere=isSouthHemisphere) 4538 4543 # 1.415 = 2^0.5, rounded up.... 4539 4544 sqrt_2_rounded_up = 1.415 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5250 r5253 6144 6144 6145 6145 6146 def Xtest_URS_points_needed_poly2(self):6146 def test_URS_points_needed_poly2(self): 6147 6147 # Values used for 2004 validation work 6148 6148 # domain in northern hemisphere zone 47 … … 6169 6169 GRID_SPACING, 6170 6170 LAT_AMOUNT, LONG_AMOUNT, 6171 isSouthernHemisphere=False, 6171 6172 verbose=self.verbose) 6172 6173 … … 7561 7562 suite = unittest.makeSuite(Test_Data_Manager,'test') 7562 7563 #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section') 7563 #suite = unittest.makeSuite(Test_Data_Manager,' test_urs_ungridded_holeII')7564 #suite = unittest.makeSuite(Test_Data_Manager,'Xtest') 7564 7565 7565 7566
Note: See TracChangeset
for help on using the changeset viewer.