Changeset 2648
- Timestamp:
- Mar 31, 2006, 6:21:26 PM (19 years ago)
- Files:
-
- 11 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/examples/island.py
r2638 r2648 33 33 'top': [2], 34 34 'left': [3]}, 35 maximum_triangle_area = 20,35 maximum_triangle_area = 5, 36 36 filename = 'island.msh' 37 37 , interior_regions=[ ([[50,25], [70,25], [70,75], [50,75]], 3)] 38 38 ) 39 39 … … 77 77 return z 78 78 79 domain.set_quantity('friction', 0.1) #Honky dory80 #domain.set_quantity('friction', 2) #Creep79 #domain.set_quantity('friction', 0.1) #Honky dory 80 domain.set_quantity('friction', 1000) #Creep 81 81 domain.set_quantity('elevation', island) 82 82 domain.set_quantity('stage', 1) 83 domain.max_timestep = 0.01 83 84 84 85 -
inundation/pyvolution/config.py
r2566 r2648 12 12 13 13 min_timestep = 1.0e-6 #Should be computed based on geometry 14 max_timestep = 1 00014 max_timestep = 1.0e+3 15 15 #This is how: 16 16 #Define maximal possible speed in open water v_max, e.g. 500m/s (soundspeed?) -
inundation/pyvolution/data_manager.py
r2644 r2648 1049 1049 if zone is None: 1050 1050 assert xllcorner is None, 'xllcorner must be None' 1051 assert yllcorner is None, 'yllcorner must be None' 1051 assert yllcorner is None, 'yllcorner must be None' 1052 1052 Geo_reference().write_NetCDF(outfile) 1053 1053 else: 1054 Geo_reference(zone, xllcorner, yllcorner).write_NetCDF(outfile) 1055 1054 Geo_reference(zone, xllcorner, yllcorner).write_NetCDF(outfile) 1055 1056 1056 1057 1057 … … 1075 1075 1076 1076 1077 def dem2pts(basename_in, basename_out=None, 1077 def dem2pts(basename_in, basename_out=None, 1078 1078 easting_min=None, easting_max=None, 1079 1079 northing_min=None, northing_max=None, … … 1099 1099 1100 1100 1101 kwargs = {'basename_out': basename_out, 1101 kwargs = {'basename_out': basename_out, 1102 1102 'easting_min': easting_min, 1103 1103 'easting_max': easting_max, … … 1114 1114 else: 1115 1115 result = apply(_dem2pts, [basename_in], kwargs) 1116 1116 1117 1117 return result 1118 1118 … … 1123 1123 """Read Digitial Elevation model from the following NetCDF format (.dem) 1124 1124 1125 Internal function. See public function dem2pts for details. 1125 Internal function. See public function dem2pts for details. 1126 1126 """ 1127 1127 … … 1219 1219 1220 1220 if k == 0: 1221 i1_0 = i 1221 i1_0 = i 1222 1222 j1_0 = j 1223 k += 1 1223 k += 1 1224 1224 1225 1225 index1 = j1_0 1226 1226 index2 = thisj 1227 1227 1228 1228 # dimension definitions 1229 1229 nrows_in_bounding_box = int(round((northing_max-northing_min)/cellsize)) 1230 1230 ncols_in_bounding_box = int(round((easting_max-easting_min)/cellsize)) 1231 1232 clippednopoints = (thisi+1-i1_0)*(thisj+1-j1_0) 1231 1232 clippednopoints = (thisi+1-i1_0)*(thisj+1-j1_0) 1233 1233 nopoints = clippednopoints-nn 1234 1234 1235 1235 clipped_dem_elev = dem_elevation_r[i1_0:thisi+1,j1_0:thisj+1] 1236 1236 1237 1237 if verbose and nn > 0: 1238 1238 print 'There are %d values in the elevation' %totalnopoints 1239 1239 print 'There are %d values in the clipped elevation' %clippednopoints 1240 1240 print 'There are %d NODATA_values in the clipped elevation' %nn 1241 1241 1242 1242 outfile.createDimension('number_of_points', nopoints) 1243 1243 outfile.createDimension('number_of_dimensions', 2) #This is 2d data … … 1273 1273 1274 1274 local_index = 0 1275 1275 1276 1276 y = (nrows-i-1)*cellsize + yllcorner 1277 1277 #for j in range(ncols): … … 1286 1286 global_index += 1 1287 1287 local_index += 1 1288 1288 1289 1289 upper_index = global_index 1290 1290 1291 if upper_index == lower_index + newcols: 1291 if upper_index == lower_index + newcols: 1292 1292 points[lower_index:upper_index, :] = tpoints 1293 1293 elevation[lower_index:upper_index] = telev … … 1914 1914 use_cache = False, 1915 1915 verbose = False): 1916 """Read Digitial Elevation model from the following ASCII format (.asc) 1916 """Read Digitial Elevation model from the following ASCII format (.asc) 1917 1917 1918 1918 Example: … … 1958 1958 else: 1959 1959 result = apply(_convert_dem_from_ascii2netcdf, [basename_in], kwargs) 1960 1960 1961 1961 return result 1962 1962 1963 1964 1963 1964 1965 1965 1966 1966 … … 2161 2161 if maxlon != None: 2162 2162 assert -180 < maxlon < 180 , msg 2163 2163 2164 2164 2165 2165 #Get NetCDF data … … 2168 2168 file_u = NetCDFFile(basename_in + '_ua.nc', 'r') #Velocity (x) (cm/s) 2169 2169 file_v = NetCDFFile(basename_in + '_va.nc', 'r') #Velocity (y) (cm/s) 2170 file_e = NetCDFFile(basename_in + '_e.nc', 'r') #Elevation (z) (m)2170 file_e = NetCDFFile(basename_in + '_e.nc', 'r') #Elevation (z) (m) 2171 2171 2172 2172 if basename_out is None: … … 2605 2605 from Numeric import array 2606 2606 from config import time_format 2607 from utilities.numerical_tools import ensure_numeric 2607 from utilities.numerical_tools import ensure_numeric 2608 2608 2609 2609 … … 2823 2823 2824 2824 2825 try: 2825 try: 2826 2826 domain = Domain(coordinates, volumes, boundary) 2827 2827 except AssertionError, e: … … 2887 2887 X = resize(X,(X.shape[0]/3,3)) 2888 2888 domain.set_quantity(quantity,X) 2889 2889 2890 2890 fid.close() 2891 2891 return domain … … 3592 3592 quantities which can be derived from those, i.e. 3593 3593 ['depth', 'xmomentum', 'ymomentum', 'momentum', 'velocity', 'bearing']. 3594 3594 3595 3595 Momentum is the absolute momentum, sqrt(xmomentum^2 + ymomentum^2). 3596 3596 Note, units of momentum are m^2/s and depth is m. … … 3611 3611 3612 3612 # extract gauge locations from gauge file 3613 3613 3614 3614 # extract all quantities from swwfile (f = file_function) 3615 3615 if time_min is None: time_min = min(f.T) 3616 3616 if time_max is None: time_max = max(f.T) 3617 3617 3618 3618 # loop through appropriate range of time 3619 3619 # plot prescribed quantities and export data if requested 3620 3620 3621 3621 #if gauge_data_outname is None: 3622 3622 -
inundation/pyvolution/domain.py
r2633 r2648 78 78 #FIXME: Maybe have separate orders for h-limiter and w-limiter? 79 79 #Or maybe get rid of order altogether and use beta_w and beta_h 80 self.set_default_order(1) 80 self.set_default_order(1) 81 81 #self.default_order = 1 82 82 #self.order = self.default_order … … 115 115 if mesh_filename is not None: 116 116 # If the mesh file passed any quantity values 117 # , initialise with these values. 117 # , initialise with these values. 118 118 self.set_quantity_vertices_dict(vertex_quantity_dict) 119 119 120 120 121 121 122 122 def set_default_order(self, n): … … 126 126 msg = 'Default order must be either 1 or 2. I got %s' %n 127 127 assert n in [1,2], msg 128 128 129 129 self.default_order = n 130 130 self.order = self.default_order … … 412 412 Input: 413 413 quantities: either None, a string or a list of strings naming the quantities to be reported 414 tags: either None, a string or a list of strings naming the tags to be reported 414 tags: either None, a string or a list of strings naming the tags to be reported 415 415 416 416 … … 514 514 yieldstep = None, 515 515 finaltime = None, 516 duration = None, 516 duration = None, 517 517 skip_initial_step = False): 518 518 """Evolve model through time starting from self.starttime. 519 520 519 520 521 521 yieldstep: Interval between yields where results are stored, 522 522 statistics written and domain inspected or 523 523 possibly modified. If omitted the internal predefined 524 524 max timestep is used. 525 Internally, smaller timesteps may be taken. 525 Internally, smaller timesteps may be taken. 526 526 527 527 duration: Duration of simulation … … 534 534 skip_initial_step: Boolean flag that decides whether the first 535 535 yield step is skipped or not. This is useful for example to avoid 536 duplicate steps when multiple evolve processes are dove tailed. 536 duplicate steps when multiple evolve processes are dove tailed. 537 537 538 538 … … 543 543 544 544 545 All times are given in seconds 545 All times are given in seconds 546 546 547 547 """ … … 575 575 if duration is not None: 576 576 self.finaltime = self.starttime + float(duration) 577 578 579 577 578 579 580 580 581 581 self.yieldtime = 0.0 #Time between 'yields' … … 678 678 if B is None: 679 679 print 'WARNING: Ignored boundary segment %d (None)' 680 else: 680 else: 681 681 q = B.evaluate(vol_id, edge_id) 682 682 … … 693 693 def update_timestep(self, yieldstep, finaltime): 694 694 695 from config import min_timestep 695 from config import min_timestep, max_timestep 696 696 697 697 # self.timestep is calculated from speed of characteristics 698 698 # Apply CFL condition here 699 timestep = self.CFL*self.timestep699 timestep = min(self.CFL*self.timestep,max_timestep) 700 700 701 701 #Record maximal and minimal values of timestep for reporting -
inundation/pyvolution/quantity.py
r2526 r2648 197 197 Arbitrary geo spatial dataset in the form of the class 198 198 Geospatial_data. Mesh points are populated using least squares 199 fitting 199 fitting 200 200 201 201 points: … … 210 210 211 211 data_georef: 212 If points is specified, geo_reference applies to each point. 213 212 If points is specified, geo_reference applies to each point. 213 214 214 filename: 215 215 Name of a .pts file containing data points and attributes for 216 216 use with least squares. 217 217 218 218 attribute_name: 219 219 If specified, any array matching that name … … 289 289 if not(points is None and values is None and data_georef is None): 290 290 from warnings import warn 291 291 292 292 msg = 'Using points, values or data_georef with set_quantity ' 293 293 msg += 'is obsolete. Please use a Geospatial_data object instead.' … … 312 312 location, indices, verbose) 313 313 elif isinstance(numeric, Geospatial_data): 314 self.set_values_from_geospatial_data(numeric, 314 self.set_values_from_geospatial_data(numeric, 315 315 alpha, 316 316 location, indices, … … 338 338 print 'The usage of points in set_values will be deprecated.' +\ 339 339 'Please use the geospatial_data object.' 340 340 341 341 msg = 'When points are specified, associated values must also be.' 342 342 assert values is not None, msg … … 350 350 location, indices, 351 351 verbose = verbose, 352 use_cache = use_cache) 352 use_cache = use_cache) 353 353 else: 354 354 raise 'This can\'t happen :-)' … … 586 586 587 587 588 588 589 589 def set_values_from_geospatial_data(self, geospatial_data, alpha, 590 590 location, indices, … … 604 604 data_georef = data_georef, 605 605 verbose = verbose, 606 use_cache = use_cache) 607 608 606 use_cache = use_cache) 607 608 609 609 610 610 def set_values_from_points(self, points, values, alpha, … … 621 621 from least_squares import fit_to_mesh 622 622 from coordinate_transforms.geo_reference import Geo_reference 623 623 624 624 625 625 points = ensure_numeric(points, Float) … … 645 645 #print data_georef 646 646 #print points 647 648 649 #Call least squares method 647 648 649 #Call least squares method 650 650 args = (coordinates, triangles, points, values) 651 651 kwargs = {'data_origin': data_georef.get_origin(), … … 656 656 657 657 #print kwargs 658 658 659 659 if use_cache is True: 660 660 try: … … 672 672 vertex_attributes = apply(fit_to_mesh, 673 673 args, kwargs) 674 675 #Call underlying method using array values 674 675 #Call underlying method using array values 676 676 self.set_values_from_array(vertex_attributes, 677 677 location, indices, verbose) … … 730 730 data_georef = None 731 731 732 732 733 733 734 734 #Call underlying method for geospatial data 735 735 geospatial_data = points_dictionary2geospatial_data(points_dict) 736 736 geospatial_data.set_default_attribute_name(attribute_name) 737 737 738 738 self.set_values_from_geospatial_data(geospatial_data, 739 739 alpha, … … 741 741 verbose = verbose, 742 742 use_cache = use_cache) 743 743 744 744 #Call underlying method for points 745 745 #self.set_values_from_points(points, z, alpha, … … 770 770 771 771 The values will be stored in elements following their 772 internal ordering. 772 internal ordering. 773 773 774 774 """ … … 1132 1132 denominator = ones(N, Float)-timestep*quantity.semi_implicit_update 1133 1133 1134 if sum(less(denominator, 1.0)) > 0.0: 1135 msg = 'denominator < 1.0 in semi implicit update. Call Stephen :-)' 1136 raise msg 1137 1134 1138 if sum(equal(denominator, 0.0)) > 0.0: 1135 1139 msg = 'Zero division in semi implicit update. Call Stephen :-)' -
inundation/pyvolution/quantity_ext.c
r1506 r2648 81 81 82 82 //Two point gradient 83 _gradient2(x0, y0, x1, y1, q0, q1, &a[k], &b[k]); 84 85 83 _gradient2(x0, y0, x1, y1, q0, q1, &a[k], &b[k]); 84 85 86 86 //Old (wrong code) 87 87 //det = x0*y1 - x1*y0; … … 187 187 188 188 189 //Explicit updates190 for (k=0; k<N; k++) {191 centroid_values[k] += timestep*explicit_update[k];192 }193 194 189 //Semi implicit updates 195 190 for (k=0; k<N; k++) { … … 202 197 } 203 198 } 199 200 201 //Explicit updates 202 for (k=0; k<N; k++) { 203 centroid_values[k] += timestep*explicit_update[k]; 204 } 205 206 204 207 //MH080605 set semi_impliit_update[k] to 0.0 here, rather than in update_conserved_quantities.py 205 for (k=0;k<N;k++) 208 for (k=0;k<N;k++){ 206 209 semi_implicit_update[k]=0.0; 210 } 211 207 212 return 0; 208 213 } -
inundation/pyvolution/shallow_water.py
r2620 r2648 83 83 from config import minimum_allowed_height, maximum_allowed_speed, g 84 84 self.minimum_allowed_height = minimum_allowed_height 85 self.maximum_allowed_speed = maximum_allowed_speed 85 self.maximum_allowed_speed = maximum_allowed_speed 86 86 self.g = g 87 87 88 89 self.forcing_terms.append(manning_friction) 88 90 self.forcing_terms.append(gravity) 89 self.forcing_terms.append(manning_friction)90 91 91 92 #Realtime visualisation … … 108 109 self.quantities_to_be_stored = ['stage','xmomentum','ymomentum'] 109 110 110 111 111 112 def set_quantities_to_be_stored(self, q): 112 113 """Specify which quantities will be stored in the sww file. … … 118 119 119 120 In the two first cases, the named quantities will be stored at each yieldstep 120 (This is in addition to the quantities elevation and friction) 121 (This is in addition to the quantities elevation and friction) 121 122 If q is None, storage will be switched off altogether. 122 123 """ … … 124 125 125 126 if q is None: 126 self.quantities_to_be_stored = [] 127 self.quantities_to_be_stored = [] 127 128 self.store = False 128 129 return … … 131 132 q = [q] # Turn argument into a list 132 133 133 #Check correcness 134 #Check correcness 134 135 for quantity_name in q: 135 136 msg = 'Quantity %s is not a valid conserved quantity' %quantity_name 136 assert quantity_name in self.conserved_quantities, msg 137 137 assert quantity_name in self.conserved_quantities, msg 138 138 139 self.quantities_to_be_stored = q 139 140 140 141 141 142 def initialise_visualiser(self,scale_z=1.0,rect=None): … … 224 225 yieldstep = None, 225 226 finaltime = None, 226 duration = None, 227 duration = None, 227 228 skip_initial_step = False): 228 229 """Specialisation of basic evolve method from parent class … … 670 671 hc = wc - zc #Water depths at centroids 671 672 672 #Update 673 #Update 673 674 #FIXME: Modify accroditg to c-version - or discard altogether. 674 675 for k in range(domain.number_of_elements): … … 695 696 from shallow_water_ext import protect 696 697 697 protect(domain.minimum_allowed_height, domain.maximum_allowed_speed, 698 protect(domain.minimum_allowed_height, domain.maximum_allowed_speed, 698 699 domain.epsilon, wc, zc, xmomc, ymomc) 699 700 … … 1183 1184 1184 1185 1185 def manning_friction_ c(domain):1186 def manning_friction_implicit_c(domain): 1186 1187 """Wrapper for c version 1187 1188 """ … … 1200 1201 xmom_update = xmom.semi_implicit_update 1201 1202 ymom_update = ymom.semi_implicit_update 1203 1204 N = domain.number_of_elements 1205 eps = domain.minimum_allowed_height 1206 g = domain.g 1207 1208 from shallow_water_ext import manning_friction 1209 manning_friction(g, eps, w, z, uh, vh, eta, xmom_update, ymom_update) 1210 1211 1212 def manning_friction_explicit_c(domain): 1213 """Wrapper for c version 1214 """ 1215 1216 xmom = domain.quantities['xmomentum'] 1217 ymom = domain.quantities['ymomentum'] 1218 1219 w = domain.quantities['stage'].centroid_values 1220 z = domain.quantities['elevation'].centroid_values 1221 1222 uh = xmom.centroid_values 1223 vh = ymom.centroid_values 1224 eta = domain.quantities['friction'].centroid_values 1225 1226 xmom_update = xmom.explicit_update 1227 ymom_update = ymom.explicit_update 1202 1228 1203 1229 N = domain.number_of_elements … … 1791 1817 extrapolate_second_order_sw=extrapolate_second_order_sw_c 1792 1818 gravity = gravity_c 1793 manning_friction = manning_friction_ c1819 manning_friction = manning_friction_implicit_c 1794 1820 h_limiter = h_limiter_c 1795 1821 balance_deep_and_shallow = balance_deep_and_shallow_c -
inundation/pyvolution/shallow_water_ext.c
r2636 r2648 260 260 261 261 262 void _manning_friction_explicit(double g, double eps, int N, 263 double* w, double* z, 264 double* uh, double* vh, 265 double* eta, double* xmom, double* ymom) { 266 267 int k; 268 double S, h; 269 270 for (k=0; k<N; k++) { 271 if (eta[k] > eps) { 272 h = w[k]-z[k]; 273 if (h >= eps) { 274 S = -g * eta[k]*eta[k] * sqrt((uh[k]*uh[k] + vh[k]*vh[k])); 275 S /= pow(h, 7.0/3); //Expensive (on Ole's home computer) 276 //S /= exp(7.0/3.0*log(h)); //seems to save about 15% over manning_friction 277 //S /= h*h*(1 + h/3.0 - h*h/9.0); //FIXME: Could use a Taylor expansion 278 279 280 //Update momentum 281 xmom[k] += S*uh[k]; 282 ymom[k] += S*vh[k]; 283 } 284 } 285 } 286 } 287 262 288 263 289 int _balance_deep_and_shallow(int N, … … 356 382 int _protect(int N, 357 383 double minimum_allowed_height, 358 double maximum_allowed_speed, 384 double maximum_allowed_speed, 359 385 double epsilon, 360 386 double* wc, … … 365 391 int k; 366 392 double hc; 367 double u, v, reduced_speed; 393 double u, v, reduced_speed; 368 394 369 395 //Protect against initesimal and negative heights … … 372 398 373 399 if (hc < minimum_allowed_height) { 374 400 375 401 //Old code: Set momentum to zero and ensure h is non negative 376 402 //xmomc[k] = 0.0; 377 //ymomc[k] = 0.0; 378 //if (hc <= 0.0) wc[k] = zc[k]; 379 403 //ymomc[k] = 0.0; 404 //if (hc <= 0.0) wc[k] = zc[k]; 405 380 406 381 407 //New code: Adjust momentum to guarantee speeds are physical 382 // ensure h is non negative 383 //FIXME (Ole): This is only implemented in this C extension and 384 // has no Python equivalent 408 // ensure h is non negative 409 //FIXME (Ole): This is only implemented in this C extension and 410 // has no Python equivalent 385 411 if (hc <= 0.0) { 386 wc[k] = zc[k]; 412 wc[k] = zc[k]; 387 413 xmomc[k] = 0.0; 388 414 ymomc[k] = 0.0; 389 415 } else { 390 //Reduce excessive speeds derived from division by small hc 416 //Reduce excessive speeds derived from division by small hc 391 417 u = xmomc[k]/hc; 392 418 if (fabs(u) > maximum_allowed_speed) { 393 419 reduced_speed = maximum_allowed_speed * u/fabs(u); 394 //printf("Speed (u) has been reduced from %.3f to %.3f\n", 395 // u, reduced_speed); 420 //printf("Speed (u) has been reduced from %.3f to %.3f\n", 421 // u, reduced_speed); 396 422 xmomc[k] = reduced_speed * hc; 397 423 } 398 399 v = ymomc[k]/hc; 424 425 v = ymomc[k]/hc; 400 426 if (fabs(v) > maximum_allowed_speed) { 401 reduced_speed = maximum_allowed_speed * v/fabs(v); 402 //printf("Speed (v) has been reduced from %.3f to %.3f\n", 403 // v, reduced_speed); 404 ymomc[k] = reduced_speed * hc; 405 } 427 reduced_speed = maximum_allowed_speed * v/fabs(v); 428 //printf("Speed (v) has been reduced from %.3f to %.3f\n", 429 // v, reduced_speed); 430 ymomc[k] = reduced_speed * hc; 431 } 406 432 } 407 433 } … … 530 556 } 531 557 558 559 PyObject *manning_friction_explicit(PyObject *self, PyObject *args) { 560 // 561 // manning_friction_explicit(g, eps, h, uh, vh, eta, xmom_update, ymom_update) 562 // 563 564 565 PyArrayObject *w, *z, *uh, *vh, *eta, *xmom, *ymom; 566 int N; 567 double g, eps; 568 569 if (!PyArg_ParseTuple(args, "ddOOOOOOO", 570 &g, &eps, &w, &z, &uh, &vh, &eta, 571 &xmom, &ymom)) 572 return NULL; 573 574 N = w -> dimensions[0]; 575 _manning_friction_explicit(g, eps, N, 576 (double*) w -> data, 577 (double*) z -> data, 578 (double*) uh -> data, 579 (double*) vh -> data, 580 (double*) eta -> data, 581 (double*) xmom -> data, 582 (double*) ymom -> data); 583 584 return Py_BuildValue(""); 585 } 532 586 PyObject *extrapolate_second_order_sw(PyObject *self, PyObject *args) { 533 587 /*Compute the vertex values based on a linear reconstruction on each triangle … … 1067 1121 if (!PyArg_ParseTuple(args, "dddOOOO", 1068 1122 &minimum_allowed_height, 1069 &maximum_allowed_speed, 1123 &maximum_allowed_speed, 1070 1124 &epsilon, 1071 1125 &wc, &zc, &xmomc, &ymomc)) -
inundation/pyvolution/test_data_manager.py
r2639 r2648 79 79 latitudes = [-34.5, -34.33333, -34.16667, -34] 80 80 81 81 long_name = 'LON' 82 82 lat_name = 'LAT' 83 83 … … 89 89 for ext in ['_ha.nc', '_ua.nc', '_va.nc', '_e.nc']: 90 90 fid = NetCDFFile(self.test_MOST_file + ext, 'w') 91 91 92 92 fid.createDimension(long_name,nx) 93 93 fid.createVariable(long_name,'d',(long_name,)) … … 107 107 fid.variables['TIME'].units='seconds' 108 108 fid.variables['TIME'].assignValue([0.0, 0.1, 0.6, 1.1, 1.6, 2.1]) 109 109 110 110 111 111 name = ext[1:3].upper() … … 113 113 fid.createVariable(name,'d',('TIME', lat_name, long_name)) 114 114 fid.variables[name].units='CENTIMETERS' 115 fid.variables[name].missing_value=-1.e+034 116 115 fid.variables[name].missing_value=-1.e+034 116 117 117 fid.variables[name].assignValue([[[0.3400644, 0, -46.63519, -6.50198], 118 118 [-0.1214216, 0, 0, 0], … … 139 139 [0.0004811212, 0.0009622425, 0.0009599366, 8.152277e-007], 140 140 [0, 0.0004811212, 0.0004811212, 0]]]) 141 142 141 142 143 143 fid.close() 144 144 145 145 146 146 147 147 … … 150 150 for ext in ['_ha.nc', '_ua.nc', '_va.nc', '_e.nc']: 151 151 #print 'Trying to remove', self.test_MOST_file + ext 152 os.remove(self.test_MOST_file + ext) 152 os.remove(self.test_MOST_file + ext) 153 153 154 154 def test_sww_constant(self): … … 520 520 #def test_write_pts(self): 521 521 # #Obsolete 522 # 522 # 523 523 # #Get (enough) datapoints 524 524 # … … 546 546 # #Check contents 547 547 # #Get NetCDF 548 # from Scientific.IO.NetCDF import NetCDFFile 548 # from Scientific.IO.NetCDF import NetCDFFile 549 549 # fid = NetCDFFile(ptsfile, 'r') 550 550 # … … 555 555 # 556 556 # #Check values# 557 # 557 # 558 558 # #print points[:] 559 559 # #print ref_points 560 # assert allclose(points, points1) 560 # assert allclose(points, points1) 561 561 # 562 562 # #print attributes[:] … … 569 569 # import os 570 570 # os.remove(ptsfile) 571 571 572 572 573 573 def test_dem2pts_bounding_box_v2(self): … … 591 591 NODATA_value -9999 592 592 """) 593 #Create linear function 593 #Create linear function 594 594 ref_points = [] 595 595 ref_elevation = [] … … 610 610 611 611 fid.close() 612 612 613 613 #print 'sending pts', ref_points 614 614 #print 'sending elev', ref_elevation … … 650 650 651 651 #create new reference points 652 newz = [] 652 newz = [] 653 653 newz[0:5] = ref_elevation[32:38] 654 654 newz[6:11] = ref_elevation[42:48] … … 668 668 x = x0 + xvec[j] 669 669 xnew = x - 2002.0 670 ref_points.append ([xnew,ynew]) #Relative point values 670 ref_points.append ([xnew,ynew]) #Relative point values 671 671 672 672 assert allclose(points, ref_points) … … 704 704 NODATA_value -9999 705 705 """) 706 #Create linear function 706 #Create linear function 707 707 ref_points = [] 708 708 ref_elevation = [] … … 721 721 ref_points.append ([x,y]) 722 722 count += 1 723 z[count] = (4*i - 3*j)%13 723 z[count] = (4*i - 3*j)%13 724 724 if j == 4: z[count] = NODATA_value #column inside clipping region 725 725 if j == 8: z[count] = NODATA_value #column outside clipping region 726 726 if i == 9: z[count] = NODATA_value #row outside clipping region 727 if i == 4 and j == 6: z[count] = NODATA_value #arbitrary point inside clipping region 727 if i == 4 and j == 6: z[count] = NODATA_value #arbitrary point inside clipping region 728 728 ref_elevation.append( z[count] ) 729 729 fid.write('%f ' %z[count]) 730 730 fid.write('\n') 731 731 732 fid.close() 733 732 fid.close() 733 734 734 #print 'sending elev', ref_elevation 735 735 … … 781 781 newz[16:19] = ref_elevation[65:68] 782 782 783 783 784 784 ref_elevation = newz 785 785 ref_points = [] … … 795 795 x = x0 + xvec[j] 796 796 xnew = x - 2002.0 797 if j <> 2 and (i<>1 or j<>4): 797 if j <> 2 and (i<>1 or j<>4): 798 798 ref_points.append([x,y]) 799 799 new_ref_points.append ([xnew,ynew]) 800 800 801 801 802 802 assert allclose(points, new_ref_points) 803 803 assert allclose(elevation, ref_elevation) … … 834 834 NODATA_value -9999 835 835 """) 836 #Create linear function 836 #Create linear function 837 837 ref_points = [] 838 838 ref_elevation = [] … … 851 851 ref_points.append ([x,y]) 852 852 count += 1 853 z[count] = (4*i - 3*j)%13 853 z[count] = (4*i - 3*j)%13 854 854 if j == 4: z[count] = NODATA_value #column inside clipping region 855 855 if j == 8: z[count] = NODATA_value #column outside clipping region 856 856 if i == 6: z[count] = NODATA_value #row on clipping boundary 857 if i == 4 and j == 6: z[count] = NODATA_value #arbitrary point inside clipping region 857 if i == 4 and j == 6: z[count] = NODATA_value #arbitrary point inside clipping region 858 858 ref_elevation.append( z[count] ) 859 859 fid.write('%f ' %z[count]) 860 860 fid.write('\n') 861 861 862 fid.close() 863 862 fid.close() 863 864 864 #print 'sending elev', ref_elevation 865 865 … … 910 910 911 911 912 912 913 913 ref_elevation = newz 914 914 ref_points = [] … … 924 924 x = x0 + xvec[j] 925 925 xnew = x - 2002.0 926 if j <> 2 and (i<>1 or j<>4) and i<>3: 926 if j <> 2 and (i<>1 or j<>4) and i<>3: 927 927 ref_points.append([x,y]) 928 928 new_ref_points.append ([xnew,ynew]) … … 932 932 #print new_ref_points, len(new_ref_points) 933 933 934 assert allclose(elevation, ref_elevation) 934 assert allclose(elevation, ref_elevation) 935 935 assert allclose(points, new_ref_points) 936 936 … … 973 973 PROJECTION ZONE: 50 974 974 DATUM: AGD66 975 VERTICAL DATUM: 976 NUMBER OF REACHES: 19 977 NUMBER OF CROSS-SECTIONS: 2 975 VERTICAL DATUM: 976 NUMBER OF REACHES: 19 977 NUMBER OF CROSS-SECTIONS: 2 978 978 END HEADER: 979 979 … … 984 984 STREAM ID:Southern-Wungong 985 985 REACH ID:Southern-Wungong 986 STATION:21410 986 STATION:21410 987 987 CUT LINE: 988 407546.08 , 6437277.542 989 407329.32 , 6437489.482 990 407283.11 , 6437541.232 988 407546.08 , 6437277.542 989 407329.32 , 6437489.482 990 407283.11 , 6437541.232 991 991 SURFACE LINE: 992 992 407546.08, 6437277.54, 52.14 … … 999 999 1000 1000 CROSS-SECTION: 1001 STREAM ID:Swan River 1002 REACH ID:Swan Mouth 1003 STATION:840.* 1001 STREAM ID:Swan River 1002 REACH ID:Swan Mouth 1003 STATION:840.* 1004 1004 CUT LINE: 1005 381178.0855 , 6452559.0685 1006 380485.4755 , 6453169.272 1005 381178.0855 , 6452559.0685 1006 380485.4755 , 6453169.272 1007 1007 SURFACE LINE: 1008 1008 381178.09, 6452559.07, 4.17 … … 1017 1017 381063.46, 6452660.06, 3.67 1018 1018 381054.41, 6452668.03, 3.67 1019 END: 1019 END: 1020 1020 END CROSS-SECTIONS: 1021 1021 """) … … 1044 1044 [407510.08, 6437312.74]] 1045 1045 1046 ref_points += [[381178.09, 6452559.07], 1047 [381169.49, 6452566.64], 1048 [381157.78, 6452576.96], 1049 [381155.97, 6452578.56], 1050 [381143.72, 6452589.35], 1051 [381136.69, 6452595.54], 1052 [381114.74, 6452614.88], 1053 [381075.53, 6452649.43], 1054 [381071.47, 6452653.00], 1055 [381063.46, 6452660.06], 1056 [381054.41, 6452668.03]] 1057 1058 1046 ref_points += [[381178.09, 6452559.07], 1047 [381169.49, 6452566.64], 1048 [381157.78, 6452576.96], 1049 [381155.97, 6452578.56], 1050 [381143.72, 6452589.35], 1051 [381136.69, 6452595.54], 1052 [381114.74, 6452614.88], 1053 [381075.53, 6452649.43], 1054 [381071.47, 6452653.00], 1055 [381063.46, 6452660.06], 1056 [381054.41, 6452668.03]] 1057 1058 1059 1059 ref_elevation = [52.14, 51.07, 50.56, 49.58, 49.09, 48.76] 1060 1060 ref_elevation += [4.17, 4.26, 4.34, 4.35, 4.43, 4.58, 4.41, 4.17, 3.99, 3.67, 3.67] … … 1127 1127 verbose = False, 1128 1128 format = 'asc') 1129 1129 1130 1130 #Check prj (meta data) 1131 1131 prjid = open(prjfile) … … 1225 1225 cellsize 10.000000 1226 1226 NODATA_value -9999 1227 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 -200 1228 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 1229 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 1230 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 1231 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 1232 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 1227 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 -200 1228 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 -190 1229 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 -180 1230 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 -170 1231 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 -160 1232 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 -150 1233 1233 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 -140 1234 1234 -30 -40 -50 -60 -70 -80 -90 -100 -110 -120 -130 … … 1236 1236 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 -110 1237 1237 0 -10 -20 -30 -40 -50 -60 -70 -80 -90 -100 1238 1238 1239 1239 """ 1240 1240 … … 1267 1267 # 1268 1268 domain.set_quantity('elevation', lambda x,y: -x-y) 1269 domain.set_quantity('stage', 0) 1269 domain.set_quantity('stage', 0) 1270 1270 1271 1271 B = Transmissive_boundary(domain) … … 1283 1283 cellsize = 10 #10m grid 1284 1284 1285 1285 1286 1286 #Check contents 1287 1287 #Get NetCDF … … 1303 1303 verbose = False, 1304 1304 format = 'asc') 1305 1306 1305 1306 1307 1307 #Check prj (meta data) 1308 1308 prjid = open(prjfile) … … 1380 1380 #assert allclose(float(value), -(10-i+j)*cellsize) 1381 1381 assert float(value) == -(10-i+j)*cellsize 1382 1382 1383 1383 1384 1384 fid.close() … … 1398 1398 Original extent is 100m x 100m: 1399 1399 1400 Eastings: 308500 - 308600 1400 Eastings: 308500 - 308600 1401 1401 Northings: 6189000 - 6189100 1402 1402 1403 1403 Bounding box changes this to the 50m x 50m square defined by 1404 1404 1405 Eastings: 308530 - 308570 1405 Eastings: 308530 - 308570 1406 1406 Northings: 6189050 - 6189100 1407 1407 1408 1408 The cropped values should be 1409 1409 1410 -130 -140 -150 -160 -170 1411 -120 -130 -140 -150 -160 1412 -110 -120 -130 -140 -150 1413 -100 -110 -120 -130 -140 1414 -90 -100 -110 -120 -130 1410 -130 -140 -150 -160 -170 1411 -120 -130 -140 -150 -160 1412 -110 -120 -130 -140 -150 1413 -100 -110 -120 -130 -140 1414 -90 -100 -110 -120 -130 1415 1415 -80 -90 -100 -110 -120 1416 1416 1417 and the new lower reference point should be 1418 Eastings: 308530 1417 and the new lower reference point should be 1418 Eastings: 308530 1419 1419 Northings: 6189050 1420 1420 1421 1421 Original dataset is the same as in test_sww2dem_larger() 1422 1422 1423 1423 """ 1424 1424 … … 1451 1451 # 1452 1452 domain.set_quantity('elevation', lambda x,y: -x-y) 1453 domain.set_quantity('stage', 0) 1453 domain.set_quantity('stage', 0) 1454 1454 1455 1455 B = Transmissive_boundary(domain) … … 1467 1467 cellsize = 10 #10m grid 1468 1468 1469 1469 1470 1470 #Check contents 1471 1471 #Get NetCDF … … 1487 1487 easting_min = 308530, 1488 1488 easting_max = 308570, 1489 northing_min = 6189050, 1490 northing_max = 6189100, 1489 northing_min = 6189050, 1490 northing_max = 6189100, 1491 1491 verbose = False, 1492 1492 format = 'asc') 1493 1494 fid.close() 1495 1496 1493 1494 fid.close() 1495 1496 1497 1497 #Check prj (meta data) 1498 1498 prjid = open(prjfile) … … 1568 1568 for i, line in enumerate(lines[6:]): 1569 1569 for j, value in enumerate( line.split() ): 1570 #assert float(value) == -(10-i+j)*cellsize 1570 #assert float(value) == -(10-i+j)*cellsize 1571 1571 assert float(value) == -(10-i+j+3)*cellsize 1572 1572 1573 1573 1574 1574 … … 2000 2000 # cellsize = cellsize, 2001 2001 # verbose = False) 2002 2002 2003 2003 sww2dem(self.domain.filename, 2004 2004 quantity = 'elevation', … … 2010 2010 #Check header data 2011 2011 from ermapper_grids import read_ermapper_header, read_ermapper_data 2012 2012 2013 2013 header = read_ermapper_header(self.domain.filename + '_elevation.ers') 2014 2014 #print header 2015 2015 assert header['projection'].lower() == '"utm-56"' 2016 2016 assert header['datum'].lower() == '"wgs84"' 2017 assert header['units'].lower() == '"meters"' 2018 assert header['value'].lower() == '"elevation"' 2017 assert header['units'].lower() == '"meters"' 2018 assert header['value'].lower() == '"elevation"' 2019 2019 assert header['xdimension'] == '0.25' 2020 assert header['ydimension'] == '0.25' 2020 assert header['ydimension'] == '0.25' 2021 2021 assert float(header['eastings']) == 308500.0 #xllcorner 2022 assert float(header['northings']) == 6189000.0 #yllcorner 2022 assert float(header['northings']) == 6189000.0 #yllcorner 2023 2023 assert int(header['nroflines']) == 5 2024 assert int(header['nrofcellsperline']) == 5 2024 assert int(header['nrofcellsperline']) == 5 2025 2025 assert int(header['nullcellvalue']) == NODATA_value 2026 #FIXME - there is more in the header 2027 2028 2029 #Check grid data 2030 grid = read_ermapper_data(self.domain.filename + '_elevation') 2031 2026 #FIXME - there is more in the header 2027 2028 2029 #Check grid data 2030 grid = read_ermapper_data(self.domain.filename + '_elevation') 2031 2032 2032 #FIXME (Ole): Why is this the desired reference grid for -x-y? 2033 2033 ref_grid = [NODATA_value, NODATA_value, NODATA_value, NODATA_value, NODATA_value, 2034 2034 -1, -1.25, -1.5, -1.75, -2.0, 2035 -0.75, -1.0, -1.25, -1.5, -1.75, 2035 -0.75, -1.0, -1.25, -1.5, -1.75, 2036 2036 -0.5, -0.75, -1.0, -1.25, -1.5, 2037 -0.25, -0.5, -0.75, -1.0, -1.25] 2038 2037 -0.25, -0.5, -0.75, -1.0, -1.25] 2038 2039 2039 2040 2040 #print grid … … 2042 2042 2043 2043 fid.close() 2044 2044 2045 2045 #Cleanup 2046 2046 #FIXME the file clean-up doesn't work (eg Permission Denied Error) 2047 #Done (Ole) - it was because sww2ers didn't close it's sww file 2047 #Done (Ole) - it was because sww2ers didn't close it's sww file 2048 2048 os.remove(sww.filename) 2049 2049 os.remove(self.domain.filename + '_elevation') 2050 os.remove(self.domain.filename + '_elevation.ers') 2050 os.remove(self.domain.filename + '_elevation.ers') 2051 2051 2052 2052 … … 2067 2067 # Fourth value (index==3) is -6.50198 cm 2068 2068 2069 2069 2070 2070 2071 2071 #Read 2072 2072 from coordinate_transforms.redfearn import redfearn 2073 2073 #fid = NetCDFFile(self.test_MOST_file) 2074 fid = NetCDFFile(self.test_MOST_file + '_ha.nc') 2074 fid = NetCDFFile(self.test_MOST_file + '_ha.nc') 2075 2075 first_value = fid.variables['HA'][:][0,0,0] 2076 2076 fourth_value = fid.variables['HA'][:][0,0,3] … … 2090 2090 #Read output file 'small.sww' 2091 2091 #fid = NetCDFFile('small.sww') 2092 fid = NetCDFFile(self.test_MOST_file + '.sww') 2092 fid = NetCDFFile(self.test_MOST_file + '.sww') 2093 2093 2094 2094 x = fid.variables['x'][:] … … 2211 2211 h2_list = [-34.5,-34.33333] 2212 2212 2213 2213 long_name = 'LON' 2214 2214 lat_name = 'LAT' 2215 time_name = 'TIME' 2215 time_name = 'TIME' 2216 2216 2217 2217 nx = 3 … … 2253 2253 2254 2254 name = {} 2255 2256 2257 2258 2255 name[fid1]='HA' 2256 name[fid2]='UA' 2257 name[fid3]='VA' 2258 name[fid4]='ELEVATION' 2259 2259 2260 2260 units = {} 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2261 units[fid1]='cm' 2262 units[fid2]='cm/s' 2263 units[fid3]='cm/s' 2264 units[fid4]='m' 2265 2266 values = {} 2267 values[fid1]=[[[5., 10.,15.], [13.,18.,23.]],[[50.,100.,150.],[130.,180.,230.]]] 2268 values[fid2]=[[[1., 2.,3.], [4.,5.,6.]],[[7.,8.,9.],[10.,11.,12.]]] 2269 values[fid3]=[[[13., 12.,11.], [10.,9.,8.]],[[7.,6.,5.],[4.,3.,2.]]] 2270 values[fid4]=[[-3000,-3100,-3200],[-4000,-5000,-6000]] 2271 2271 2272 2272 for fid in [fid1,fid2,fid3]: … … 2276 2276 fid.variables[name[fid]].assignValue(values[fid]) 2277 2277 fid.variables[name[fid]].missing_value = -99999999. 2278 2278 if fid == fid3: break 2279 2279 2280 2280 for fid in [fid4]: 2281 2281 fid.createVariable(name[fid],'d',(lat_name,long_name)) 2282 2282 fid.variables[name[fid]].point_spacing='uneven' 2283 2283 fid.variables[name[fid]].units=units[fid] … … 2323 2323 elevation = fid.variables['elevation'][:] 2324 2324 stage = fid.variables['stage'][:] 2325 2326 2327 2328 2325 xmomentum = fid.variables['xmomentum'][:] 2326 ymomentum = fid.variables['ymomentum'][:] 2327 2328 #print ymomentum 2329 2329 first_height = first_amp/100 - first_elevation 2330 2330 third_height = third_amp/100 - third_elevation … … 2371 2371 h2_list = [-34.5,-34.33333] 2372 2372 2373 long_name = 'LON961_1261' 2374 lat_name = 'LAT481_841' 2375 time_name = 'TIME1' 2373 # long_name = 'LON961_1261' 2374 # lat_name = 'LAT481_841' 2375 # time_name = 'TIME1' 2376 2377 long_name = 'LON' 2378 lat_name = 'LAT' 2379 time_name = 'TIME' 2376 2380 2377 2381 nx = 3 … … 2413 2417 2414 2418 name = {} 2415 2416 2417 2418 2419 name[fid1]='HA' 2420 name[fid2]='UA' 2421 name[fid3]='VA' 2422 name[fid4]='ELEVATION' 2419 2423 2420 2424 units = {} 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2425 units[fid1]='cm' 2426 units[fid2]='cm/s' 2427 units[fid3]='cm/s' 2428 units[fid4]='m' 2429 2430 values = {} 2431 values[fid1]=[[[5., 10.,15.], [13.,18.,23.]],[[50.,100.,150.],[130.,180.,230.]]] 2432 values[fid2]=[[[1., 2.,3.], [4.,5.,6.]],[[7.,8.,9.],[10.,11.,12.]]] 2433 values[fid3]=[[[13., 12.,11.], [10.,9.,8.]],[[7.,6.,5.],[4.,3.,2.]]] 2434 values[fid4]=[[-3000,-3100,-3200],[-4000,-5000,-6000]] 2431 2435 2432 2436 for fid in [fid1,fid2,fid3]: … … 2436 2440 fid.variables[name[fid]].assignValue(values[fid]) 2437 2441 fid.variables[name[fid]].missing_value = -99999999. 2438 2442 if fid == fid3: break 2439 2443 2440 2444 for fid in [fid4]: … … 2468 2472 2469 2473 #Call conversion (with zero origin) 2470 ferret2sww('test', verbose=False, 2471 origin = (56, 0, 0)) 2474 ferret2sww('test', verbose=False, origin = (56, 0, 0)) 2472 2475 2473 2476 os.remove('test_va.nc') … … 2483 2486 elevation = fid.variables['elevation'][:] 2484 2487 stage = fid.variables['stage'][:] 2485 2486 2487 2488 2488 xmomentum = fid.variables['xmomentum'][:] 2489 ymomentum = fid.variables['ymomentum'][:] 2490 2491 #print ymomentum 2489 2492 first_height = first_amp/100 - first_elevation 2490 2493 third_height = third_amp/100 - third_elevation … … 2518 2521 #fid = NetCDFFile('small.sww', 'r') 2519 2522 fid = NetCDFFile(self.test_MOST_file + '.sww') 2520 2523 2521 2524 x = fid.variables['x'][:] 2522 2525 y = fid.variables['y'][:] … … 2642 2645 2643 2646 #os.remove(domain.filename + '.sww') 2644 os.remove(filename) 2647 os.remove(filename) 2645 2648 2646 2649 bits = ['vertex_coordinates'] … … 2782 2785 #Clean up 2783 2786 os.remove(filename) 2784 2787 2785 2788 2786 2789 bits = [ 'geo_reference.get_xllcorner()', … … 3204 3207 3205 3208 os.remove(filename) 3206 3209 3207 3210 def test_asc_csiro2sww(self): 3208 3211 import tempfile 3209 3212 3210 3213 bath_dir = tempfile.mkdtemp() 3211 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3214 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3212 3215 #bath_dir = 'bath_data_manager_test' 3213 #print "os.getcwd( )",os.getcwd( ) 3216 #print "os.getcwd( )",os.getcwd( ) 3214 3217 elevation_dir = tempfile.mkdtemp() 3215 3218 #elevation_dir = 'elev_expanded' 3216 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3217 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3218 3219 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3220 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3221 3219 3222 fid = open(bath_dir_filename, 'w') 3220 3223 fid.write(""" ncols 3 … … 3225 3228 nodata_value -9999.0 3226 3229 9000.000 -1000.000 3000.0 3227 -1000.000 9000.000 -1000.000 3230 -1000.000 9000.000 -1000.000 3228 3231 """) 3229 3232 fid.close() 3230 3233 3231 3234 fid = open(elevation_dir_filename1, 'w') 3232 3235 fid.write(""" ncols 3 … … 3237 3240 nodata_value -9999.0 3238 3241 9000.000 0.000 3000.0 3239 0.000 9000.000 0.000 3242 0.000 9000.000 0.000 3240 3243 """) 3241 3244 fid.close() … … 3249 3252 nodata_value -9999.0 3250 3253 9000.000 4000.000 4000.0 3251 4000.000 9000.000 4000.000 3254 4000.000 9000.000 4000.000 3252 3255 """) 3253 3256 fid.close() 3254 3257 3255 3258 ucur_dir = tempfile.mkdtemp() 3256 3259 ucur_dir_filename1 = ucur_dir + os.sep +'uc19940524.000' 3257 3260 ucur_dir_filename2 = ucur_dir + os.sep +'uc19940524.001' 3258 3261 3259 3262 fid = open(ucur_dir_filename1, 'w') 3260 3263 fid.write(""" ncols 3 … … 3265 3268 nodata_value -9999.0 3266 3269 90.000 60.000 30.0 3267 10.000 10.000 10.000 3270 10.000 10.000 10.000 3268 3271 """) 3269 3272 fid.close() … … 3276 3279 nodata_value -9999.0 3277 3280 90.000 60.000 30.0 3278 10.000 10.000 10.000 3281 10.000 10.000 10.000 3279 3282 """) 3280 3283 fid.close() 3281 3284 3282 3285 vcur_dir = tempfile.mkdtemp() 3283 3286 vcur_dir_filename1 = vcur_dir + os.sep +'vc19940524.000' 3284 3287 vcur_dir_filename2 = vcur_dir + os.sep +'vc19940524.001' 3285 3288 3286 3289 fid = open(vcur_dir_filename1, 'w') 3287 3290 fid.write(""" ncols 3 … … 3292 3295 nodata_value -9999.0 3293 3296 90.000 60.000 30.0 3294 10.000 10.000 10.000 3297 10.000 10.000 10.000 3295 3298 """) 3296 3299 fid.close() … … 3303 3306 nodata_value -9999.0 3304 3307 90.000 60.000 30.0 3305 10.000 10.000 10.000 3308 10.000 10.000 10.000 3306 3309 """) 3307 3310 fid.close() 3308 3311 3309 3312 sww_file = 'a_test.sww' 3310 3313 asc_csiro2sww(bath_dir,elevation_dir, ucur_dir, vcur_dir, sww_file) 3311 3314 3312 3315 # check the sww file 3313 3316 3314 3317 fid = NetCDFFile(sww_file, 'r') #Open existing file for read 3315 3318 x = fid.variables['x'][:] … … 3319 3322 xmomentum = fid.variables['xmomentum'][:] 3320 3323 geo_ref = Geo_reference(NetCDFObject=fid) 3321 #print "geo_ref",geo_ref 3324 #print "geo_ref",geo_ref 3322 3325 x_ref = geo_ref.get_xllcorner() 3323 3326 y_ref = geo_ref.get_yllcorner() … … 3325 3328 assert allclose(x_ref, 587798.418) # (-38, 148) 3326 3329 assert allclose(y_ref, 5793123.477)# (-38, 148.5) 3327 3328 #Zone: 55 3329 #Easting: 588095.674 Northing: 5821451.722 3330 3331 #Zone: 55 3332 #Easting: 588095.674 Northing: 5821451.722 3330 3333 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 0 ' 0.00000 '' 3331 3334 assert allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref)) 3332 3335 3333 #Zone: 55 3334 #Easting: 632145.632 Northing: 5820863.269 3335 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3336 #Zone: 55 3337 #Easting: 632145.632 Northing: 5820863.269 3338 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3336 3339 assert allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref)) 3337 3340 3338 #Zone: 55 3339 #Easting: 609748.788 Northing: 5793447.860 3340 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 3341 #Zone: 55 3342 #Easting: 609748.788 Northing: 5793447.860 3343 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 3341 3344 assert allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref)) 3342 3345 … … 3346 3349 #(4000+1000)*60 3347 3350 assert allclose(xmomentum[1][1],300000.0 ) 3348 3349 3350 fid.close() 3351 3351 3352 3353 fid.close() 3354 3352 3355 #tidy up 3353 3356 os.remove(bath_dir_filename) … … 3357 3360 os.remove(elevation_dir_filename2) 3358 3361 os.rmdir(elevation_dir) 3359 3362 3360 3363 os.remove(ucur_dir_filename1) 3361 3364 os.remove(ucur_dir_filename2) 3362 3365 os.rmdir(ucur_dir) 3363 3366 3364 3367 os.remove(vcur_dir_filename1) 3365 3368 os.remove(vcur_dir_filename2) … … 3369 3372 # remove sww file 3370 3373 os.remove(sww_file) 3371 3374 3372 3375 def test_asc_csiro2sww2(self): 3373 3376 import tempfile 3374 3377 3375 3378 bath_dir = tempfile.mkdtemp() 3376 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3379 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3377 3380 #bath_dir = 'bath_data_manager_test' 3378 #print "os.getcwd( )",os.getcwd( ) 3381 #print "os.getcwd( )",os.getcwd( ) 3379 3382 elevation_dir = tempfile.mkdtemp() 3380 3383 #elevation_dir = 'elev_expanded' 3381 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3382 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3383 3384 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3385 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3386 3384 3387 fid = open(bath_dir_filename, 'w') 3385 3388 fid.write(""" ncols 3 … … 3390 3393 nodata_value -9999.0 3391 3394 9000.000 -1000.000 3000.0 3392 -1000.000 9000.000 -1000.000 3395 -1000.000 9000.000 -1000.000 3393 3396 """) 3394 3397 fid.close() 3395 3398 3396 3399 fid = open(elevation_dir_filename1, 'w') 3397 3400 fid.write(""" ncols 3 … … 3402 3405 nodata_value -9999.0 3403 3406 9000.000 0.000 3000.0 3404 0.000 -9999.000 -9999.000 3407 0.000 -9999.000 -9999.000 3405 3408 """) 3406 3409 fid.close() … … 3414 3417 nodata_value -9999.0 3415 3418 9000.000 4000.000 4000.0 3416 4000.000 9000.000 4000.000 3419 4000.000 9000.000 4000.000 3417 3420 """) 3418 3421 fid.close() 3419 3422 3420 3423 ucur_dir = tempfile.mkdtemp() 3421 3424 ucur_dir_filename1 = ucur_dir + os.sep +'uc19940524.000' 3422 3425 ucur_dir_filename2 = ucur_dir + os.sep +'uc19940524.001' 3423 3426 3424 3427 fid = open(ucur_dir_filename1, 'w') 3425 3428 fid.write(""" ncols 3 … … 3430 3433 nodata_value -9999.0 3431 3434 90.000 60.000 30.0 3432 10.000 10.000 10.000 3435 10.000 10.000 10.000 3433 3436 """) 3434 3437 fid.close() … … 3441 3444 nodata_value -9999.0 3442 3445 90.000 60.000 30.0 3443 10.000 10.000 10.000 3446 10.000 10.000 10.000 3444 3447 """) 3445 3448 fid.close() 3446 3449 3447 3450 vcur_dir = tempfile.mkdtemp() 3448 3451 vcur_dir_filename1 = vcur_dir + os.sep +'vc19940524.000' 3449 3452 vcur_dir_filename2 = vcur_dir + os.sep +'vc19940524.001' 3450 3453 3451 3454 fid = open(vcur_dir_filename1, 'w') 3452 3455 fid.write(""" ncols 3 … … 3457 3460 nodata_value -9999.0 3458 3461 90.000 60.000 30.0 3459 10.000 10.000 10.000 3462 10.000 10.000 10.000 3460 3463 """) 3461 3464 fid.close() … … 3468 3471 nodata_value -9999.0 3469 3472 90.000 60.000 30.0 3470 10.000 10.000 10.000 3473 10.000 10.000 10.000 3471 3474 """) 3472 3475 fid.close() 3473 3476 3474 3477 try: 3475 3478 asc_csiro2sww(bath_dir,elevation_dir, ucur_dir, … … 3483 3486 os.remove(elevation_dir_filename2) 3484 3487 os.rmdir(elevation_dir) 3485 3488 3486 3489 os.remove(ucur_dir_filename1) 3487 3490 os.remove(ucur_dir_filename2) 3488 3491 os.rmdir(ucur_dir) 3489 3492 3490 3493 os.remove(vcur_dir_filename1) 3491 3494 os.remove(vcur_dir_filename2) … … 3500 3503 os.rmdir(elevation_dir) 3501 3504 raise 'Should raise exception' 3502 3505 3503 3506 os.remove(ucur_dir_filename1) 3504 3507 os.remove(ucur_dir_filename2) 3505 3508 os.rmdir(ucur_dir) 3506 3509 3507 3510 os.remove(vcur_dir_filename1) 3508 3511 os.remove(vcur_dir_filename2) 3509 3512 os.rmdir(vcur_dir) 3510 3513 3511 3512 3514 3515 3513 3516 def test_asc_csiro2sww3(self): 3514 3517 import tempfile 3515 3518 3516 3519 bath_dir = tempfile.mkdtemp() 3517 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3520 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3518 3521 #bath_dir = 'bath_data_manager_test' 3519 #print "os.getcwd( )",os.getcwd( ) 3522 #print "os.getcwd( )",os.getcwd( ) 3520 3523 elevation_dir = tempfile.mkdtemp() 3521 3524 #elevation_dir = 'elev_expanded' 3522 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3523 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3524 3525 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3526 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3527 3525 3528 fid = open(bath_dir_filename, 'w') 3526 3529 fid.write(""" ncols 3 … … 3531 3534 nodata_value -9999.0 3532 3535 9000.000 -1000.000 3000.0 3533 -1000.000 9000.000 -1000.000 3536 -1000.000 9000.000 -1000.000 3534 3537 """) 3535 3538 fid.close() 3536 3539 3537 3540 fid = open(elevation_dir_filename1, 'w') 3538 3541 fid.write(""" ncols 3 … … 3543 3546 nodata_value -9999.0 3544 3547 9000.000 0.000 3000.0 3545 0.000 -9999.000 -9999.000 3548 0.000 -9999.000 -9999.000 3546 3549 """) 3547 3550 fid.close() … … 3555 3558 nodata_value -9999.0 3556 3559 9000.000 4000.000 4000.0 3557 4000.000 9000.000 4000.000 3560 4000.000 9000.000 4000.000 3558 3561 """) 3559 3562 fid.close() 3560 3563 3561 3564 ucur_dir = tempfile.mkdtemp() 3562 3565 ucur_dir_filename1 = ucur_dir + os.sep +'uc19940524.000' 3563 3566 ucur_dir_filename2 = ucur_dir + os.sep +'uc19940524.001' 3564 3567 3565 3568 fid = open(ucur_dir_filename1, 'w') 3566 3569 fid.write(""" ncols 3 … … 3571 3574 nodata_value -9999.0 3572 3575 90.000 60.000 30.0 3573 10.000 10.000 10.000 3576 10.000 10.000 10.000 3574 3577 """) 3575 3578 fid.close() … … 3582 3585 nodata_value -9999.0 3583 3586 90.000 60.000 30.0 3584 10.000 10.000 10.000 3587 10.000 10.000 10.000 3585 3588 """) 3586 3589 fid.close() 3587 3590 3588 3591 vcur_dir = tempfile.mkdtemp() 3589 3592 vcur_dir_filename1 = vcur_dir + os.sep +'vc19940524.000' 3590 3593 vcur_dir_filename2 = vcur_dir + os.sep +'vc19940524.001' 3591 3594 3592 3595 fid = open(vcur_dir_filename1, 'w') 3593 3596 fid.write(""" ncols 3 … … 3598 3601 nodata_value -9999.0 3599 3602 90.000 60.000 30.0 3600 10.000 10.000 10.000 3603 10.000 10.000 10.000 3601 3604 """) 3602 3605 fid.close() … … 3609 3612 nodata_value -9999.0 3610 3613 90.000 60.000 30.0 3611 10.000 10.000 10.000 3614 10.000 10.000 10.000 3612 3615 """) 3613 3616 fid.close() 3614 3617 3615 3618 sww_file = 'a_test.sww' 3616 3619 asc_csiro2sww(bath_dir,elevation_dir, ucur_dir, vcur_dir, … … 3619 3622 3620 3623 # check the sww file 3621 3624 3622 3625 fid = NetCDFFile(sww_file, 'r') #Open existing file for read 3623 3626 x = fid.variables['x'][:] … … 3627 3630 xmomentum = fid.variables['xmomentum'][:] 3628 3631 geo_ref = Geo_reference(NetCDFObject=fid) 3629 #print "geo_ref",geo_ref 3632 #print "geo_ref",geo_ref 3630 3633 x_ref = geo_ref.get_xllcorner() 3631 3634 y_ref = geo_ref.get_yllcorner() … … 3633 3636 assert allclose(x_ref, 587798.418) # (-38, 148) 3634 3637 assert allclose(y_ref, 5793123.477)# (-38, 148.5) 3635 3636 #Zone: 55 3637 #Easting: 588095.674 Northing: 5821451.722 3638 3639 #Zone: 55 3640 #Easting: 588095.674 Northing: 5821451.722 3638 3641 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 0 ' 0.00000 '' 3639 3642 assert allclose((x[0],y[0]), (588095.674 - x_ref, 5821451.722 - y_ref)) 3640 3643 3641 #Zone: 55 3642 #Easting: 632145.632 Northing: 5820863.269 3643 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3644 #Zone: 55 3645 #Easting: 632145.632 Northing: 5820863.269 3646 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3644 3647 assert allclose((x[2],y[2]), (632145.632 - x_ref, 5820863.269 - y_ref)) 3645 3648 3646 #Zone: 55 3647 #Easting: 609748.788 Northing: 5793447.860 3648 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 3649 #Zone: 55 3650 #Easting: 609748.788 Northing: 5793447.860 3651 #Latitude: -38 0 ' 0.00000 '' Longitude: 148 15 ' 0.00000 '' 3649 3652 assert allclose((x[4],y[4]), (609748.788 - x_ref, 5793447.86 - y_ref)) 3650 3653 … … 3655 3658 #(100.0 - 9000)*10 3656 3659 assert allclose(xmomentum[0][4], -89000.0 ) 3657 3660 3658 3661 #(100.0 - -1000.000)*10 3659 3662 assert allclose(xmomentum[0][5], 11000.0 ) 3660 3661 fid.close() 3662 3663 3664 fid.close() 3665 3663 3666 #tidy up 3664 3667 os.remove(bath_dir_filename) … … 3668 3671 os.remove(elevation_dir_filename2) 3669 3672 os.rmdir(elevation_dir) 3670 3673 3671 3674 os.remove(ucur_dir_filename1) 3672 3675 os.remove(ucur_dir_filename2) 3673 3676 os.rmdir(ucur_dir) 3674 3677 3675 3678 os.remove(vcur_dir_filename1) 3676 3679 os.remove(vcur_dir_filename2) … … 3679 3682 # remove sww file 3680 3683 os.remove(sww_file) 3681 3682 3684 3685 3683 3686 def test_asc_csiro2sww4(self): 3684 3687 """ 3685 3688 Test specifying the extent 3686 3689 """ 3687 3690 3688 3691 import tempfile 3689 3692 3690 3693 bath_dir = tempfile.mkdtemp() 3691 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3694 bath_dir_filename = bath_dir + os.sep +'ba19940524.000' 3692 3695 #bath_dir = 'bath_data_manager_test' 3693 #print "os.getcwd( )",os.getcwd( ) 3696 #print "os.getcwd( )",os.getcwd( ) 3694 3697 elevation_dir = tempfile.mkdtemp() 3695 3698 #elevation_dir = 'elev_expanded' 3696 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3697 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3698 3699 elevation_dir_filename1 = elevation_dir + os.sep +'el19940524.000' 3700 elevation_dir_filename2 = elevation_dir + os.sep +'el19940524.001' 3701 3699 3702 fid = open(bath_dir_filename, 'w') 3700 3703 fid.write(""" ncols 4 … … 3710 3713 """) 3711 3714 fid.close() 3712 3715 3713 3716 fid = open(elevation_dir_filename1, 'w') 3714 3717 fid.write(""" ncols 4 … … 3738 3741 """) 3739 3742 fid.close() 3740 3743 3741 3744 ucur_dir = tempfile.mkdtemp() 3742 3745 ucur_dir_filename1 = ucur_dir + os.sep +'uc19940524.000' 3743 3746 ucur_dir_filename2 = ucur_dir + os.sep +'uc19940524.001' 3744 3747 3745 3748 fid = open(ucur_dir_filename1, 'w') 3746 3749 fid.write(""" ncols 4 … … 3769 3772 """) 3770 3773 fid.close() 3771 3774 3772 3775 vcur_dir = tempfile.mkdtemp() 3773 3776 vcur_dir_filename1 = vcur_dir + os.sep +'vc19940524.000' 3774 3777 vcur_dir_filename2 = vcur_dir + os.sep +'vc19940524.001' 3775 3778 3776 3779 fid = open(vcur_dir_filename1, 'w') 3777 3780 fid.write(""" ncols 4 … … 3800 3803 """) 3801 3804 fid.close() 3802 3805 3803 3806 sww_file = tempfile.mktemp(".sww") 3804 3807 #sww_file = 'a_test.sww' … … 3812 3815 3813 3816 # check the sww file 3814 3817 3815 3818 fid = NetCDFFile(sww_file, 'r') #Open existing file for read 3816 3819 x = fid.variables['x'][:] … … 3821 3824 ymomentum = fid.variables['ymomentum'][:] 3822 3825 geo_ref = Geo_reference(NetCDFObject=fid) 3823 #print "geo_ref",geo_ref 3826 #print "geo_ref",geo_ref 3824 3827 x_ref = geo_ref.get_xllcorner() 3825 3828 y_ref = geo_ref.get_yllcorner() … … 3830 3833 assert allclose(y_ref, 5820863.269 )# (-37.45, 148.5) 3831 3834 3832 #Easting: 632145.632 Northing: 5820863.269 3833 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3834 3835 #Easting: 632145.632 Northing: 5820863.269 3836 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3837 3835 3838 #print "x",x 3836 #print "y",y 3839 #print "y",y 3837 3840 self.failUnless(len(x) == 4,'failed') # 2*2 3838 3841 self.failUnless(len(x) == 4,'failed') # 2*2 3839 3842 3840 3843 #Zone: 55 3841 #Easting: 632145.632 Northing: 5820863.269 3844 #Easting: 632145.632 Northing: 5820863.269 3842 3845 #Latitude: -37 45 ' 0.00000 '' Longitude: 148 30 ' 0.00000 '' 3843 # magic number - y is close enough for me. 3846 # magic number - y is close enough for me. 3844 3847 assert allclose(x[3], 632145.63 - x_ref) 3845 3848 assert allclose(y[3], 5820863.269 - y_ref + 5.22155314684e-005) 3846 3849 3847 3850 assert allclose(z[0],9000.0 ) #z is elevation info 3848 #print "z",z 3851 #print "z",z 3849 3852 # 2 time steps, 4 points 3850 self.failUnless(xmomentum.shape == (2,4), 'failed') 3851 self.failUnless(ymomentum.shape == (2,4), 'failed') 3852 3853 self.failUnless(xmomentum.shape == (2,4), 'failed') 3854 self.failUnless(ymomentum.shape == (2,4), 'failed') 3855 3853 3856 #(100.0 - -1000.000)*10 3854 3857 #assert allclose(xmomentum[0][5], 11000.0 ) 3855 3856 fid.close() 3857 3858 3859 fid.close() 3860 3858 3861 # is the sww file readable? 3859 3862 #Lets see if we can convert it to a dem! 3860 #print "sww_file",sww_file 3863 #print "sww_file",sww_file 3861 3864 #dem_file = tempfile.mktemp(".dem") 3862 3865 domain = sww2domain(sww_file) ###, dem_file) … … 3870 3873 os.remove(elevation_dir_filename2) 3871 3874 os.rmdir(elevation_dir) 3872 3875 3873 3876 os.remove(ucur_dir_filename1) 3874 3877 os.remove(ucur_dir_filename2) 3875 3878 os.rmdir(ucur_dir) 3876 3879 3877 3880 os.remove(vcur_dir_filename1) 3878 3881 os.remove(vcur_dir_filename2) … … 3880 3883 3881 3884 3882 3883 3885 3886 3884 3887 # remove sww file 3885 3888 os.remove(sww_file) 3886 3889 3887 3890 # remove dem file 3888 3891 #os.remove(dem_file) … … 3907 3910 longitudes == longitudes_news, 3908 3911 'failed') 3909 3912 3910 3913 ## 2nd test 3911 3914 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( … … 3918 3921 #print "latitudes_new", latitudes_new 3919 3922 #print "longitudes_news",longitudes_news 3920 3923 3921 3924 self.failUnless(latitudes == latitudes_new and \ 3922 3925 longitudes == longitudes_news, 3923 3926 'failed') 3924 3927 3925 3928 ## 3rd test 3926 3929 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes(latitudes, … … 3933 3936 #print "latitudes_new", latitudes_new 3934 3937 #print "longitudes_news",longitudes_news 3935 3938 3936 3939 self.failUnless(latitudes_new == [2, 1] and \ 3937 3940 longitudes_news == [10, 20], 3938 3941 'failed') 3939 3942 3940 3943 3941 3944 ## 4th test 3942 3945 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( … … 3949 3952 #print "latitudes_new", latitudes_new 3950 3953 #print "longitudes_news",longitudes_news 3951 3954 3952 3955 self.failUnless(latitudes_new == [2, 1, 0] and \ 3953 3956 longitudes_news == [0, 10, 20], … … 3963 3966 #print "latitudes_new", latitudes_new 3964 3967 #print "longitudes_news",longitudes_news 3965 3968 3966 3969 self.failUnless(latitudes_new == [2, 1, 0] and \ 3967 3970 longitudes_news == [0, 10, 20], 3968 3971 'failed') 3969 3972 3970 3973 ## 6th test 3971 3974 3972 3975 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( 3973 3976 latitudes,longitudes, … … 3979 3982 #print "latitudes_new", latitudes_new 3980 3983 #print "longitudes_news",longitudes_news 3981 3984 3982 3985 self.failUnless(latitudes_new == [3, 2, 1] and \ 3983 3986 longitudes_news == [10, 20, 30], 3984 3987 'failed') 3985 3986 3988 3989 3987 3990 ## 7th test 3988 3991 m2d = array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) … … 3995 3998 longitudes_news = longitudes[lmin:lmax] 3996 3999 m2d = m2d[kmin:kmax,lmin:lmax] 3997 #print "m2d", m2d 4000 #print "m2d", m2d 3998 4001 #print "latitudes_new", latitudes_new 3999 4002 #print "longitudes_news",longitudes_news 4000 4003 4001 4004 self.failUnless(latitudes_new == [2, 1] and \ 4002 4005 longitudes_news == [10, 20], 4003 4006 'failed') 4004 4007 4005 4008 self.failUnless(m2d == [[5,6],[9,10]], 4006 4009 'failed') 4007 4010 4008 4011 def test_get_min_max_indexes2(self): 4009 4012 latitudes = [-30,-35,-40,-45] … … 4011 4014 4012 4015 m2d = array([[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]) 4013 4016 4014 4017 # k - lat 4015 4018 # l - lon … … 4020 4023 #print "kmin",kmin;print "kmax",kmax 4021 4024 #print "lmin",lmin;print "lmax",lmax 4022 #print "m2d", m2d 4025 #print "m2d", m2d 4023 4026 #print "latitudes", latitudes 4024 4027 #print "longitudes",longitudes 4025 #print "latitudes[kmax]", latitudes[kmax] 4028 #print "latitudes[kmax]", latitudes[kmax] 4026 4029 latitudes_new = latitudes[kmin:kmax] 4027 4030 longitudes_new = longitudes[lmin:lmax] … … 4030 4033 #print "latitudes_new", latitudes_new 4031 4034 #print "longitudes_new",longitudes_new 4032 4035 4033 4036 self.failUnless(latitudes_new == [-30, -35, -40] and \ 4034 4037 longitudes_new == [148, 149,150], … … 4036 4039 self.failUnless(m2d == [[0,1,2],[4,5,6],[8,9,10]], 4037 4040 'failed') 4038 4041 4039 4042 def test_get_min_max_indexes3(self): 4040 4043 latitudes = [-30,-35,-40,-45,-50,-55,-60] … … 4047 4050 -43,-37,148.5,149.5) 4048 4051 4049 4052 4050 4053 #print "kmin",kmin;print "kmax",kmax 4051 4054 #print "lmin",lmin;print "lmax",lmax … … 4056 4059 #print "latitudes_new", latitudes_new 4057 4060 #print "longitudes_news",longitudes_news 4058 4061 4059 4062 self.failUnless(latitudes_new == [-35, -40, -45] and \ 4060 4063 longitudes_news == [148, 149,150], 4061 4064 'failed') 4062 4065 4063 4066 def test_get_min_max_indexes4(self): 4064 4067 latitudes = [-30,-35,-40,-45,-50,-55,-60] … … 4069 4072 kmin, kmax, lmin, lmax = data_manager._get_min_max_indexes( 4070 4073 latitudes,longitudes) 4071 4074 4072 4075 #print "kmin",kmin;print "kmax",kmax 4073 4076 #print "lmin",lmin;print "lmax",lmax … … 4078 4081 #print "latitudes_new", latitudes_new 4079 4082 #print "longitudes_news",longitudes_news 4080 4083 4081 4084 self.failUnless(latitudes_new == latitudes and \ 4082 4085 longitudes_news == longitudes, 4083 4086 'failed') 4084 4087 4085 4088 def test_tsh2sww(self): 4086 4089 import os 4087 4090 import tempfile 4088 4091 4089 4092 tsh_file = tempfile.mktemp(".tsh") 4090 4093 file = open(tsh_file,"w") … … 4124 4127 4125 4128 #sww_file = tempfile.mktemp(".sww") 4126 #print "sww_file",sww_file 4129 #print "sww_file",sww_file 4127 4130 #print "sww_file",tsh_file 4128 4131 tsh2sww(tsh_file) … … 4135 4138 suite = unittest.makeSuite(Test_Data_Manager,'test') 4136 4139 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_asc_missing_points') 4137 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_asc_elevation') 4140 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_asc_elevation') 4138 4141 #suite = unittest.makeSuite(Test_Data_Manager,'test_dem2pts_bounding_box') 4139 4142 #suite = unittest.makeSuite(Test_Data_Manager,'test_decimate_dem') … … 4141 4144 runner = unittest.TextTestRunner() 4142 4145 runner.run(suite) 4143 4146 4144 4147 4145 4148 … … 4378 4381 if i == 3 and j == 3: z = NODATA_value 4379 4382 4380 4383 4381 4384 if z <> NODATA_value: 4382 4385 new_ref_elev.append(z) 4383 4386 new_ref_pts.append( [x,y] ) 4384 4387 4385 4388 ref_points.append( [x,y] ) 4386 4389 ref_elevation.append(z) … … 4391 4394 fid.close() 4392 4395 4393 4396 4394 4397 #Write prj file with metadata 4395 4398 metafilename = root+'.prj' … … 4482 4485 new_ref_elev1.append(z) 4483 4486 new_ref_pts1.append( [x,y] ) 4484 4487 4485 4488 ref_points.append( [x,y] ) 4486 4489 ref_elevation.append(z) … … 4506 4509 """) 4507 4510 fid.close() 4508 4511 4509 4512 #Convert to NetCDF pts 4510 4513 convert_dem_from_ascii2netcdf(root) … … 4549 4552 new_ref_pts2.append( [x_new,y_new] ) 4550 4553 4551 4554 4552 4555 ref_points.append( [x_new,y_new] ) 4553 4556 ref_elevation.append(z) … … 4561 4564 #assert allclose(elevation, ref_elevation) 4562 4565 4563 4566 4564 4567 assert len(points) == len(new_ref_pts2), 'length of returned points not correct' 4565 4568 assert allclose(points, new_ref_pts2), 'points do not align' … … 4580 4583 4581 4584 4582 -
inundation/zeus/Validation.zpi
r2255 r2648 73 73 <ReleaseProjectSaveAll>Off</ReleaseProjectSaveAll> 74 74 <ReleaseProjectReload>Off</ReleaseProjectReload> 75 <file>..\validation\completed\lwru2\create_mesh.py</file>76 <file>..\validation\completed\lwru2\extract_timeseries.py</file>77 <file>..\validation\completed\lwru2\lwru2.py</file>78 <file>..\validation\completed\lwru2\project.py</file>79 75 <folder name="Header Files" /> 80 76 <folder name="Resource Files" /> -
inundation/zeus/analytic_solutions.zpi
r2255 r2648 73 73 <ReleaseProjectSaveAll>Off</ReleaseProjectSaveAll> 74 74 <ReleaseProjectReload>Off</ReleaseProjectReload> 75 <file>..\analytical solutions\Analytical solution_oblique_shock.py</file> 76 <file>..\analytical solutions\Analytical solution_oblique_shock_01.py</file> 77 <file>..\analytical solutions\Analytical_solution_circular_hydraulic_jump.py</file> 78 <file>..\analytical solutions\Non_symmetrical_dam_break.py</file> 75 <file>..\..\development\analytical solutions\Analytical_solution_circular_hydraulic_jump.py</file> 76 <file>..\..\development\analytical solutions\Analytical_solution_Sampson_cross_mesh.py</file> 77 <file>..\..\development\analytical solutions\Analytical_solution_Yoon_cross_mesh.py</file> 79 78 </project> -
inundation/zeus/anuga-workspace.ini
r2255 r2648 1 1 [Files MRU] 2 0=c:\home\projects\anuga\inundation\pyvolution\shallow_water.py 3 1=c:\home\projects\anuga\inundation\pyvolution\general_mesh.py 4 2=c:\apps\lyx\bin\reLyX.bat 5 3=c:\program files\zfw\readme.txt 2 0=c:\home\projects\anuga\production\merimbula_2005\run_merimbula_lake.py 3 1=c:\home\projects\anuga\production\merimbula_2005\run_new_meribula.py 4 2=c:\home\projects\anuga\production\merimbula_2005\prepare.py 5 3=c:\home\projects\anuga\inundation\pyvolution\shallow_water.py 6 4=c:\home\projects\anuga\inundation\pyvolution\general_mesh.py 7 5=c:\apps\lyx\bin\reLyX.bat 8 6=c:\program files\zfw\readme.txt -
inundation/zeus/anuga-workspace.zwi
r2622 r2648 2 2 <workspace name="anuga-workspace"> 3 3 <mode>Debug</mode> 4 <active> Merimbula</active>4 <active>analytic_solutions</active> 5 5 <project name="analytic_solutions">analytic_solutions.zpi</project> 6 6 <project name="euler">euler.zpi</project> -
inundation/zeus/parallel.zpi
r2255 r2648 84 84 <file>..\parallel\run_parallel_advection.py</file> 85 85 <file>..\parallel\run_parallel_merimbula.py</file> 86 <file>..\parallel\run_parallel_mesh.py</file>87 86 <file>..\parallel\run_parallel_sw_merimbula.py</file> 88 87 <file>..\parallel\run_parallel_sw_merimbula_metis.py</file> -
production/merimbula_2005/project.py
r2622 r2648 7 7 bathymetry_filename = 'merimbula_bathymetry.xya' 8 8 mesh_filename = 'merimbula_10785.tsh' 9 sww_file = 'merimbula_weed.sww' -
production/merimbula_2005/run_new_meribula_weed.py
r2622 r2648 156 156 # close to bearing = 0 and 360! 157 157 #--------------------------------------------- 158 filename = project.original_wind_filename[:-4]+'.tms'159 print 'Wind field from ',filename160 wind = file_function(filename, domain=domain, quantities=['speed','bearing'])161 domain.forcing_terms.append(Wind_stress(wind))158 #filename = project.original_wind_filename[:-4]+'.tms' 159 #print 'Wind field from ',filename 160 #wind = file_function(filename, domain=domain, quantities=['speed','bearing']) 161 #domain.forcing_terms.append(Wind_stress(wind)) 162 162 163 163
Note: See TracChangeset
for help on using the changeset viewer.