Changeset 5580 for anuga_work/production/perth/get_gauges.py
- Timestamp:
- Jul 25, 2008, 6:35:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/production/perth/get_gauges.py
r5576 r5580 1 1 import os 2 2 from os import sep 3 #import create_boundary4 3 import project 5 4 try: … … 18 17 x = fid.variables['x'][:]+fid.xllcorner #x-coordinates of vertices 19 18 y = fid.variables['y'][:]+fid.yllcorner #y-coordinates of vertices 20 print 'heloo', len(x), len(y)21 19 points=transpose(asarray([x.tolist(),y.tolist()])) 22 20 time=fid.variables['time'][:] … … 32 30 #plot(polygon[:,0],polygon[:,1]) 33 31 #show() 34 32 33 basename='sts_gauge' 35 34 quantity_names=['stage','xmomentum','ymomentum'] 36 37 fid_sts = open(project.boundaries_dir+sep+'sts_gauge.csv', 'w')38 s = 'time, stage, xmomentum, ymomentum \n'39 fid_sts.write(s)40 35 quantities = {} 41 36 for i, name in enumerate(quantity_names): 42 37 quantities[name] = fid.variables[name][:] 43 print len(quantities[name])44 38 if inside_points is not None: 45 39 quantities[name] = take(quantities[name],indices,1) 46 for j in range(len(x)): 40 for j in range(len(x)-1): 41 locx=int(x[j]) 42 locy=int(y[j]) 43 fid_sts = open(project.boundaries_dir+sep+basename+'_'+str(locx)+'_'+str(locy)+'.csv', 'w') 44 s = 'time, stage, xmomentum, ymomentum \n' 45 fid_sts.write(s) 47 46 stage = quantities[name][:,j] 48 47 xmomentum = quantities[name][:,j] 49 48 ymomentum = quantities[name][:,j] 50 #print 'hello', len(stage)51 #s = '%.2f, %.2f, %.2f, %.2f\n' %(time[j], stage, xmomentum, ymomentum)52 #fid_sts.write(s)49 for k in range(len(time)-1): 50 s = '%.2f, %.2f, %.2f, %.2f\n' %(time[k], stage[k], xmomentum[k], ymomentum[k]) 51 fid_sts.write(s) 53 52 else: 54 53 msg = 'No gauges found inside polygon' 55 54 raise msg 55 fid_sts.close() 56 56 fid.close() 57 57 … … 59 59 60 60 polygon=project.poly_all 61 points,quantities,elevation,time=get_sts_gauge_data(project.scenario_name,polygon,verbose=False) 62 from Numeric import size 63 print 'hello', len(quantities['stage']) 61 points,quantities,elevation,time=get_sts_gauge_data(os.path.join(project.boundaries_dir,project.scenario_name),polygon,verbose=False) 62 64 63 65 64 assert len(points)==len(elevation)==len(quantities['stage'][0,:]) 66 67 ##def plot_gauge(time,quantity,quantity_name,elevation,gauge_id,pos):68 ## figname=figname = '%s_%s%s.png' %('tgs/urs_gauge',69 ## quantity_name,70 ## str(gauge_id))71 ## hold(False)72 ## plot(time/60.0,quantity,label='%s (elevation = %sm)'%('urs',str(elevation)))73 ## title('Gauge %d at (%f,%f)' %(gauge_id,pos[0],pos[1]))74 ## xlabel('Time (minutes)')75 ## ylabel(quantity_name)76 ## legend()77 ## print 'saving figure here %s' %figname78 ## savefig(figname)79 ##80 ##points=points[::5]81 ##elevation=elevation[::5]82 ##gauge_filename=project.boundaries_dir+sep+'urs_gauges'83 ##d=','84 ##if os.path.exists(gauge_filename+ '.txt'):85 ## print 'file with list of gauges already created'86 ##else:87 ## fid = open(gauge_filename+ '.txt', 'w')88 ## fid.write('easting,northing,name,elevation\n')89 ## for i in range(len(points)):90 ## fid.write(str(points[i][0])+d+str(points[i][1])+d+str(i)+d+str(elevation[i])+'\n')91 ## fid.close()92
Note: See TracChangeset
for help on using the changeset viewer.