Changeset 2972
 Timestamp:
 May 25, 2006, 3:42:31 PM (18 years ago)
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

development/stochastic_study/plot_spread.py
r2967 r2972 2 2 """ 3 3 4 # Standard modules 4 5 import sys, os 6 7 # Related major packages 8 from Numeric import zeros, Float, allclose, arange 5 9 from caching import cache 10 11 # Application specific imports 12 from utilities.numerical_tools import histogram, create_bins 6 13 import project 7 14 15 # Initialise 8 16 gauge_name = project.gauge_names[0] 9 from Numeric import zeros, Float, allclose10 11 12 17 number_of_realisations = project.number_of_realisations 13 18 14 19 time = zeros(project.number_of_timesteps, Float) 15 20 data = zeros((project.number_of_timesteps, number_of_realisations), Float) 21 22 23 # Read in all realisationstimeseries 16 24 17 25 j = 0 # Count realisations … … 37 45 38 46 ion() 39 hold(True)47 #hold(True) 40 48 hold(False) 41 49 42 #for i in range(project.number_of_timesteps): 43 # print i, data[i,:] 44 # plot(data[i,:], 'k.') 45 # raw_input('Next') 46 50 # Simple plot of timeseries for different realisations 47 51 for j in range(number_of_realisations): 48 print j, data[:,j]52 #print j, data[:,j] 49 53 plot(data[:,j], 'k') 50 54 51 55 raw_input('Next') 56 xlabel('time(s)') 57 ylabel('stage (m)') 58 title('Realisation %d of %d' %(j, number_of_realisations)) 59 60 61 62 # Plot histogram of stage values for each timestep 63 for i in range(project.number_of_timesteps): 64 # Plot histogram 65 66 w = data[i,:] 67 68 bins = create_bins(w, project.number_of_bins) 69 print 'bins', bins 70 hist = histogram(w, bins) 71 print 'hist', hist 72 73 #plot(w, 'k.') 74 plot(hist, 'k.') 75 xlabel('stage (m)') 76 ylabel('count') 77 title('Timestep %d of %d (t=%.2f)'\ 78 %(i, project.number_of_timesteps, time[i])) 79 raw_input('Next') 80 81 52 82 #title('Gauge %s' %name) 53 83 #xlabel('time(s)') … … 55 85 #legend(('Observed', 'Modelled'), shadow=True, loc='upper left') 56 86 #savefig(name, dpi = 300) 87 88 89 90 57 91 58 92 
development/stochastic_study/project.py
r2966 r2972 19 19 20 20 # Stats (Suresh ?) 21 number_of_realisations = 421 number_of_realisations = 1 22 22 #std_dev = 0.0026 #Range is 26.035 cm 23 23 std_dev = 0.0013 #Range is 26.035 cm … … 25 25 blocksize = 100 #How many realisations to fit at a time 26 26 27 27 number_of_bins = 10 28 28 29 29 
inundation/pyvolution/mesh.py
r2866 r2972 689 689 690 690 from Numeric import arange 691 from utilities.numerical_tools import histogram 691 from utilities.numerical_tools import histogram, create_bins 692 692 693 693 vertex_coordinates = self.vertex_coordinates … … 698 698 699 699 #Setup 10 bins for area histogram 700 m = max(areas) 701 bins = arange(0., m, m/10) 700 bins = create_bins(areas, 10) 701 #m = max(areas) 702 #bins = arange(0., m, m/10) 702 703 hist = histogram(areas, bins) 703 704 
inundation/utilities/numerical_tools.py
r2778 r2972 8 8 #(this should move to somewhere central) 9 9 try: 10 from scipy import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate, Float 10 from scipy import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate, Float, arange 11 11 except: 12 12 #print 'Could not find scipy  using Numeric' 13 from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate, Float 13 from Numeric import ArrayType, array, sum, innerproduct, ravel, sqrt, searchsorted, sort, concatenate, Float, arange 14 14 15 15 # Getting an infinite number to use when using Numeric … … 212 212 return n[1:]n[:1] 213 213 214 def create_bins(data, number_of_bins = None): 215 """Safely create bins for use with histogram 216 If data contains only one point or is constant, one bin will be created. 217 If number_of_bins in omitted 10 bins will be created 218 """ 219 220 mx = max(data) 221 mn = min(data) 222 223 if mx == mn: 224 bins = array([mn]) 225 else: 226 if number_of_bins is None: 227 number_of_bins = 10 228 229 bins = arange(mn, mx, (mxmn)/number_of_bins) 230 231 return bins 232 214 233 215 234
Note: See TracChangeset
for help on using the changeset viewer.