1 | """Read in timeseries from N simulations and plot spread for each timestep at specified locations (ch 5,7,9) |
---|
2 | """ |
---|
3 | |
---|
4 | # Standard modules |
---|
5 | import sys, os |
---|
6 | |
---|
7 | # Related major packages |
---|
8 | from Numeric import zeros, Float, allclose, arange |
---|
9 | |
---|
10 | # Application specific imports |
---|
11 | from utilities.numerical_tools import histogram, create_bins |
---|
12 | from read_realisations import read_realisations |
---|
13 | import project |
---|
14 | |
---|
15 | # Initialise |
---|
16 | # Read in all realisations-timeseries |
---|
17 | time, data, filenames = read_realisations('cyclone1', |
---|
18 | max_realisations = 200, |
---|
19 | use_cache=True) |
---|
20 | #time, data, filenames = read_realisations('test', exclude='_0_', |
---|
21 | # max_realisations = 200, |
---|
22 | # use_cache=True) |
---|
23 | #time, data, filenames = read_realisations('nautilus1', exclude='_0_') |
---|
24 | number_of_realisations = data.shape[1] |
---|
25 | |
---|
26 | |
---|
27 | # Plot |
---|
28 | from pylab import ion, hold, plot, title, xlabel, ylabel, legend, savefig, show |
---|
29 | |
---|
30 | ion() |
---|
31 | hold(True) |
---|
32 | #hold(False) |
---|
33 | |
---|
34 | # Simple plot of timeseries for different realisations |
---|
35 | for j in range(20): |
---|
36 | print j, filenames[j] |
---|
37 | plot(time, data[:,j], 'k-') |
---|
38 | |
---|
39 | xlabel('time(s)') |
---|
40 | ylabel('stage (m)') |
---|
41 | title('Timeseries for realisation %d of %d' %(j, number_of_realisations-1)) |
---|
42 | raw_input('Next') |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | hold(False) |
---|
47 | # Plot spread of stage values for each timestep |
---|
48 | for i in range(300,320): #project.number_of_timesteps): |
---|
49 | # Plot histogram# |
---|
50 | |
---|
51 | w = data[i,:] |
---|
52 | plot(w, 'k.') |
---|
53 | xlabel('realisations') |
---|
54 | ylabel('stage (m)') |
---|
55 | title('Spread at timestep %d of %d (t=%.2f)'\ |
---|
56 | %(i, project.number_of_timesteps-1, time[i])) |
---|
57 | raw_input('Next') |
---|
58 | |
---|
59 | |
---|
60 | hold(False) |
---|
61 | # Plot histogram of stage values for each timestep |
---|
62 | for i in range(300,320):#project.number_of_timesteps): |
---|
63 | # Plot histogram |
---|
64 | |
---|
65 | w = data[i,:] |
---|
66 | |
---|
67 | bins = create_bins(w, project.number_of_bins) |
---|
68 | print 'bins', bins |
---|
69 | hist = histogram(w, bins, relative=True) |
---|
70 | #print 'hist', hist |
---|
71 | |
---|
72 | #plot(w, 'k.') |
---|
73 | plot(bins, hist, 'k.') |
---|
74 | xlabel('stage (m)') |
---|
75 | ylabel('frequency') |
---|
76 | title('Histogram at timestep %d of %d (t=%.2f)'\ |
---|
77 | %(i, project.number_of_timesteps-1, time[i])) |
---|
78 | raw_input('Next') |
---|
79 | |
---|
80 | |
---|
81 | #title('Gauge %s' %name) |
---|
82 | #xlabel('time(s)') |
---|
83 | #ylabel('stage (m)') |
---|
84 | #legend(('Observed', 'Modelled'), shadow=True, loc='upper left') |
---|
85 | #savefig(name, dpi = 300) |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | show() |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | #from pylab import * |
---|
97 | #plot(time, stage) |
---|
98 | #show() |
---|