Changeset 2682
- Timestamp:
- Apr 10, 2006, 9:39:39 AM (18 years ago)
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/least_squares.py
r2668 r2682 441 441 self.mesh = Mesh(vertex_coordinates, triangles, 442 442 geo_reference = geo) 443 443 print 'mesh.check_integrity' 444 444 self.mesh.check_integrity() 445 445 print 'data_origin' 446 446 self.data_origin = data_origin 447 447 … … 474 474 data_origin = data_origin, 475 475 precrop = precrop) 476 print 'finished interpolation' 476 477 477 478 def set_point_coordinates(self, point_coordinates, -
inundation/pyvolution/mesh.py
r2582 r2682 498 498 499 499 N = self.number_of_elements 500 500 print 'number of elements:', N 501 501 #Get x,y coordinates for all vertices for all triangles 502 502 V = self.get_vertex_coordinates() 503 503 print 'number of triangle', len(V) 504 504 #Check each triangle 505 505 for i in range(N): 506 506 507 x0 = V[i, 0]; y0 = V[i, 1] 507 508 x1 = V[i, 2]; y1 = V[i, 3] … … 561 562 for i in range(N): 562 563 for v in self.triangles[i, :]: 564 print v 563 565 #Check that all vertices have been registered 564 566 assert self.vertexlist[v] is not None -
production/onslow_2006/export_results.py
r2543 r2682 1 1 import project, os 2 from os import sep 2 3 3 4 from pyvolution.data_manager import sww2dem 4 5 from pyvolution.ermapper_grids import read_ermapper_grid 5 6 6 #name = project.outputname 7 name = project.outputname 7 #name = project.outputname 8 8 9 time_dir = "20060328_094539_alpha_0.1" 10 directory = project.outputdir 11 name = directory + time_dir +sep + "source" 12 13 print'output dir:', name 9 14 #print 'Which variable do you want to export?' 10 15 #which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3 ' )) 11 which_var = 216 which_var = 4 12 17 13 18 if which_var == 0: # Stage … … 29 34 quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)' #Speed 30 35 36 if which_var == 4: # Elevation 37 outname = name + '_elevation' 38 quantityname = 'elevation' #Elevation 39 31 40 32 41 sww2dem(name, basename_out = outname, 33 42 quantity = quantityname, 34 cellsize = 25, # Trevor would like this at 2543 cellsize = 30, # Trevor would like this at 25 35 44 # define region for viz purposes 36 easting_min = project.e minviz,37 easting_max = project.e maxviz,38 northing_min = project.n minviz,39 northing_max = project.n maxviz,45 easting_min = project.e_min_area, 46 easting_max = project.e_max_area, 47 northing_min = project.n_min_area, 48 northing_max = project.n_max_area, 40 49 reduction = max, #this is because we want max quantityname 41 50 verbose = True, -
production/onslow_2006/get_timeseries.py
r2543 r2682 7 7 from coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn 8 8 from pylab import * 9 from matplotlib.ticker import MultipleLocator, FormatStrFormatter 10 11 swwfile = project.outputname + '.sww' 9 from os import sep 10 # from matplotlib.ticker import MultipleLocator, FormatStrFormatter 11 12 13 14 time_dir = "20060331_155157" 15 directory = project.outputdir 16 swwfile = directory + time_dir +sep + "source.sww" 17 18 #swwfile = project.outputname + '.sww' 12 19 13 20 def get_gauges_from_file(filename): … … 21 28 fields = line.split(',') 22 29 # my gauge file set up as locationname, easting, northing 23 location = fields[0] 24 easting = float(fields[1]) 25 northing = float(fields[2]) 30 31 easting = float(fields[0]) 32 northing = float(fields[1]) 33 location = fields[2] 26 34 #z, easting, northing = redfearn(lat, lon) 27 35 gauges.append([easting, northing]) … … 31 39 return gauges, lines, gaugelocation 32 40 33 gauges, lines, locations = get_gauges_from_file(project.gauge_filename)41 gauges, lines, gauge_names = get_gauges_from_file(project.gauge_filename) 34 42 35 43 print 'number of gauges: ', len(gauges) … … 37 45 #Read model output 38 46 quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] 47 39 48 f = file_function(swwfile, 40 49 quantities = quantities, … … 47 56 from math import sqrt, atan, degrees 48 57 from Numeric import ones 58 49 59 N = len(gauges) 60 50 61 for k, g in enumerate(gauges): 51 62 if k%((N+10)/10)==0: # diagnostics - print 10 lines … … 77 88 uh = f(t, point_id = k)[2] 78 89 vh = f(t, point_id = k)[3] 79 myloc = locations[k]90 myloc = gauge_names[k] 80 91 depth = w-z 81 92 … … 137 148 loc='upper right') 138 149 #savefig('Gauge_%d_stage' %k) 139 savefig('Gauge_%s_stage' %myloc) 140 141 # raw_input('Next') 142 150 #savefig('Gauge_%s_stage' %myloc) 151 savefig(project.gaugetimeseries+'Gauge_'+myloc+'_stage') 152 153 # raw_input('Next') 154 ''' 143 155 #Momentum plot 144 156 ion() … … 188 200 #savefig('Gauge_%d_speed' %k) 189 201 savefig('Gauge_%s_speed' %myloc) 190 202 ''' 191 203 # raw_input('Next') 192 204 -
production/onslow_2006/project.py
r2645 r2682 40 40 41 41 #Derive subdirectories and filenames 42 time dir= strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir43 output dir = home+sep+scenario_dir_name+sep+'output'+sep+timedir+sep42 time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir 43 outputtimedir = home+sep+scenario_dir_name+sep+'output'+sep+time+sep 44 44 meshdir = home+sep+scenario_dir_name+sep+'meshes'+sep 45 45 datadir = home+sep+scenario_dir_name+sep+'topographies'+sep 46 46 gaugedir = home+sep+scenario_dir_name+sep+'gauges'+sep 47 47 polygondir = home+sep+scenario_dir_name+sep+'polygons'+sep 48 48 boundarydir = home+sep+scenario_dir_name+sep+'boundaries'+sep 49 #output dir without time 50 outputdir = home+sep+scenario_dir_name+sep+'output'+sep 51 52 49 53 print'bound', boundarydir 54 55 gauge_filename = gaugedir + 'onslow_gauges.xya' 56 57 gaugetimeseries = gaugedir + 'onslow' 50 58 51 59 # boundary source data … … 66 74 combined_dem_name = datadir + 'onslow_combined_elevation' 67 75 68 outputname = output dir + basename #Used by post processing76 outputname = outputtimedir + basename #Used by post processing 69 77 70 78 #!gauge_filename = outputdir + 'onslow_gauges.xya' 71 79 #!gauge_outname = outputdir + 'gauges_max_output.xya' 72 80 73 # clipping region forfine elevation data74 eastingmin = 2 5000075 eastingmax = 3 3000081 # clipping region to make DEM (pts file) from fine elevation data 82 eastingmin = 240000 83 eastingmax = 340000 76 84 northingmin = 7580000 77 northingmax = 7 63500085 northingmax = 7700000 78 86 79 south = degminsec2decimal_degrees(-2 2,00,0)80 north = degminsec2decimal_degrees(-2 1,10,0)81 west = degminsec2decimal_degrees(114, 30,0)87 south = degminsec2decimal_degrees(-21,55,0) 88 north = degminsec2decimal_degrees(-20,50,0) 89 west = degminsec2decimal_degrees(114,25,0) 82 90 east = degminsec2decimal_degrees(115,30,0) 83 91 ''' 84 92 # region for visualisation 85 93 eminviz = 260000 … … 87 95 nminviz = 7590000 88 96 nmaxviz = 7630000 97 ''' 98 # region to export 99 100 e_min_area = 280000 101 e_max_area = 310000 102 n_min_area = 7590000 103 n_max_area = 7630000 89 104 90 105 #Georeferencing … … 93 108 refzone = 50 94 109 95 # Main Domain of Onslow: first run NB 21/2/0696 d0 = [3 05000, 7635000]97 d1 = [280000, 76 35000]98 d2 = [2 50000, 7615000]99 d3 = [2 50000, 7590000]100 d4 = [ 310000, 7580000]101 d5 = [3 30000, 7610000]102 d6 = [3 30000, 7620000]110 #Updated Main Domain of Onslow: first run NB 6/4/06 111 d0 = [310000, 7690000] 112 d1 = [280000, 7690000] 113 d2 = [270000, 7645000] 114 d3 = [240000, 7625000] 115 d4 = [270000, 7580000] 116 d5 = [300000, 7590000] 117 d6 = [340000, 7610000] 103 118 104 119 polyAll = [d0, d1, d2, d3, d4, d5, d6] … … 122 137 123 138 poly_thevenard = [j0, j1, j2, j3] 124 139 ''' 125 140 # Direction Is 126 141 k0 = [309000, 7619000] … … 130 145 131 146 poly_direction = [k0, k1, k2, k3] 132 147 ''' -
production/onslow_2006/run_onslow.py
r2645 r2682 3 3 Source data such as elevation and boundary data is assumed to be available in 4 4 directories specified by project.py 5 The output sww file is stored in project.output dir5 The output sww file is stored in project.outputtimedir 6 6 7 7 The scenario is defined by a triangular mesh created from project.polygon, … … 45 45 46 46 # filenames 47 coarsedemname = project.coarsedemname47 #coarsedemname = project.coarsedemname 48 48 49 49 onshore_dem_name = project.onshore_dem_name … … 56 56 57 57 # creates copy of code in output dir if dir doesn't exist 58 if access(project.output dir,F_OK) == 0 :59 mkdir (project.output dir)60 copy (project.codedirname, project.output dir + project.codename)61 copy (project.codedir + 'run_onslow.py', project.output dir + 'run_onslow.py')58 if access(project.outputtimedir,F_OK) == 0 : 59 mkdir (project.outputtimedir) 60 copy (project.codedirname, project.outputtimedir + project.codename) 61 copy (project.codedir + 'run_onslow.py', project.outputtimedir + 'run_onslow.py') 62 62 print'hello' 63 ''' 64 copied_files = False 65 66 # files to be used 67 files_used = [onshore_dem_name, offshore_points,] 68 69 if sys.platform != 'win32': 70 copied_files = True 71 for name in file_list: 72 copy(name, ) 73 ''' 63 74 #print' most file', project.MOST_dir + project.boundary_basename+'_ha.nc' 64 75 #if access(project.MOST_dir + project.boundary_basename+'_ha.nc',F_OK) == 1 : 65 76 # print' most file', project.MOST_dir + project.boundary_basename 66 67 ''' 68 # coarse data 69 convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True) 70 dem2pts(coarsedemname, use_cache=True, verbose=True) 71 77 ''' 72 78 73 79 # fine data (clipping the points file to smaller area) 80 # creates DEM from asc data 74 81 convert_dem_from_ascii2netcdf(onshore_dem_name, use_cache=True, verbose=True) 82 83 #creates pts file from DEM 75 84 dem2pts(onshore_dem_name, 76 85 easting_min=project.eastingmin, … … 80 89 use_cache=True, 81 90 verbose=True) 82 '''83 91 84 92 print'create G1' … … 93 101 print'export G' 94 102 G.new_export_points_file(project.combined_dem_name + '.pts') 95 103 ''' 96 104 97 105 #------------------------------------------------------------------------------- … … 104 112 105 113 # original 106 interior_res = 500 00114 interior_res = 500 107 115 interior_regions = [[project.poly_onslow, interior_res], 108 [project.poly_thevenard, interior_res], 109 [project.poly_direction, interior_res]] 110 #[project.testpoly, interior_res]] 116 [project.poly_thevenard, interior_res]] 117 111 118 print 'number of interior regions', len(interior_regions) 112 119 … … 115 122 project.polyAll, 116 123 {'boundary_tags': {'top': [0], 'topleft': [1], 117 ' left': [2], 'bottom': [3],118 'bottom right': [4], 'right': [5],124 'topleft1': [2], 'bottomleft': [3], 125 'bottom': [4], 'bottomright': [5], 119 126 'topright':[6]}, 120 'maximum_triangle_area': 10000 00,127 'maximum_triangle_area': 10000, 121 128 'filename': meshname, 122 129 'interior_regions': interior_regions}, … … 129 136 130 137 domain = pmesh_to_domain_instance(meshname, Domain, 131 use_cache = True,138 use_cache = False, 132 139 verbose = True) 133 140 … … 137 144 138 145 domain.set_name(project.basename) 139 domain.set_datadir(project.output dir)146 domain.set_datadir(project.outputtimedir) 140 147 domain.set_quantities_to_be_stored(['stage']) 141 148 … … 190 197 east = project.east 191 198 199 #note only need to do when an SWW file for the MOST boundary doesn't exist 192 200 cache(ferret2sww, 193 201 (source_dir + project.boundary_basename, … … 228 236 229 237 domain.set_boundary( {'top': Bf, 'topleft': Bf, 230 'left': Br, 'bottom': Br, 231 'bottomright': Br, 'right': Br, 'topright': Br} ) 232 238 'topleft1': Bf, 'bottomleft': Bd, 239 'bottom': Br, 'bottomright': Br, 'topright': Bd} ) 233 240 234 241 #------------------------------------------------------------------------------- … … 238 245 t0 = time.time() 239 246 240 for t in domain.evolve(yieldstep = 1000, finaltime = 3000):247 for t in domain.evolve(yieldstep = 500, finaltime = 3000): 241 248 domain.write_time() 242 249 domain.write_boundary_statistics(tags = 'top') 243 250 244 for t in domain.evolve(yieldstep = 100, finaltime = 20000,245 251 for t in domain.evolve(yieldstep = 60, finaltime = 15000): 252 # ,skip_initial_step = True): 246 253 domain.write_time() 247 254 domain.write_boundary_statistics(tags = 'top')
Note: See TracChangeset
for help on using the changeset viewer.