Changeset 7651
- Timestamp:
- Mar 3, 2010, 2:44:06 PM (15 years ago)
- Location:
- anuga_validation/automated_validation_tests/patong_beach_validation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_validation/automated_validation_tests/patong_beach_validation/compare_model_timeseries.py
r7649 r7651 17 17 import numpy as num 18 18 import sys, os 19 20 try: 21 import pylab 22 pylab.hold(False) # Check if this command can be issued 23 except: 24 print 'Could not import pylab' 25 plotting = False 26 else: 27 # Create plots as png files 28 plotting = True 29 30 19 31 20 32 # Model specific data … … 27 39 'g11c': [422689.1, 872859.8], 28 40 'g11d': [422408.7, 871940.3], 29 'g11e': [421751.7, 871097.8],30 41 'north': [422572.4, 873992.6], 31 42 'south': [422004.4, 872014.4]} … … 86 97 assert timeseries2.shape[0] == N 87 98 99 print 'Testing gauge "%s"' % name 88 100 print 'epsilon', eps 89 101 # Covariance measure … … 124 136 max1 = max(timeseries1) 125 137 max2 = max(timeseries2) 126 print 'Max diff', abs(max1-max2) 138 res = abs(max1-max2) 139 print 'Max diff', res 140 msg = '%s: Difference between maxima was too large: %e' % (name, res) 141 assert res < eps, msg 127 142 128 143 min1 = min(timeseries1) 129 144 min2 = min(timeseries2) 130 print 'Min diff', abs(min1-min2) 145 res = abs(min1-min2) 146 print 'Min diff', res 147 msg = '%s: Difference between minima was too large: %e' % (name, res) 148 assert res < eps, msg 149 131 150 132 151 # Locations of extrema … … 134 153 i2 = num.argmax(timeseries2) 135 154 136 res = abs( reference_time[i1]-reference_time[i2])155 res = abs(timevector[i1]-timevector[i2]) 137 156 print 'Max loc diff', res 138 157 msg = '%s: Difference between location of maxima was too large: %e' % (name, res) 158 assert res < eps, msg 139 159 140 160 i1 = num.argmin(timeseries1) 141 161 i2 = num.argmin(timeseries2) 142 162 143 res = abs( reference_time[i1]-reference_time[i2])163 res = abs(timevector[i1]-timevector[i2]) 144 164 print 'Min loc diff', res 145 146 147 148 # Generate plots 149 pylab.ion() # No plotting on screen 150 pylab.hold(False) 151 152 pylab.plot(timevector, timeseries1, 'r-', 153 timevector, timeseries2, 'k-') 154 155 pylab.title('Gauge %s' % name) 156 pylab.xlabel('time(s)') 157 pylab.ylabel('stage (m)') 158 pylab.legend(legend, shadow=True, loc='upper left') 159 pylab.savefig(name, dpi = 300) 160 161 # Error vector 162 pylab.ion() # No plotting on screen 163 pylab.hold(False) 164 pylab.plot(timevector, timeseries1-timeseries2, 'b-') 165 pylab.title('Gauge %s (difference)' % name) 166 pylab.xlabel('time(s)') 167 pylab.ylabel('stage difference (m)') 168 pylab.savefig(name + '_diff', dpi = 300) 169 165 msg = '%s: Difference between location of minima was too large: %e' % (name, res) 166 assert res < eps, msg 167 168 169 if plotting: 170 # Generate plots 171 #pylab.ion() # No plotting on screen 172 pylab.hold(False) 173 174 pylab.plot(timevector, timeseries1, 'r-', 175 timevector, timeseries2, 'k-') 176 177 pylab.title('Gauge %s' % name) 178 pylab.xlabel('time(s)') 179 pylab.ylabel('stage (m)') 180 pylab.legend(legend, shadow=True, loc='upper left') 181 pylab.savefig(name, dpi = 300) 182 183 # Error vector 184 #pylab.ion() # No plotting on screen 185 pylab.hold(False) 186 pylab.plot(timevector, timeseries1-timeseries2, 'b-') 187 pylab.title('Gauge %s (difference)' % name) 188 pylab.xlabel('time(s)') 189 pylab.ylabel('stage difference (m)') 190 pylab.savefig(name + '_diff', dpi = 300) 191 192 193 print 'Gauge "%s" OK' % name 194 print 170 195 171 196 … … 199 224 200 225 201 print ' OK'226 print 'All gauges OK' 202 227 203 228 … … 207 232 if len(sys.argv) != 4: 208 233 usage() 209 import sys;sys.exit(-1)234 sys.exit(-1) 210 235 211 236 eps = float(sys.argv[3]) # Get tolerance to be used in comparisons 212 try: 213 res = compare_all_timeseries(sys.argv[1], sys.argv[2], eps=eps) 214 except: 215 sys.exit(-1) 216 else: 217 sys.exit(0) 237 res = compare_all_timeseries(sys.argv[1], sys.argv[2], eps=eps) 238 239 #try: 240 # res = compare_all_timeseries(sys.argv[1], sys.argv[2], eps=eps) 241 #except: 242 # print 'Failed' 243 # sys.exit(-1) 244 #else: 245 # print 'Good', res 246 # sys.exit(0) -
anuga_validation/automated_validation_tests/patong_beach_validation/project.py
r7645 r7651 36 36 37 37 use_buildings = True 38 setup = ' basic' # This can be one of three values38 setup = 'trial' # This can be one of three values 39 39 # trial - coarsest mesh, fast 40 40 # basic - coarse mesh -
anuga_validation/automated_validation_tests/patong_beach_validation/validate.py
r7650 r7651 53 53 'patong.sww.FINAL.tgz' 54 54 ) 55 #Optional_Data_Objects = ('patong.sww.TRIAL.tgz' )55 #Optional_Data_Objects = ('patong.sww.TRIAL.tgz',) 56 56 57 57 # Associated tolerances to be used in comparisons (would depend on discretisation errors) … … 364 364 log.debug("check_that_output_is_as_expected: res=%d" % res) 365 365 log.critical() 366 print 'Result', res 366 367 if res == 0: 367 368 log.info('Simulation results are as expected.') … … 395 396 log.log_logging_level = log.DEBUG 396 397 397 log.debug( "Machine we are running on is '%s'"% get_host_name())398 log.debug('Machine we are running on is "%s"' % get_host_name()) 398 399 setup() 399 400 400 401 # prepare user for what is about to happen 401 402 log.critical(''' 402 Please note that this validation test is accurate only on 64bit Linux or403 Windows. Running the validation on a 32bit operating system will result in404 small differences in the generated mesh which defeats the simplistic test for405 equality between the generated and expected SWW files.406 407 403 This validation requires a working internet connection to refresh its files. 408 404 You may still run this validation without an internet connection if you have the … … 451 447 vtype = vtype.lower() 452 448 log.critical('#' * 72) 453 log.critical( "Running Patong '%s' validation ..."% vtype)449 log.critical('Running Patong "%s" validation ...' % vtype) 454 450 if run_simulation(vtype, odo): 455 451 # get SWW names expected and valid, check 'equal' … … 459 455 460 456 stop_time = time.time() 461 log.critical( "'%s' validation took %.1fs\n\n\n"% (vtype, stop_time - start_time))457 log.critical('"%s" validation took %.1fs\n\n\n' % (vtype, stop_time - start_time)) 462 458 463 459 # clean up
Note: See TracChangeset
for help on using the changeset viewer.