Changeset 3035
- Timestamp:
- May 31, 2006, 5:03:59 PM (19 years ago)
- Location:
- development/stochastic_study
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
development/stochastic_study/create_realisations.py
r2979 r3035 72 72 use_cache = False) 73 73 74 print V.shape75 print V[:2,:]76 74 Z = None 77 75 -
development/stochastic_study/plot_spread.py
r3011 r3035 15 15 # Initialise 16 16 # Read in all realisations-timeseries 17 study = 'cyclone1' 18 study = 'cyclone3' 19 #study = 'nautilus3' 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 20 study = 'cyclone1' #~4000 realisations, blocks of 100, parallel, stddev= 0.0006 21 #study = 'cyclone3' #~120 realisations, blocks of 10, parallel, stddev= 0.0013 20 22 21 23 time, data, filenames = read_realisations(study, 22 24 #max_realisations = 200, 23 gauge_number=2, 24 use_cache=False) 25 gauge_number=0, 26 sorting='randomised', 27 #sorting='numerical', 28 verbose=True, 29 use_cache=True) 25 30 number_of_realisations = data.shape[1] 31 number_of_timesteps = data.shape[0] 26 32 print 'Read %d realisations' %number_of_realisations 33 27 34 28 35 # Plot … … 34 41 35 42 36 for j in range( 20):43 for j in range(1): 37 44 #print j, filenames[j] 38 45 plot(time, data[:,j], 'k-') … … 45 52 %(study, shortname, j, number_of_realisations-1)) 46 53 47 #title('Study %s: timeseries for %s (realisation %d of %d)'\ 48 # %(study, filenames[j], j, number_of_realisations-1)) 49 raw_input('Next') 54 #raw_input('Next') 55 56 57 raw_input('Stats') 50 58 51 59 … … 53 61 hold(False) 54 62 # Plot spread of stage values for each timestep 55 for i in range( 300,320): #project.number_of_timesteps):63 for i in range(0,project.number_of_timesteps): 56 64 # Plot histogram# 57 65 … … 62 70 title('Study %s: spread at timestep %d of %d (t=%.2f)'\ 63 71 %(study, i, project.number_of_timesteps-1, time[i])) 64 72 raw_input('Next') 65 73 74 show() 75 import sys; sys.exit() 66 76 67 77 hold(False) -
development/stochastic_study/project.py
r3011 r3035 27 27 28 28 # Stats (Suresh ?) 29 number_of_realisations = 129 number_of_realisations = 2 30 30 31 31 #number_of_realisations = 16000 32 32 33 #std_dev = 0.0026 #Range is 26.035 cm 34 std_dev = 0.0013 #Range is 26.035 cm (simulation 3) 35 #std_dev = 0.0006 #Range is 26.035 cm (simulation 1) 33 std_dev = 0.0013 #m #Range is 26.035 cm (simulation 3) 34 #std_dev = 0.0006 #m #Range is 26.035 cm (simulation 1) 36 35 mean = 0.0 37 36 blocksize = 100 #How many realisations to fit at a time -
development/stochastic_study/read_realisations.py
r3006 r3035 5 5 import project 6 6 from Numeric import Float, zeros 7 from RandomArray import randint 7 8 from caching import cache 8 9 9 10 def read_realisations(subdir, max_realisations = None, gauge_number=0, 10 exclude=None, use_cache=False, verbose=True): 11 exclude=None, 12 sorting=None, 13 use_cache=False, 14 verbose=True): 11 15 """Read realisations 12 16 """ … … 17 21 {'max_realisations': max_realisations, 18 22 'gauge_number': gauge_number, 19 'exclude': exclude}, 23 'exclude': exclude, 24 'sorting': sorting}, 20 25 verbose=verbose) 21 26 else: … … 23 28 max_realisations = max_realisations, 24 29 gauge_number=gauge_number, 25 exclude=exclude) 30 exclude=exclude, 31 sorting=sorting) 26 32 27 33 return result 28 34 35 29 36 def _read_realisations(subdir, max_realisations = None, gauge_number=0, 30 exclude=None, use_cache=False, verbose=True): 37 exclude=None, sorting=None, 38 use_cache=False, verbose=True): 31 39 """Read realisations 32 40 """ … … 52 60 time = zeros(project.number_of_timesteps, Float) 53 61 data = zeros((project.number_of_timesteps, len(filenames)), Float) 54 62 63 if sorting is None: 64 pass 65 elif sorting == 'numerical': 66 filenames = sort_numerically(filenames) 67 elif sorting == 'randomised': 68 filenames = randomise(filenames) 69 else: 70 print 'Invalid value for sorting: %s' %sorting 71 import sys; sys.exit() 72 73 55 74 # Read data 56 75 … … 68 87 69 88 return time, data, filenames 89 90 91 def sort_numerically(filenames): 92 """Sort filenames numerically 93 simulation_realisation_n_ch.... (sort by n) 94 """ 95 96 print 'Sorting' 97 sorted_filenames = [] 98 99 numbers = [] 100 for filename in filenames: 101 fields = filename.split('_') 102 n = int(fields[2]) 103 numbers.append(n) 104 105 A = zip(numbers, filenames) 106 A.sort() 107 108 sorted_filenames = [a[1] for a in A] 109 110 return sorted_filenames 111 112 113 def randomise(filenames): 114 """Randomise filenames 115 """ 116 117 print 'Randomising' 118 randomised_filenames = [] 119 120 121 while len(filenames) > 0: 122 n = randint(0, len(filenames)) 123 filename = filenames[n] 124 del filenames[n] 125 randomised_filenames.append(filename) 126 127 return randomised_filenames -
development/stochastic_study/run_model.py
r3009 r3035 134 134 finaltime = finaltime): 135 135 pass 136 #domain.write_time()136 domain.write_time() 137 137 138 138
Note: See TracChangeset
for help on using the changeset viewer.