source: anuga_work/production/shark_bay_2007/plot_gauges.py @ 6874

Last change on this file since 6874 was 4628, checked in by sexton, 18 years ago

basic plotting routine to look at frequency sweeps

File size: 4.9 KB
Line 
1"""Read in csv files and plot time series
2
3"""
4import project
5from pylab import plot, xlabel, ylabel, savefig, ion, hold, axis, close, figure, legend, title
6from os import sep
7
8directory = project.output_dir
9dirnames = [
10#'20070710_023849_run_final_-0.85_shark_bay_onielsen_10000_tide-0.85_coastpolys',
11#'20070710_001018_run_final_0.85_shark_bay_onielsen_10000_tide0.85_coastpolys',
12#'20070710_001110_run_final_0.85_shark_bay_onielsen_july2006_tide0.85_coastpolys',
13#'20070710_023824_run_final_-0.85_shark_bay_onielsen_july2006_tide-0.85_coastpolys',
14'20070712_003638_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T6',
15'20070712_003626_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T12',
16'20070712_003616_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T25',
17'20070712_003606_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T50',
18'20070712_001432_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T100',
19'20070712_002232_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T200',
20'20070712_003334_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T300',
21'20070712_002254_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T400',
22'20070712_003400_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T500',
23'20070712_003410_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T600',
24'20070712_003421_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T700',
25'20070712_002317_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T800',
26'20070712_002331_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T900',
27'20070712_003433_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T1000',
28'20070712_003443_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T1100',
29'20070712_003453_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T1200',
30'20070712_003527_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T1300',
31'20070712_002526_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T1800',
32'20070712_002604_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T3600',
33'20070712_002625_run_final_0.0_shark_bay_onielsen_experimental_A0.5_T7200'
34]
35
36period = [6,12,15,50,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1800,3600,7200]
37
38def get_time_series_from_file(filename):
39    fid = open(filename)
40    lines = fid.readlines()
41    fid.close()
42    t = []
43    stage = []
44    #depth = []
45    speed = []
46    #momentum = []
47    for line in lines[1:]:
48        fields = line.split(',')
49        t.append((float(fields[0])/3600.0))
50        stage.append(float(fields[1]))
51        #depth.append(float(fields[1])-float(fields[4]))
52        speed.append(float(fields[3]))
53        #momentum.append(float(fields[2]))
54    return stage, speed
55   
56from Numeric import zeros, Float, size
57gauges = range(3,80)
58plot_gauges = range(77)
59max_st = max_sp = min_st = min_sp = max_m = min_m = zeros((len(gauges),len(dirnames)), Float)
60max_t = []
61
62for j, dirname in enumerate(dirnames):
63    for i, gauge in enumerate(gauges):  #could alter get_all_swwfiles to get all file extension and get csv files??
64        extra = 'gauges_time_series_%d.csv' %(gauge)
65        filename = directory + dirname + sep + extra
66        stage, speed = get_time_series_from_file(filename)
67        #max_t.append(max(t))
68        max_st[i,j] = max(stage)
69        max_sp[i,j] = max(speed)
70        min_st[i,j] = min(stage)
71        min_sp[i,j] = min(speed)
72        #min_m[i,j] = min(mom)
73        #max_m[i,j] = max(mom)
74
75#find maximums for axis for plots
76#stage_axis = ([5000./3600.,max(max_t), min(min(min_st)), max(max(max_st))])
77#speed_axis = ([5000/3600.,max(max_t), min(min(min_sp)), max(max(max_sp))])
78#mom_axis = ([5000/3600.,max(max_t), min(min(min_m)), max(max(max_m))])
79
80ion()
81hold(False)
82
83for i in plot_gauges:
84    plot(period,min_st[i,:],'+',period,max_st[i,:],'+',period,min_st[i,:],period,max_st[i,:])
85    #plot(period,max_st[i,:],'+',period,max_st[i,:])
86    xlabel('Period')
87    ylabel('Stage (m)')
88    axis(stage_axis)
89    name = 'stage_period_%d' %(i+3)
90    savefig(name)
91    plot(period,min_sp[i,:],'+',period,max_sp[i,:],'+',period,min_sp[i,:],period,max_sp[i,:])
92    #plot(period,max_sp[i,:],'+',period,max_sp[i,:])
93    xlabel('Period')
94    ylabel('Speed (m/s)')
95    axis(speed_axis)
96    name = 'speed_period_%d' %(i)
97    savefig(name)
98
99for i, dirname in enumerate(dirnames):
100    plot(gauges,min_st[:,i],'+',gauges,max_st[:,i],'+',gauges,min_st[:,i],gauges,max_st[:,i])
101    #plot(gauges,max_st[:,i],'+',gauges,max_st[:,i])
102    xlabel('Gauge number')
103    ylabel('Stage (m)')
104    axis(stage_axis)
105    title(dirname)
106    j = dirname.rfind('_')
107    name = 'stage_%s' %(dirname[j+1:])
108    savefig(name)
109    plot(gauges,min_sp[:,i],'+',gauges,max_sp[:,i],'+',gauges,min_sp[:,i],gauges,max_sp[:,i])
110    #plot(gauges,max_sp[:,i],'+',gauges,max_sp[:,i])
111    xlabel('Gauge number')
112    ylabel('Speed (m/s)')
113    axis(speed_axis)
114    title(dirname)
115    name = 'speed_%s' %(dirname[j+1:])
116    savefig(name)
117
118close('all')
119
Note: See TracBrowser for help on using the repository browser.