source: development/stochastic_study/plot_spread.py @ 2967

Last change on this file since 2967 was 2967, checked in by ole, 19 years ago

Added function for plotting realisations of timeseries

File size: 1.6 KB
Line 
1"""Read in timeseries from N simulations and plot spread for each timestep at specified locations (ch 5,7,9)
2"""
3
4import sys, os
5from caching import cache
6import project
7
8gauge_name = project.gauge_names[0]
9from Numeric import zeros, Float, allclose
10
11
12number_of_realisations = project.number_of_realisations
13
14time = zeros(project.number_of_timesteps, Float)
15data = zeros((project.number_of_timesteps, number_of_realisations), Float)
16
17j = 0 # Count realisations
18for filename in os.listdir('.'):
19    if filename.startswith(project.basename) and filename.endswith('%s.txt' %gauge_name):
20        if j < data.shape[1]:       
21            print 'Reading filename %s (column %d)' %(filename, j)
22            fid = open(filename)
23            for i, line in enumerate(fid.readlines()):
24                if i < data.shape[0]:
25                    fields = line.strip().split()
26                    time[i] = float(fields[0])
27                    data[i,j] = float(fields[1])
28        else:
29            print 'Ignored %s (column %d)' %(filename, j)
30
31        fid.close()
32        j += 1   
33
34
35# Plot
36from pylab import ion, hold, plot, title, xlabel, ylabel, legend, savefig, show
37
38ion()
39hold(True)
40hold(False)
41
42#for i in range(project.number_of_timesteps):
43#    print i, data[i,:]
44#    plot(data[i,:], 'k.')
45#    raw_input('Next')   
46
47for j in range(number_of_realisations):
48    print j, data[:,j]
49    plot(data[:,j], 'k-')
50   
51    raw_input('Next')
52#title('Gauge %s' %name)
53#xlabel('time(s)')
54#ylabel('stage (m)')   
55#legend(('Observed', 'Modelled'), shadow=True, loc='upper left')
56#savefig(name, dpi = 300)
57
58
59show()
60
61
62
63#from pylab import *
64#plot(time, stage)
65#show()
Note: See TracBrowser for help on using the repository browser.