source: anuga_work/development/stochastic_study/plot_spread.py @ 5599

Last change on this file since 5599 was 3514, checked in by duncan, 18 years ago

Hi all,
I'm doing a change in the anuga structure, moving the code to

\anuga_core\source\anuga

After you have done an svn update, the PYTHONPATH has to be changed to;
PYTHONPATH = anuga_core/source/

This is part of changes required to make installation of anuga quicker and reducing the size of our sandpits.

If any imports are broken, try fixing them. With adding anuga. to them for example. If this seems to have really broken things, email/phone me.

Cheers
Duncan

File size: 3.2 KB
Line 
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
5import sys, os, string
6
7# Related major packages
8from Numeric import zeros, Float, allclose, arange
9
10# Application specific imports
11from anuga.utilities.numerical_tools import histogram, create_bins
12from read_realisations import read_realisations
13import project
14
15# Initialise
16# Read in all realisations-timeseries
17
18#study = 'nautilus1' #~70 realisations, blocks of 100, sequential, stddev= 0.0006
19#study = 'nautilus3' #~100 realisations, blocks of 10, sequential, stddev= 0.0013
20study = 'cyclone1' #~4000 realisations, blocks of 100, parallel, stddev= 0.0006
21#study = 'cyclone3' #~120 realisations, blocks of 10, parallel, stddev= 0.0013
22
23time, data, filenames = read_realisations(study, 
24                                          #max_realisations = 200,
25                                          gauge_number=0,
26                                          sorting='randomised',
27                                          #sorting='numerical',
28                                          verbose=True,
29                                          use_cache=True)
30number_of_realisations = data.shape[1]
31number_of_timesteps = data.shape[0]
32print 'Read %d realisations' %number_of_realisations
33
34
35# Plot
36from pylab import ion, hold, plot, title, xlabel, ylabel, legend, savefig, show
37
38ion()
39hold(True)
40#hold(False)
41
42N=250
43for j in range(N):
44    #print j, filenames[j]
45    plot(time, data[:,j], 'k-')
46   
47    xlabel('time(s)')
48    ylabel('stage (m)')
49
50    shortname = string.join(os.path.split(filenames[j])[-1].split('_')[-2:], '_')
51    title('Study %s: timeseries for %s (realisation %d of %d)'\
52          %(study, shortname, j, number_of_realisations-1))
53   
54    #raw_input('Next')
55
56title('%d realisations' %N)
57savefig('realisations', dpi = 300)
58#raw_input('Stats')   
59 
60
61
62hold(False)
63# Plot spread of stage values for each timestep
64for i in range(0, project.number_of_timesteps, 10):
65    # Plot histogram#
66
67    w = data[i,:]
68    plot(w, 'k.')
69    xlabel('realisations')
70    ylabel('stage (m)')
71    #title('Study %s: spread at timestep %d of %d (t=%.2f)'\
72    #      %(study, i, project.number_of_timesteps-1, time[i]))
73    title('Spread at timestep %d of %d (t=%.2f)'\
74          %(i, project.number_of_timesteps-1, time[i]))
75
76    savefig('spread_%d' %i, dpi = 300)   
77    #raw_input('Next')
78
79show()
80import sys; sys.exit()
81
82hold(False)
83# Plot histogram of stage values for each timestep
84for i in range(300,320):#project.number_of_timesteps):
85    # Plot histogram
86
87    w = data[i,:]
88     
89    bins = create_bins(w, project.number_of_bins)
90    print 'bins', bins
91    hist = histogram(w, bins, relative=True)
92    #print 'hist', hist
93   
94    #plot(w, 'k.')
95    plot(bins, hist, 'k.')
96    xlabel('stage (m)')
97    ylabel('frequency')
98    title('Study %s: histogram at timestep %d of %d (t=%.2f)'\
99          %(study, i, project.number_of_timesteps-1, time[i]))       
100    raw_input('Next')
101
102
103#title('Gauge %s' %name)
104#xlabel('time(s)')
105#ylabel('stage (m)')   
106#legend(('Observed', 'Modelled'), shadow=True, loc='upper left')
107#savefig(name, dpi = 300)
108
109
110
111
112
113
114show()
115
116
117
118#from pylab import *
119#plot(time, stage)
120#show()
Note: See TracBrowser for help on using the repository browser.