Changeset 2105
- Timestamp:
- Dec 1, 2005, 6:04:45 PM (19 years ago)
- Location:
- inundation
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/Merimbula/run_least_squares_merimbula.py
r1292 r2105 8 8 import least_squares 9 9 10 alpha = 0.510 alpha = 5 11 11 mesh_file = 'merimbula_10785.tsh' 12 12 point_file = 'meri0.xya' -
inundation/Merimbula/run_merimbula_lake.py
r1393 r2105 29 29 import time 30 30 31 31 32 #------- 32 33 # Domain … … 50 51 #--------------------------------------- 51 52 # Tidal cycle recorded at Eden as open 52 filename = 'Eden_tide_Sept03. dat'53 filename = 'Eden_tide_Sept03.tms' 53 54 print 'Open sea boundary condition from ',filename 54 55 Bf = File_boundary(filename, domain) -
inundation/parallel/build_submesh.py
r2102 r2105 51 51 submesh = {} 52 52 tsubnodes = concatenate((reshape(arrayrange(nnodes),(nnodes,1)), nodes), 1) 53 53 54 54 # loop over processors 55 55 … … 63 63 64 64 # find the boundary edges on processor p 65 65 66 66 subboundary = {} 67 67 for k in boundary: … … 69 69 subboundary[k]=boundary[k] 70 70 boundary_list.append(subboundary) 71 71 72 72 # find nodes in processor p 73 73 … … 77 77 nodemap[t[1]]=1 78 78 nodemap[t[2]]=1 79 79 80 80 node_list.append(take(tsubnodes,nonzero(nodemap))) 81 81 … … 127 127 ncoord = len(mesh.coordinates) 128 128 ntriangles = len(mesh.triangles) 129 129 130 130 # find the first layer of boundary triangles 131 131 … … 166 166 nodemap = zeros(ncoord, 'i') 167 167 fullnodes = submesh["full_nodes"][p] 168 168 169 169 subtriangles = [] 170 170 for i in range(len(trianglemap)): … … 178 178 tsubtriangles = concatenate((trilist, mesh.triangles), 1) 179 179 subtriangles = take(tsubtriangles, nonzero(trianglemap)) 180 180 181 181 # keep a record of the triangle vertices, if they are not already there 182 182 … … 188 188 tsubnodes = concatenate((nodelist, mesh.coordinates), 1) 189 189 subnodes = take(tsubnodes, nonzero(nodemap)) 190 190 191 191 # clean up before exiting 192 192 … … 223 223 224 224 ghost_commun = zeros((len(subtri), 2), Int) 225 225 226 226 for i in range(len(subtri)): 227 227 global_no = subtri[i][0] … … 241 241 242 242 ghost_commun[i] = [global_no, neigh] 243 243 244 244 return ghost_commun 245 245 … … 343 343 344 344 # build the ghost boundary layer 345 345 346 346 [subnodes, subtri] = ghost_layer(submesh, mesh, p, tupper, tlower) 347 347 ghost_triangles.append(subtri) 348 348 ghost_nodes.append(subnodes) 349 349 350 350 # build the communication pattern for the ghost nodes 351 351 … … 392 392 393 393 def submesh_quantities(submesh, quantities, triangles_per_proc): 394 394 395 395 nproc = len(triangles_per_proc) 396 396 … … 398 398 399 399 # build an empty dictionary to hold the quantites 400 400 401 401 submesh["full_quan"] = {} 402 402 submesh["ghost_quan"] = {} … … 406 406 407 407 # loop trough the subdomains 408 408 409 409 for p in range(nproc): 410 410 upper = lower+triangles_per_proc[p] 411 411 412 412 # find the global ID of the ghost triangles 413 413 414 414 global_id = [] 415 415 M = len(submesh["ghost_triangles"][p]) … … 419 419 # use the global ID to extract the quantites information from 420 420 # the full domain 421 421 422 422 for k in quantities: 423 423 submesh["full_quan"][k].append(quantities[k][lower:upper]) … … 456 456 457 457 submeshf = submesh_full(nodes, triangles, edges, triangles_per_proc) 458 458 459 459 # add any extra ghost boundary layer information 460 460 … … 463 463 # order the quantities information to be the same as the triangle 464 464 # information 465 465 466 466 submesh = submesh_quantities(submeshg, quantities, triangles_per_proc) 467 467 468 468 return submesh 469 469 … … 498 498 submesh_cell["full_quan"][k] = submesh["full_quan"][k][0] 499 499 submesh_cell["ghost_quan"][k] = submesh["ghost_quan"][k][0] 500 500 501 501 return submesh_cell 502 502 503 -
inundation/pymetis/metis-4.0/Makefile.in
r2051 r2105 1 1 2 2 # Which compiler to use 3 CC = cc3 CC = gcc 4 4 5 5 # What optimization level to use -
inundation/pyvolution/data_manager.py
r2074 r2105 53 53 searchsorted, zeros, allclose, around 54 54 55 55 56 56 from coordinate_transforms.geo_reference import Geo_reference 57 57 … … 255 255 256 256 fid.order = domain.default_order 257 258 if hasattr(domain, 'texture'): 257 258 if hasattr(domain, 'texture'): 259 259 fid.texture = domain.texture 260 #else: 261 # fid.texture = 'None' 260 #else: 261 # fid.texture = 'None' 262 262 263 263 #Reference point … … 283 283 if domain.geo_reference is not None: 284 284 domain.geo_reference.write_NetCDF(fid) 285 285 286 286 #FIXME: Backwards compatibility 287 287 fid.createVariable('z', self.precision, ('number_of_points',)) … … 943 943 #easting_min=None, easting_max=None, 944 944 #northing_min=None, northing_max=None, 945 stride = 1, 945 stride = 1, 946 946 attribute_name = 'elevation', 947 947 z_func = None): … … 954 954 0.00000e+00 1.40000e-02 1.3535000e-01 955 955 956 956 957 957 958 958 Convert to NetCDF pts format which is … … 966 966 """ 967 967 968 import os 968 import os 969 969 #from Scientific.IO.NetCDF import NetCDFFile 970 970 from Numeric import Float, arrayrange, concatenate … … 984 984 985 985 if i % stride != 0: continue 986 986 987 987 fields = line.split() 988 988 989 989 try: 990 990 assert len(fields) == 3 991 except: 992 print 'WARNING: Line %d doesn\'t have 3 elements: %s' %(i, line) 991 except: 992 print 'WARNING: Line %d doesn\'t have 3 elements: %s' %(i, line) 993 993 994 994 try: 995 995 x = float( fields[0] ) 996 996 y = float( fields[1] ) 997 z = float( fields[2] ) 997 z = float( fields[2] ) 998 998 except: 999 999 continue … … 1002 1002 1003 1003 if callable(z_func): 1004 attribute.append(z_func(z)) 1005 else: 1004 attribute.append(z_func(z)) 1005 else: 1006 1006 attribute.append(z) 1007 1007 … … 1022 1022 1023 1023 from Numeric import Float 1024 1024 1025 1025 if attribute_name is None: 1026 attribute_name = 'attribute' 1027 1026 attribute_name = 'attribute' 1027 1028 1028 1029 1029 from Scientific.IO.NetCDF import NetCDFFile 1030 1030 1031 1031 # NetCDF file definition 1032 1032 outfile = NetCDFFile(ptsname, 'w') … … 1037 1037 outfile.description = 'NetCDF pts format for compact and '\ 1038 1038 'portable storage of spatial point data' 1039 1039 1040 1040 1041 1041 #Georeferencing 1042 1042 from coordinate_transforms.geo_reference import Geo_reference 1043 1043 Geo_reference().write_NetCDF(outfile) 1044 1044 1045 1045 1046 1046 outfile.createDimension('number_of_points', len(points)) … … 1061 1061 1062 1062 outfile.close() 1063 1063 1064 1064 1065 1065 def dem2pts(basename_in, basename_out=None, verbose=False, … … 1178 1178 for i in range(nrows): 1179 1179 if verbose and i%((nrows+10)/10)==0: 1180 print 'Processing row %d of %d' %(i, nrows) 1181 1180 print 'Processing row %d of %d' %(i, nrows) 1181 1182 1182 lower_index = global_index 1183 1183 tpoints = zeros((ncols_in_bounding_box, 2), Float) … … 1212 1212 """Return block of surface lines for each cross section 1213 1213 Starts with SURFACE LINE, 1214 Ends with END CROSS-SECTION 1214 Ends with END CROSS-SECTION 1215 1215 """ 1216 1216 … … 1218 1218 1219 1219 reading_surface = False 1220 for i, line in enumerate(lines): 1221 1220 for i, line in enumerate(lines): 1221 1222 1222 if len(line.strip()) == 0: #Ignore blanks 1223 continue 1223 continue 1224 1224 1225 1225 if lines[i].strip().startswith('SURFACE LINE'): … … 1236 1236 easting = float(fields[0]) 1237 1237 northing = float(fields[1]) 1238 elevation = float(fields[2]) 1239 points.append([easting, northing, elevation]) 1238 elevation = float(fields[2]) 1239 points.append([easting, northing, elevation]) 1240 1240 1241 1241 … … 1246 1246 verbose=False): 1247 1247 """Read HEC-RAS Elevation datal from the following ASCII format (.sdf) 1248 1248 1249 1249 Example: 1250 1250 1251 1251 1252 1252 # RAS export file created on Mon 15Aug2005 11:42 … … 1262 1262 PROJECTION ZONE: 50 1263 1263 DATUM: AGD66 1264 VERTICAL DATUM: 1265 NUMBER OF REACHES: 19 1266 NUMBER OF CROSS-SECTIONS: 14206 1264 VERTICAL DATUM: 1265 NUMBER OF REACHES: 19 1266 NUMBER OF CROSS-SECTIONS: 14206 1267 1267 END HEADER: 1268 1268 … … 1273 1273 STREAM ID:Southern-Wungong 1274 1274 REACH ID:Southern-Wungong 1275 STATION:19040.* 1275 STATION:19040.* 1276 1276 CUT LINE: 1277 405548.671603161 , 6438142.7594925 1278 405734.536092045 , 6438326.10404912 1279 405745.130459356 , 6438331.48627354 1280 405813.89633823 , 6438368.6272789 1277 405548.671603161 , 6438142.7594925 1278 405734.536092045 , 6438326.10404912 1279 405745.130459356 , 6438331.48627354 1280 405813.89633823 , 6438368.6272789 1281 1281 SURFACE LINE: 1282 1282 405548.67, 6438142.76, 35.37 … … 1290 1290 405566.99, 6438160.83, 35.37 1291 1291 ... 1292 END CROSS-SECTION 1292 END CROSS-SECTION 1293 1293 1294 1294 Convert to NetCDF pts format which is … … 1322 1322 assert lines[i].strip().upper() == 'BEGIN HEADER:' 1323 1323 i += 1 1324 1324 1325 1325 assert lines[i].strip().upper().startswith('UNITS:') 1326 1326 units = lines[i].strip().split()[1] 1327 i += 11328 1329 assert lines[i].strip().upper().startswith('DTM TYPE:')1330 1327 i += 1 1331 1328 1332 assert lines[i].strip().upper().startswith('DTM:') 1333 i += 1 1334 1335 assert lines[i].strip().upper().startswith('STREAM') 1329 assert lines[i].strip().upper().startswith('DTM TYPE:') 1336 1330 i += 1 1337 1331 1338 assert lines[i].strip().upper().startswith('CROSS') 1332 assert lines[i].strip().upper().startswith('DTM:') 1333 i += 1 1334 1335 assert lines[i].strip().upper().startswith('STREAM') 1336 i += 1 1337 1338 assert lines[i].strip().upper().startswith('CROSS') 1339 1339 i += 1 1340 1340 … … 1354 1354 i += 1 1355 1355 1356 assert lines[i].strip().upper().startswith('NUMBER OF REACHES:') 1356 assert lines[i].strip().upper().startswith('NUMBER OF REACHES:') 1357 1357 i += 1 1358 1358 1359 1359 assert lines[i].strip().upper().startswith('NUMBER OF CROSS-SECTIONS:') 1360 1360 number_of_cross_sections = int(lines[i].strip().split(':')[1]) 1361 i += 1 1361 i += 1 1362 1362 1363 1363 … … 1368 1368 for k, entry in enumerate(entries): 1369 1369 points.append(entry[:2]) 1370 elevation.append(entry[2]) 1370 elevation.append(entry[2]) 1371 1371 1372 1372 1373 1373 msg = 'Actual #number_of_cross_sections == %d, Reported as %d'\ 1374 %(j+1, number_of_cross_sections) 1374 %(j+1, number_of_cross_sections) 1375 1375 assert j+1 == number_of_cross_sections, msg 1376 1376 1377 1377 #Get output file 1378 1378 if basename_out == None: … … 1390 1390 outfile.description = 'NetCDF pts format for compact and portable ' +\ 1391 1391 'storage of spatial point data derived from HEC-RAS' 1392 1392 1393 1393 #Georeferencing 1394 1394 outfile.zone = zone … … 1429 1429 northing_min = None, 1430 1430 northing_max = None, 1431 expand_search = False, #To avoid intractable situations (This will be fixed when least_squares gets redesigned) 1431 expand_search = False, #To avoid intractable situations (This will be fixed when least_squares gets redesigned) 1432 1432 verbose = False, 1433 1433 origin = None, 1434 1434 datum = 'WGS84', 1435 1435 format = 'ers'): 1436 1436 1437 1437 """Read SWW file and convert to Digitial Elevation model format (.asc or .ers) 1438 1438 … … 1465 1465 The parameter quantity must be the name of an existing quantity or 1466 1466 an expression involving existing quantities. The default is 1467 'elevation'. 1467 'elevation'. 1468 1468 1469 1469 if timestep (an index) is given, output quantity at that timestep … … 1471 1471 if reduction is given use that to reduce quantity over all timesteps. 1472 1472 1473 datum 1474 1473 datum 1474 1475 1475 format can be either 'asc' or 'ers' 1476 1476 """ … … 1479 1479 from Numeric import array, Float, concatenate, NewAxis, zeros, reshape, sometrue 1480 1480 from Numeric import array2string 1481 1481 1482 1482 from utilities.polygon import inside_polygon, outside_polygon, separate_points_by_polygon 1483 1483 from util import apply_expression_to_dictionary 1484 1484 1485 1485 msg = 'Format must be either asc or ers' 1486 1486 assert format.lower() in ['asc', 'ers'], msg 1487 1487 1488 1488 1489 1489 false_easting = 500000 1490 1490 false_northing = 10000000 … … 1498 1498 if basename_out is None: 1499 1499 basename_out = basename_in + '_%s' %quantity 1500 1500 1501 1501 swwfile = basename_in + '.sww' 1502 1502 demfile = basename_out + '.' + format … … 1590 1590 #Post condition: Now q has dimension: number_of_points 1591 1591 assert len(q.shape) == 1 1592 assert q.shape[0] == number_of_points 1593 1592 assert q.shape[0] == number_of_points 1593 1594 1594 1595 1595 if verbose: 1596 1596 print 'Processed values for %s are in [%f, %f]' %(quantity, min(q), max(q)) 1597 1597 1598 1598 1599 1599 #Create grid and update xll/yll corner and x,y … … 1609 1609 else: 1610 1610 xmax = easting_max - xllcorner 1611 1612 if northing_min is None: 1611 1612 if northing_min is None: 1613 1613 ymin = min(y) 1614 1614 else: 1615 1615 ymin = northing_min - yllcorner 1616 1617 if northing_max is None: 1616 1617 if northing_max is None: 1618 1618 ymax = max(y) 1619 1619 else: 1620 1620 ymax = northing_max - yllcorner 1621 1622 1623 1621 1622 1623 1624 1624 if verbose: print 'Creating grid' 1625 1625 ncols = int((xmax-xmin)/cellsize)+1 … … 1645 1645 if format.lower() == 'asc': 1646 1646 yg = i*cellsize 1647 else: 1647 else: 1648 1648 #this will flip the order of the y values for ers 1649 yg = (nrows-i)*cellsize 1650 1649 yg = (nrows-i)*cellsize 1650 1651 1651 for j in xrange(ncols): 1652 1652 xg = j*cellsize … … 1658 1658 #Interpolate 1659 1659 from least_squares import Interpolation 1660 1660 1661 1661 1662 1662 #FIXME: This should be done with precrop = True (?), otherwise it'll … … 1669 1669 verbose = verbose) 1670 1670 1671 1671 1672 1672 1673 1673 #Interpolate using quantity values … … 1685 1685 1686 1686 for i in outside_indices: 1687 grid_values[i] = NODATA_value 1687 grid_values[i] = NODATA_value 1688 1688 1689 1689 … … 1692 1692 if format.lower() == 'ers': 1693 1693 # setup ERS header information 1694 grid_values = reshape(grid_values,(nrows, ncols)) 1694 grid_values = reshape(grid_values,(nrows, ncols)) 1695 1695 header = {} 1696 1696 header['datum'] = '"' + datum + '"' … … 1717 1717 ermapper_grids.write_ermapper_grid(demfile, grid_values, header) 1718 1718 1719 fid.close() 1719 fid.close() 1720 1720 else: 1721 1721 #Write to Ascii format 1722 1722 1723 1723 #Write prj file 1724 prjfile = basename_out + '.prj' 1725 1724 prjfile = basename_out + '.prj' 1725 1726 1726 if verbose: print 'Writing %s' %prjfile 1727 1727 prjid = open(prjfile, 'w') … … 1738 1738 1739 1739 1740 1740 1741 1741 if verbose: print 'Writing %s' %demfile 1742 1742 1743 1743 ascid = open(demfile, 'w') 1744 1744 … … 1765 1765 ascid.write(s[1:-1] + '\n') 1766 1766 1767 1767 1768 1768 #print 1769 1769 #for j in range(ncols): … … 1777 1777 fid.close() 1778 1778 1779 #Backwards compatibility 1779 #Backwards compatibility 1780 1780 def sww2asc(basename_in, basename_out = None, 1781 1781 quantity = None, … … 1796 1796 datum = 'WGS84', 1797 1797 format = 'asc') 1798 1798 1799 1799 def sww2ers(basename_in, basename_out = None, 1800 1800 quantity = None, … … 1806 1806 datum = 'WGS84'): 1807 1807 print 'sww2ers will soon be obsoleted - please use sww2dem' 1808 sww2dem(basename_in, 1808 sww2dem(basename_in, 1809 1809 basename_out = basename_out, 1810 1810 quantity = quantity, … … 1815 1815 origin = origin, 1816 1816 datum = datum, 1817 format = 'ers') 1818 ################################# END COMPATIBILITY ############## 1817 format = 'ers') 1818 ################################# END COMPATIBILITY ############## 1819 1819 1820 1820 … … 1973 1973 fields = line.split() 1974 1974 if verbose and i%((n+10)/10)==0: 1975 print 'Processing row %d of %d' %(i, nrows) 1975 print 'Processing row %d of %d' %(i, nrows) 1976 1976 1977 1977 elevation[i, :] = array([float(x) for x in fields]) … … 2030 2030 from Numeric import Float, Int, Int32, searchsorted, zeros, array 2031 2031 from Numeric import allclose, around 2032 2032 2033 2033 precision = Float 2034 2034 … … 2063 2063 assert allclose(longitudes, file_u.variables['LON']) 2064 2064 assert allclose(longitudes, file_v.variables['LON']) 2065 assert allclose(longitudes, e_lon) 2065 assert allclose(longitudes, e_lon) 2066 2066 2067 2067 … … 2107 2107 zname = 'ELEVATION' 2108 2108 2109 2109 2110 2110 amplitudes = file_h.variables['HA'][jmin:jmax, kmin:kmax, lmin:lmax] 2111 2111 uspeed = file_u.variables['UA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lon … … 2113 2113 elevations = file_e.variables[zname][kmin:kmax, lmin:lmax] 2114 2114 2115 # if latitudes2[0]==latitudes[0] and latitudes2[-1]==latitudes[-1]:2116 # elevations = file_e.variables['ELEVATION'][kmin:kmax, lmin:lmax]2117 # elif latitudes2[0]==latitudes[-1] and latitudes2[-1]==latitudes[0]:2118 # from Numeric import asarray2119 # elevations=elevations.tolist()2120 # elevations.reverse()2121 # elevations=asarray(elevations)2122 # else:2123 # from Numeric import asarray2124 # elevations=elevations.tolist()2125 # elevations.reverse()2126 # elevations=asarray(elevations)2127 # 'print hmmm'2115 # if latitudes2[0]==latitudes[0] and latitudes2[-1]==latitudes[-1]: 2116 # elevations = file_e.variables['ELEVATION'][kmin:kmax, lmin:lmax] 2117 # elif latitudes2[0]==latitudes[-1] and latitudes2[-1]==latitudes[0]: 2118 # from Numeric import asarray 2119 # elevations=elevations.tolist() 2120 # elevations.reverse() 2121 # elevations=asarray(elevations) 2122 # else: 2123 # from Numeric import asarray 2124 # elevations=elevations.tolist() 2125 # elevations.reverse() 2126 # elevations=asarray(elevations) 2127 # 'print hmmm' 2128 2128 2129 2129 … … 2359 2359 outfile.variables['y'][:] = y - yllcorner 2360 2360 outfile.variables['z'][:] = z #FIXME HACK 2361 outfile.variables['elevation'][:] = z 2361 outfile.variables['elevation'][:] = z 2362 2362 outfile.variables['time'][:] = times #Store time relative 2363 2363 outfile.variables['volumes'][:] = volumes.astype(Int32) #On Opteron 64 … … 2384 2384 i += 1 2385 2385 2386 #outfile.close() 2386 #outfile.close() 2387 2387 2388 2388 #FIXME: Refactor using code from file_function.statistics … … 2413 2413 2414 2414 2415 outfile.close() 2415 outfile.close() 2416 2416 2417 2417 … … 2491 2491 fields = line.split(',') 2492 2492 realtime = calendar.timegm(time.strptime(fields[0], time_format)) 2493 2493 2494 2494 T[i] = realtime - starttime 2495 2495 … … 2516 2516 #FIXME: Use Georef 2517 2517 fid.starttime = starttime 2518 2519 2518 2519 2520 2520 # dimension definitions 2521 2521 #fid.createDimension('number_of_volumes', self.number_of_volumes) … … 2528 2528 2529 2529 fid.variables['time'][:] = T 2530 2530 2531 2531 for i in range(Q.shape[1]): 2532 2532 try: 2533 2533 name = quantity_names[i] 2534 except: 2534 except: 2535 2535 name = 'Attribute%d'%i 2536 2536 2537 2537 fid.createVariable(name, Float, ('number_of_timesteps',)) 2538 fid.variables[name][:] = Q[:,i] 2538 fid.variables[name][:] = Q[:,i] 2539 2539 2540 2540 fid.close() … … 2642 2642 2643 2643 if verbose: print ' building domain' 2644 # From domain.Domain:2645 # domain = Domain(coordinates, volumes,\2646 # conserved_quantities = conserved_quantities,\2647 # other_quantities = other_quantities,zone=zone,\2648 # xllcorner=xllcorner, yllcorner=yllcorner)2649 2650 # From shallow_water.Domain:2644 # From domain.Domain: 2645 # domain = Domain(coordinates, volumes,\ 2646 # conserved_quantities = conserved_quantities,\ 2647 # other_quantities = other_quantities,zone=zone,\ 2648 # xllcorner=xllcorner, yllcorner=yllcorner) 2649 2650 # From shallow_water.Domain: 2651 2651 coordinates=coordinates.tolist() 2652 2652 volumes=volumes.tolist() … … 2692 2692 X = resize(X,(len(X)/3,3)) 2693 2693 domain.set_quantity(quantity,X) 2694 #2694 # 2695 2695 for quantity in conserved_quantities: 2696 2696 try: … … 3118 3118 3119 3119 3120 3120 3121 3121 def sww2asc_obsolete(basename_in, basename_out = None, 3122 3122 quantity = None, … … 3268 3268 #Interpolate 3269 3269 from least_squares import Interpolation 3270 3270 3271 3271 3272 3272 #FIXME: This should be done with precrop = True, otherwise it'll … … 3298 3298 3299 3299 3300 3300 3301 3301 if verbose: print 'Writing %s' %ascfile 3302 3302 NODATA_value = -9999 3303 3303 3304 3304 ascid = open(ascfile, 'w') 3305 3305 … … 3390 3390 """ 3391 3391 Produce an sww boundary file, from esri ascii data from CSIRO. 3392 3392 3393 3393 Also convert latitude and longitude to UTM. All coordinates are 3394 3394 assumed to be given in the GDA94 datum. 3395 3395 3396 3396 assume: 3397 3397 All files are in esri ascii format … … 3410 3410 """ 3411 3411 from Scientific.IO.NetCDF import NetCDFFile 3412 3412 3413 3413 from coordinate_transforms.redfearn import redfearn 3414 3414 3415 3415 precision = Float # So if we want to change the precision its done here 3416 3416 3417 3417 # go in to the bath dir and load the only file, 3418 3418 bath_files = os.listdir(bath_dir) 3419 #print "bath_files",bath_files 3419 #print "bath_files",bath_files 3420 3420 3421 3421 #fixme: make more general? … … 3424 3424 bath_metadata,bath_grid = _read_asc(bath_dir_file) 3425 3425 #print "bath_metadata",bath_metadata 3426 #print "bath_grid",bath_grid 3426 #print "bath_grid",bath_grid 3427 3427 3428 3428 #Use the date.time of the bath file as a basis for 3429 3429 #the start time for other files 3430 3430 base_start = bath_file[-12:] 3431 3431 3432 3432 #go into the elevation dir and load the 000 file 3433 3433 elevation_dir_file = elevation_dir + os.sep + elevation_prefix \ 3434 3434 + base_start 3435 3435 #elevation_metadata,elevation_grid = _read_asc(elevation_dir_file) 3436 #print "elevation_dir_file",elevation_dir_file 3437 #print "elevation_grid", elevation_grid 3438 3436 #print "elevation_dir_file",elevation_dir_file 3437 #print "elevation_grid", elevation_grid 3438 3439 3439 elevation_files = os.listdir(elevation_dir) 3440 3440 ucur_files = os.listdir(ucur_dir) … … 3444 3444 # file with the same base name as the bath data 3445 3445 #print "elevation_files[0]",elevation_files[0] 3446 #print "'el' + base_start",'el' + base_start 3446 #print "'el' + base_start",'el' + base_start 3447 3447 assert elevation_files[0] == 'el' + base_start 3448 3448 3449 3449 #assert bath_metadata == elevation_metadata 3450 3450 3451 3451 3452 3452 3453 number_of_latitudes = bath_grid.shape[0] 3453 number_of_latitudes = bath_grid.shape[0] 3454 3454 number_of_longitudes = bath_grid.shape[1] 3455 3455 #number_of_times = len(os.listdir(elevation_dir)) … … 3461 3461 latitudes = [bath_metadata['yllcorner']+y*bath_metadata['cellsize'] \ 3462 3462 for y in range(number_of_latitudes)] 3463 3463 3464 3464 # reverse order of lat, so the fist lat represents the first grid row 3465 3465 latitudes.reverse() 3466 3467 #print "latitudes - before _get_min_max_indexes",latitudes 3466 3467 #print "latitudes - before _get_min_max_indexes",latitudes 3468 3468 kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes,longitudes, 3469 3469 minlat=minlat, maxlat=maxlat, 3470 3470 minlon=minlon, maxlon=maxlon) 3471 3471 3472 3472 3473 3473 bath_grid = bath_grid[kmin:kmax,lmin:lmax] … … 3480 3480 number_of_points = number_of_latitudes*number_of_longitudes 3481 3481 number_of_volumes = (number_of_latitudes-1)*(number_of_longitudes-1)*2 3482 #print "number_of_points",number_of_points 3482 #print "number_of_points",number_of_points 3483 3483 3484 3484 #Work out the times … … 3492 3492 #print "times", times 3493 3493 #print "number_of_latitudes", number_of_latitudes 3494 #print "number_of_longitudes", number_of_longitudes 3495 #print "number_of_times", number_of_times 3494 #print "number_of_longitudes", number_of_longitudes 3495 #print "number_of_times", number_of_times 3496 3496 #print "latitudes", latitudes 3497 3497 #print "longitudes", longitudes … … 3510 3510 print ' t in [%f, %f], len(t) == %d'\ 3511 3511 %(min(times), max(times), len(times)) 3512 3512 3513 3513 ######### WRITE THE SWW FILE ############# 3514 3514 # NetCDF file definition … … 3523 3523 outfile.smoothing = 'Yes' 3524 3524 outfile.order = 1 3525 3525 3526 3526 #Start time in seconds since the epoch (midnight 1/1/1970) 3527 3527 outfile.starttime = starttime = times[0] 3528 3529 3528 3529 3530 3530 # dimension definitions 3531 3531 outfile.createDimension('number_of_volumes', number_of_volumes) … … 3570 3570 #Get zone of 1st point. 3571 3571 refzone, _, _ = redfearn(latitudes[0],longitudes[0]) 3572 3572 3573 3573 vertices = {} 3574 3574 i = 0 3575 for k, lat in enumerate(latitudes): 3576 for l, lon in enumerate(longitudes): 3575 for k, lat in enumerate(latitudes): 3576 for l, lon in enumerate(longitudes): 3577 3577 3578 3578 vertices[l,k] = i … … 3639 3639 xmomentum = outfile.variables['xmomentum'] 3640 3640 ymomentum = outfile.variables['ymomentum'] 3641 3641 3642 3642 outfile.variables['time'][:] = times #Store time relative 3643 3643 3644 3644 if verbose: print 'Converting quantities' 3645 n = number_of_times 3645 n = number_of_times 3646 3646 for j in range(number_of_times): 3647 3647 # load in files 3648 3648 elevation_meta, elevation_grid = \ 3649 3649 _read_asc(elevation_dir + os.sep + elevation_files[j]) 3650 3650 3651 3651 _, u_momentum_grid = _read_asc(ucur_dir + os.sep + ucur_files[j]) 3652 3652 _, v_momentum_grid = _read_asc(vcur_dir + os.sep + vcur_files[j]) 3653 3653 3654 #print "elevation_grid",elevation_grid 3654 #print "elevation_grid",elevation_grid 3655 3655 #cut matrix to desired size 3656 3656 elevation_grid = elevation_grid[kmin:kmax,lmin:lmax] 3657 3657 u_momentum_grid = u_momentum_grid[kmin:kmax,lmin:lmax] 3658 3658 v_momentum_grid = v_momentum_grid[kmin:kmax,lmin:lmax] 3659 #print "elevation_grid",elevation_grid 3659 #print "elevation_grid",elevation_grid 3660 3660 # handle missing values 3661 3661 missing = (elevation_grid == elevation_meta['NODATA_value']) … … 3681 3681 i += 1 3682 3682 outfile.close() 3683 3683 3684 3684 def _get_min_max_indexes(latitudes,longitudes, 3685 3685 minlat=None, maxlat=None, … … 3709 3709 if lat_min_index <0: 3710 3710 lat_min_index = 0 3711 3711 3712 3712 3713 3713 if maxlat == None: … … 3717 3717 if lat_max_index > largest_lat_index: 3718 3718 lat_max_index = largest_lat_index 3719 3719 3720 3720 if minlon == None: 3721 3721 lon_min_index = 0 … … 3724 3724 if lon_min_index <0: 3725 3725 lon_min_index = 0 3726 3726 3727 3727 if maxlon == None: 3728 3728 lon_max_index = len(longitudes) … … 3730 3730 lon_max_index = searchsorted(longitudes, maxlon) 3731 3731 3732 #Take into account that the latitude list was reversed 3732 #Take into account that the latitude list was reversed 3733 3733 latitudes.reverse() # Python passes by reference, need to swap back 3734 3734 lat_min_index, lat_max_index = largest_lat_index - lat_max_index , \ … … 3736 3736 lat_max_index = lat_max_index + 1 # taking into account how slicing works 3737 3737 lon_max_index = lon_max_index + 1 # taking into account how slicing works 3738 3738 3739 3739 return lat_min_index, lat_max_index, lon_min_index, lon_max_index 3740 3741 3740 3741 3742 3742 def _read_asc(filename, verbose=False): 3743 3743 """Read esri file from the following ASCII format (.asc) … … 3769 3769 cellsize = float(lines.pop(0).split()[1].strip()) 3770 3770 NODATA_value = float(lines.pop(0).split()[1].strip()) 3771 3772 assert len(lines) == nrows 3773 3771 3772 assert len(lines) == nrows 3773 3774 3774 #Store data 3775 3775 grid = [] 3776 3776 3777 3777 n = len(lines) 3778 3778 for i, line in enumerate(lines): … … 3786 3786 'cellsize':cellsize, 3787 3787 'NODATA_value':NODATA_value}, grid 3788 3788 -
inundation/pyvolution/netherlands.py
r1828 r2105 90 90 print 'Creating domain' 91 91 #Create basic mesh 92 points, vertices, boundary = rectangular(N, N)92 points, elements, boundary = rectangular(N, N) 93 93 94 94 #Create shallow water domain 95 domain = Domain(points, vertices, boundary, use_inscribed_circle=True)95 domain = Domain(points, elements, boundary, use_inscribed_circle=True) 96 96 97 97 domain.check_integrity() … … 107 107 108 108 #Set bed-slope and friction 109 inflow_stage = 0. 1109 inflow_stage = 0.5 110 110 manning = 0.03 111 111 Z = Weir(inflow_stage) … … 155 155 # 156 156 print 'Initial condition' 157 #domain.set_quantity('stage', Constant_height(Z, 0.0))158 domain.set_quantity('stage', Constant_stage(inflow_stage/2.0))157 domain.set_quantity('stage', Constant_height(Z, 0.0)) 158 #domain.set_quantity('stage', Constant_stage(inflow_stage/2.0)) 159 159 160 160 #Evolve … … 168 168 #V.update_quantity('elevation') 169 169 170 for t in domain.evolve(yieldstep = 0.0 2, finaltime = 15.0):170 for t in domain.evolve(yieldstep = 0.005, finaltime = 15.0): 171 171 domain.write_time() 172 domain.write_boundary()173 172 #domain.write_boundary() 173 174 174 print domain.quantities['stage'].get_values(location='centroids', 175 175 indices=[0]) -
inundation/pyvolution/view_tsh.bat
r1293 r2105 1 python C:\Home\Projects\anuga\ pyvolution\view_tsh.py %1 %21 python C:\Home\Projects\anuga\inundation\pyvolution\view_tsh.py %1 %2 -
inundation/zeus/Merimbula.zpi
r1358 r2105 73 73 <ReleaseProjectSaveAll>Off</ReleaseProjectSaveAll> 74 74 <ReleaseProjectReload>Off</ReleaseProjectReload> 75 <file>..\merimbula\prepare.py</file> 75 76 <file>..\merimbula\run_least_squares_merimbula.py</file> 76 77 <file>..\merimbula\run_merimbula_lake.py</file> -
inundation/zeus/Validation.zpi
r1735 r2105 73 73 <ReleaseProjectSaveAll>Off</ReleaseProjectSaveAll> 74 74 <ReleaseProjectReload>Off</ReleaseProjectReload> 75 <file>..\validation\ lwru2\create_mesh.py</file>76 <file>..\validation\ lwru2\extract_timeseries.py</file>77 <file>..\validation\ lwru2\filenames.py</file>78 <file>..\validation\ lwru2\lwru2.py</file>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 79 <folder name="Header Files" /> 80 80 <folder name="Resource Files" /> -
inundation/zeus/anuga-workspace.zwi
r1995 r2105 2 2 <workspace name="anuga-workspace"> 3 3 <mode>Debug</mode> 4 <active> analytic_solutions</active>4 <active>parallel</active> 5 5 <project name="analytic_solutions">analytic_solutions.zpi</project> 6 6 <project name="euler">euler.zpi</project> -
inundation/zeus/parallel.zpi
r1697 r2105 86 86 <file>..\parallel\run_parallel_mesh.py</file> 87 87 <file>..\parallel\run_parallel_sw_merimbula.py</file> 88 <file>..\parallel\run_parallel_sw_merimbula_metis.py</file> 88 89 <file>..\parallel\run_parallel_sw_rectangle.py</file> 89 90 <file>..\parallel\run_sw_lost_mass.py</file> -
inundation/zeus/pyvolution.zpi
r1949 r2105 79 79 <file>..\pyvolution\check_sww_tsh.py</file> 80 80 <file>..\pyvolution\combine_pts.py</file> 81 <file>..\pyvolution\compile.py</file>82 81 <file>..\pyvolution\config.py</file> 83 82 <file>..\pyvolution\cornell_room.py</file> 84 83 <file>..\pyvolution\data_manager.py</file> 85 84 <file>..\pyvolution\domain.py</file> 86 <file>..\pyvolution\euler.py</file>87 <file>..\pyvolution\euler_config.py</file>88 <file>..\pyvolution\euler_ext.c</file>89 85 <file>..\pyvolution\flatbed.py</file> 90 86 <file>..\pyvolution\flatbed_compare.py</file> … … 123 119 <file>..\pyvolution\test_data_manager.py</file> 124 120 <file>..\pyvolution\test_domain.py</file> 125 <file>..\pyvolution\test_euler.py</file>126 121 <file>..\pyvolution\test_general_mesh.py</file> 127 122 <file>..\pyvolution\test_generic_boundary_conditions.py</file>
Note: See TracChangeset
for help on using the changeset viewer.