Changeset 7794 for branches/anuga_1_1/anuga_work/production/bunbury_storm_surge_2009/build_gems_boundary.py
- Timestamp:
- Jun 7, 2010, 9:38:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/anuga_1_1/anuga_work/production/bunbury_storm_surge_2009/build_gems_boundary.py
r7678 r7794 13 13 import sys 14 14 # sys.path.append('W:\\sandpits\\lfountain\\anuga_work\\production\\mandurah_storm_surge_2009\\gems_comparison') 15 sys.path.append('/nas/gemd/georisk_models/inundation/sandpits/lfountain/anuga_work/production/mandurah_storm_surge_2009/gems_comparison')16 import project _GEMS_grid15 #sys.path.append('/nas/gemd/georisk_models/inundation/sandpits/lfountain/anuga_work/production/mandurah_storm_surge_2009/gems_comparison') 16 import project 17 17 from Scientific.IO.NetCDF import NetCDFFile 18 18 from anuga.coordinate_transforms.geo_reference import Geo_reference, write_NetCDF_georeference … … 23 23 state = 'western_australia' 24 24 scenario_folder = 'bunbury_storm_surge_scenario_2009' 25 event = ' case_1' # Baseline TC Alby event25 event = '20100527_gcom_12min' # Baseline TC Alby event 26 26 27 27 ENV_INUNDATIONHOME = 'INUNDATIONHOME' … … 35 35 # Define boundary points to extract from master STS file 36 36 #-------------------------------------------------------- 37 gems_boundary = numpy.array(read_polygon(project_GEMS_grid.gems_order)) 37 gems_boundary = numpy.array(read_polygon(project.gems_order)) 38 #gems_boundary = numpy.array(read_polygon(project.gauges)) 38 39 number_of_points = gems_boundary.shape[0] 40 print 'hello', number_of_points 41 print 'points', gems_boundary 39 42 40 43 #--------------------------------------------------------- … … 42 45 #--------------------------------------------------------- 43 46 print "Reading master NetCDF file" 44 infile = NetCDFFile(os.path.join(event_folder, event + '_master .sts'), 'r')47 infile = NetCDFFile(os.path.join(event_folder, event + '_master_2_1.sts'), 'rl') #rl for large netcdf files 45 48 46 49 grid_size = infile.grid_size … … 69 72 origin = numpy.array([x_origin[0], y_origin[0]]) 70 73 index_array_2D = ((gems_boundary - origin)/grid_size).astype(int) 71 assert index_array_2D[:,0].min() >= 0 and index_array_2D[:,0].max() <= ncols 74 assert index_array_2D[:,0].min() >= 0 and index_array_2D[:,0].max() <= ncols # These test that the boundary points lie within the data area 72 75 assert index_array_2D[:,1].min() >= 0 and index_array_2D[:,1].max() <= nrows 73 76 … … 135 138 s[i] = stage[i,:] 136 139 xm[i] = xmomentum[i,:] 137 ym[i] = ymomentum[i,:] 138 140 ym[i] = ymomentum[i,:] 141 142 #--------------------------------------------------------------------------- 143 # Get timeseries values for wave height and components of momentum 144 #--------------------------------------------------------------------------- 145 146 basename = 'sts_gauge_tide' 147 for i in xrange(number_of_points): 148 out_file = os.path.join(event_folder, 149 basename+'_'+str(i)+'.csv') 150 fid_sts = open(out_file, 'w') 151 fid_sts.write('time, stage, xmomentum, ymomentum, elevation \n') 152 for j in xrange(number_of_timesteps): 153 fid_sts.write('%.6f, %.6f, %.6f, %.6f, %.6f\n' 154 % (time[j], stage[j,i], xmomentum[j,i], ymomentum[j,i], elevation[i])) 155 156 fid_sts.close() 157 139 158 origin = Geo_reference(refzone, x_origin, y_origin) 140 159 geo_ref = write_NetCDF_georeference(origin, fid) 141 160 142 161 fid.variables['x'][:] = x 143 fid.variables['y'][:] = y 162 fid.variables['y'][:] = y 144 163 145 164 fid.close() 165 166 sys.exit() 167 168 print 'get timeseries' 169 #------------------------------------------------------------------------------- 170 # Get gauges (timeseries of index points) 171 #------------------------------------------------------------------------------- 172 173 basename = 'sts_gauge' 174 quantity_names = ['stage', 'xmomentum', 'ymomentum'] 175 quantities = {} 176 for i, name in enumerate(quantity_names): 177 quantities[name] = fid.variables[name][:] 178 179 180 for j in range(len(x)): 181 index = j # permutation[j] 182 stage = quantities['stage'][:,j] 183 #print 'hello', j, stage 184 xmomentum = quantities['xmomentum'][:,j] 185 ymomentum = quantities['ymomentum'][:,j] 186 187 out_file = os.path.join(event_folder, 188 basename+'_'+str(index)+'.csv') 189 fid_sts = open(out_file, 'w') 190 fid_sts.write('time, stage, xmomentum, ymomentum \n') 191 192 #----------------------------------------------------------------------- 193 # End of the get gauges 194 #----------------------------------------------------------------------- 195 for k in range(len(time)-1): 196 fid_sts.write('%.6f, %.6f, %.6f, %.6f\n' 197 % (time[k], stage[k], xmomentum[k], ymomentum[k])) 198 199
Note: See TracChangeset
for help on using the changeset viewer.