Changeset 7651 for anuga_validation/automated_validation_tests/patong_beach_validation/compare_model_timeseries.py
- Timestamp:
- Mar 3, 2010, 2:44:06 PM (15 years ago)
- File:
-
- 1 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)
Note: See TracChangeset
for help on using the changeset viewer.