Changeset 9051
- Timestamp:
- Feb 11, 2014, 9:09:53 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/shallow_water/swDE1_domain_ext.c
r9039 r9051 558 558 559 559 560 // If neighbour is a boundary condition, add the flux to the boundary_flux_integral 561 if(n<0){ 560 // If this cell is not a ghost, and the neighbour is a boundary 561 // condition OR a ghost cell, then add the flux to the 562 // boundary_flux_integral 563 if( (n<0 & tri_full_flag[k]==1) | ( n>=0 && (tri_full_flag[k]==1 & tri_full_flag[n]==0)) ){ 562 564 boundary_flux_sum[0] += edgeflux_store[ki3]; 563 565 } -
trunk/anuga_core/source/anuga/utilities/plot_utils.py
r9044 r9051 550 550 xsize = len(lons) 551 551 552 # Assume data/lats/longs refer to cell centres, and compute lower left coordinate553 llx = lons[0] - (xres / 2.)554 lly = lats[0] -(yres / 2.)552 # Assume data/lats/longs refer to cell centres, and compute upper left coordinate 553 ulx = lons[0] - (xres / 2.) 554 uly = lats[lats.shape[0]-1] + (yres / 2.) 555 555 556 556 # GDAL magic to make the tif … … 568 568 ds.SetProjection(srs.ExportToWkt()) 569 569 570 gt = [llx, xres, 0, lly, 0, yres ] 570 gt = [ulx, xres, 0, uly, 0, -yres ] 571 #gt = [llx, xres, 0, lly, yres,0 ] 571 572 ds.SetGeoTransform(gt) 573 574 #import pdb 575 #pdb.set_trace() 572 576 573 577 outband = ds.GetRasterBand(1) … … 595 599 INPUTS: swwFile -- name of sww file 596 600 output_quantities -- list of quantitiies to plot, e.g. ['depth', 'velocity', 'stage','elevation','depthIntegratedVelocity'] 597 myTimeStep -- time-index of swwFile to plot, or 'last', or 'max'601 myTimeStep -- list containing time-index of swwFile to plot, or 'last', or 'max' 598 602 CellSize -- approximate pixel size for output raster [adapted to fit lower_left / upper_right] 599 603 lower_left -- [x0,y0] of lower left corner. If None, use extent of swwFile. … … 624 628 raise Exception, 'Must specify EITHER an integer EPSG_CODE describing the file projection, OR a proj4string' 625 629 630 # Ensure myTimeStep is a list 631 if type(myTimeStep)!=list: 632 myTimeStep=[myTimeStep] 633 626 634 # Make output_dir 627 635 try: … … 640 648 yllcorner=swwIn.yllcorner 641 649 642 if(myTimeStep=='last'):643 myTimeStep=len(p.time)-1644 645 650 646 651 if(verbose): … … 650 655 swwY=p2.y+yllcorner 651 656 657 # Grid for meshing 658 if(verbose): 659 print 'Computing grid of output locations...' 660 # Get points where we want raster cells 661 if(lower_left is None): 662 lower_left=[swwX.min(),swwY.min()] 663 if(upper_right is None): 664 upper_right=[swwX.max(),swwY.max()] 665 nx=round((upper_right[0]-lower_left[0])*1.0/(1.0*CellSize)) + 1 666 xres=(upper_right[0]-lower_left[0])*1.0/(1.0*(nx-1)) 667 desiredX=scipy.arange(lower_left[0], upper_right[0],xres ) 668 ny=round((upper_right[1]-lower_left[1])*1.0/(1.0*CellSize)) + 1 669 yres=(upper_right[1]-lower_left[1])*1.0/(1.0*(ny-1)) 670 desiredY=scipy.arange(lower_left[1], upper_right[1], yres) 671 672 gridX, gridY=scipy.meshgrid(desiredX,desiredY) 673 674 if(verbose): 675 print 'Making interpolation functions...' 676 swwXY=scipy.array([swwX[:],swwY[:]]).transpose() 677 # Get index of nearest point 678 index_qFun=scipy.interpolate.NearestNDInterpolator(swwXY,scipy.arange(len(swwX),dtype='int32').transpose()) 679 gridqInd=index_qFun(scipy.array([scipy.concatenate(gridX),scipy.concatenate(gridY)]).transpose()) 680 652 681 # Loop over all output quantities and produce the output 653 for output_quantity in output_quantities: 654 655 if(myTimeStep!='max'): 656 if(output_quantity=='stage'): 657 swwStage=p2.stage[myTimeStep,:] 658 if(output_quantity=='depth'): 659 swwHeight=p2.height[myTimeStep,:] 660 if(output_quantity=='velocity'): 661 swwVel=p2.vel[myTimeStep,:] 662 if(output_quantity=='depthIntegratedVelocity'): 663 swwDIVel=(p2.xmom[myTimeStep,:]**2+p2.ymom[myTimeStep,:]**2)**0.5 664 timestepString=str(round(p2.time[myTimeStep])) 665 else: 666 if(output_quantity=='stage'): 667 swwStage=p2.stage.max(axis=0) 668 if(output_quantity=='depth'): 669 swwHeight=p2.height.max(axis=0) 670 if(output_quantity=='velocity'): 671 swwVel=p2.vel.max(axis=0) 672 if(output_quantity=='depthIntegratedVelocity'): 673 swwDIVel=((p2.xmom**2+p2.ymom**2).max(axis=0))**0.5 674 timestepString='max' 675 676 # Make name for output file 677 output_name=output_dir+'/'+os.path.splitext(os.path.basename(swwFile))[0] + '_'+\ 678 output_quantity+'_'+timestepString+\ 679 '_'+str(myTimeStep)+'.tif' 680 682 for myTS in myTimeStep: 681 683 if(verbose): 682 print 'Computing grid of output locations...' 683 # Get points where we want raster cells 684 if(lower_left is None): 685 lower_left=[swwX.min(),swwY.min()] 686 if(upper_right is None): 687 upper_right=[swwX.max(),swwY.max()] 688 689 nx=round((upper_right[0]-lower_left[0])*1.0/(1.0*CellSize)) + 1 690 xres=(upper_right[0]-lower_left[0])*1.0/(1.0*(nx-1)) 691 desiredX=scipy.arange(lower_left[0], upper_right[0],xres ) 692 ny=round((upper_right[1]-lower_left[1])*1.0/(1.0*CellSize)) + 1 693 yres=(upper_right[1]-lower_left[1])*1.0/(1.0*(ny-1)) 694 desiredY=scipy.arange(lower_left[1], upper_right[1], yres) 695 696 gridX, gridY=scipy.meshgrid(desiredX,desiredY) 697 698 # Make functions to interpolate quantities at points 699 if(verbose): 700 print 'Making interpolation functions...' 701 swwXY=scipy.array([swwX[:],swwY[:]]).transpose() 702 if(output_quantity=='stage'): 703 qFun=scipy.interpolate.NearestNDInterpolator(swwXY,swwStage.transpose()) 704 elif(output_quantity=='velocity'): 705 qFun=scipy.interpolate.NearestNDInterpolator(swwXY,swwVel.transpose()) 706 elif(output_quantity=='elevation'): 707 qFun=scipy.interpolate.NearestNDInterpolator(swwXY,p2.elev.transpose()) 708 elif(output_quantity=='depth'): 709 qFun=scipy.interpolate.NearestNDInterpolator(swwXY,swwHeight.transpose()) 710 elif(output_quantity=='depthIntegratedVelocity'): 711 qFun=scipy.interpolate.NearestNDInterpolator(swwXY,swwDIVel.transpose()) 712 else: 713 raise Exception, 'output_quantity not available -- check if it is spelled correctly' 714 715 if(verbose): 716 print 'Interpolating' 717 gridq=qFun(scipy.array([scipy.concatenate(gridX),scipy.concatenate(gridY)]).transpose()).transpose() 718 gridq.shape=(len(desiredY),len(desiredX)) 719 720 if(verbose): 721 print 'Making raster ...' 722 make_grid(gridq,desiredY,desiredX, output_name,EPSG_CODE=EPSG_CODE, proj4string=proj4string) 684 print myTS 685 for output_quantity in output_quantities: 686 687 if(myTS=='last'): 688 myTS=len(p.time)-1 689 690 691 if(myTS!='max'): 692 if(output_quantity=='stage'): 693 gridq=p2.stage[myTS,:][gridqInd] 694 if(output_quantity=='depth'): 695 gridq=p2.height[myTS,:][gridqInd] 696 if(output_quantity=='velocity'): 697 gridq=p2.vel[myTS,:][gridqInd] 698 if(output_quantity=='depthIntegratedVelocity'): 699 swwDIVel=(p2.xmom[myTS,:]**2+p2.ymom[myTS,:]**2)**0.5 700 gridq=swwDIVel[gridqInd] 701 timestepString=str(round(p2.time[myTS])) 702 else: 703 if(output_quantity=='stage'): 704 gridq=p2.stage.max(axis=0)[gridqInd] 705 if(output_quantity=='depth'): 706 gridq=p2.height.max(axis=0)[gridqInd] 707 if(output_quantity=='velocity'): 708 gridq=p2.vel.max(axis=0)[gridqInd] 709 if(output_quantity=='depthIntegratedVelocity'): 710 swwDIVel=((p2.xmom**2+p2.ymom**2).max(axis=0))**0.5 711 gridq=swwDIVel[gridqInd] 712 timestepString='max' 713 714 # Make name for output file 715 output_name=output_dir+'/'+os.path.splitext(os.path.basename(swwFile))[0] + '_'+\ 716 output_quantity+'_'+timestepString+\ 717 '_'+str(myTS)+'.tif' 718 719 if(verbose): 720 print 'Making raster ...' 721 gridq.shape=(len(desiredY),len(desiredX)) 722 make_grid(scipy.flipud(gridq),desiredY,desiredX, output_name,EPSG_CODE=EPSG_CODE, proj4string=proj4string) 723 723 724 724 return -
trunk/anuga_core/source/anuga_validation_tests/case_studies/towradgi/Compare_results_with_fieldObs.py
r9044 r9051 8 8 from anuga.utilities import plot_utils as util 9 9 10 p=util.get_output('MODEL_OUTPUTS/Towradgi_historic_flood.sww') 10 swwdir='MODEL_OUTPUTS/' 11 #swwdir='MODEL_bridges_n0p04/' 12 13 p=util.get_output(swwdir+'Towradgi_historic_flood.sww') 11 14 p2=util.get_centroids(p,velocity_extrapolation=True) 12 15 floodLevels=scipy.genfromtxt('Validation/historic_1998_flood_levels_towradgi_ck.csv', delimiter=',',skip_header=1) … … 50 53 tif_outdir='OUTPUT_TIFS' 51 54 CellSize=5.0 52 util.Make_Geotif( 'MODEL_OUTPUTS/Towradgi_historic_flood.sww',55 util.Make_Geotif(swwdir+'Towradgi_historic_flood.sww', 53 56 ['depth','velocity','depthIntegratedVelocity','elevation'],'max', 54 57 CellSize=CellSize,EPSG_CODE=32756,output_dir=tif_outdir) -
trunk/anuga_core/source/anuga_validation_tests/case_studies/towradgi/Towradgi_historic_flood.py
r9044 r9051 983 983 domain.write_time() 984 984 985 barrier() 985 986 if myid == 0: 986 987 print 'Number of processors %g ' %numprocs -
trunk/anuga_work/development/gareth/tests/Petar/Towradgi/Aug98_hort_discontinous.py
r9040 r9051 249 249 250 250 if myid == 0 and verbose: print 'CREATING INLETS' 251 """ 251 252 252 #------------------------------------------------------------------------------ 253 253 # ENTER CULVERT DATA … … 670 670 label=join('Runs', '7H'), # this puts the culvert hydraulics output into the same dir as the sww's 671 671 verbose=False) 672 """ 672 673 673 674 674 #------------------------------------------------------------------------------ -
trunk/anuga_work/development/gareth/tests/shallow_steep_slope/channel_SU_sparse.py
r9039 r9051 21 21 from anuga.structures.inlet_operator import Inlet_operator 22 22 from anuga.shallow_water.shallow_water_domain import Domain as Domain 23 from bal_and import *23 #from bal_and import * 24 24 #from balanced_dev import Domain as Domain 25 25 #from anuga_tsunami import * … … 32 32 domain = Domain(points, vertices, boundary) # Create domain 33 33 domain.set_name('channel_SU_2_v2') # Output name 34 #domain.set_flow_algorithm('DE1')34 domain.set_flow_algorithm('DE1') 35 35 #------------------------------------------------------------------------------ 36 36 # Setup initial conditions 37 37 #------------------------------------------------------------------------------ 38 38 def topography(x, y): 39 return -x/10. #+ 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope39 return -x/10. + 1.*(numpy.sin(x/10.) +abs(y-50.)/10.) -0.*(x>80.) # linear bed slope 40 40 41 41 def stagetopo(x,y): -
trunk/anuga_work/development/gareth/tests/taguig_parallel/runThis.sh
r9040 r9051 2 2 rm -r MODEL_OUTPUTS* 3 3 # Run in parallel 4 mpirun -np 12python runtaguig.py4 mpirun -np 40 python runtaguig.py 5 5 # Run in serial 6 mpirun -np 5python runtaguig.py6 mpirun -np 80 python runtaguig.py 7 7 # Compare serial and parallel 8 8 ipython compare_parallel_serial.py -
trunk/anuga_work/development/gareth/tests/taguig_parallel/runtaguig.py
r9042 r9051 59 59 #domain.ghost_layer_width=4 60 60 domain.set_store_centroids(True) 61 #domain.set_flow_algorithm('DE1')61 domain.set_flow_algorithm('DE1') 62 62 63 63 # Define function to compute elevation … … 69 69 alpha=0.0001) 70 70 71 71 72 else: 72 73 domain=None … … 77 78 barrier() 78 79 80 domain.set_quantity('stage', 1.0) 81 domain.set_quantity('friction', 0.03) 79 82 ## Force first order 80 83 #domain.beta_w=0.0 … … 85 88 #domain.beta_vh_dry=0.0 86 89 ### 90 #print domain.quantities['stage'].centroid_values.max() 91 #print domain.quantities['stage'].vertex_values.max() 87 92 88 domain.set_quantity('stage', 1.0) 89 domain.set_quantity('friction', 0.03) 90 93 #barrier() 94 #raise Exception, 'Finish here' 91 95 # Rain 92 #rain_mps=90.0/(1000*3600) # 90mm/hr is meters-per-second 93 #def myrain(t): 94 # return(rain_mps) 95 #rainin_term=anuga.operators.rate_operators.Rate_operator(domain,rate=myrain) 96 rain_mps=90.0/(1000.*3600.) # 90mm/hr is meters-per-second 97 def myrain(t): 98 return(rain_mps) 99 #myindices=range(len(domain.centroid_coordinates[:,0])) 100 #rainin_term=anuga.operators.rate_operators.Rate_operator(domain,rate=myrain,indices=myindices) 101 rainin_term=anuga.operators.rate_operators.Rate_operator(domain,rate=myrain,polygon=project.bounding_polygon) 96 102 97 103 ## Boundary conditions … … 119 125 120 126 barrier() 127 finalize()
Note: See TracChangeset
for help on using the changeset viewer.