 Timestamp:
 Mar 2, 2010, 5:19:13 PM (13 years ago)
 Location:
 anuga_validation/automated_validation_tests/patong_beach_validation
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

anuga_validation/automated_validation_tests/patong_beach_validation/compare_model_timeseries.py
r7645 r7649 36 36 def usage(): 37 37 print 'Usage:' 38 print 'python compare_model_timeseries.py swwfile1 swwfile2 '38 print 'python compare_model_timeseries.py swwfile1 swwfile2 epsilon' 39 39 40 40 … … 74 74 timeseries2, 75 75 name='', 76 legend = ('Time series 1', 'Time series 2')): 76 legend = ('Time series 1', 'Time series 2'), 77 eps=1.0e6): 77 78 """Compare and plot two timeseries 78 79 """ … … 84 85 assert timeseries1.shape[0] == N 85 86 assert timeseries2.shape[0] == N 86 87 eps = 1.0e3 88 87 88 print 'epsilon', eps 89 89 # Covariance measure 90 #res = cov(timeseries1, timeseries2) 91 #msg = 'Covariance between timeseries was too large: %e' % res 92 #assert res < 0.01, msg 90 res = cov(timeseries1timeseries2) 91 print '2 norm diff', res 92 msg = '2norm of timeseries difference was too large: %e' % res 93 assert res < eps, msg 93 94 94 # Difference measures95 print timeseries196 print timeseries1timeseries297 98 99 95 # Maximum norm 100 96 nominator = max(abs(timeseries1timeseries2)) 101 97 denominator = max(abs(timeseries1)) 102 print nominator, denominator, N103 98 if denominator > 0: 104 99 # Relative measure … … 107 102 # Absolute measure 108 103 res = nominator/N 109 104 105 print 'Max abs diff', res 110 106 msg = '%s: Difference between timeseries was too large: %e' % (name, res) 111 #assert res < eps, msg107 assert res < eps, msg 112 108 113 109 114 110 nominator = sum(abs(timeseries1timeseries2)) 115 111 denominator = sum(abs(timeseries1)) 116 print nominator, denominator, N117 112 if denominator > 0: 118 113 # Relative measure … … 121 116 # Absolute measure 122 117 res = nominator/N 123 118 119 print 'Sum abs diff', res 124 120 msg = '%s: Difference between timeseries was too large: %e' % (name, res) 125 #assert res < eps, msg121 assert res < eps, msg 126 122 127 123 # Extrema 128 #res = max(model) 129 #report_difference('Maximum', res, expected_maximum[name], rtol, atol) 124 max1 = max(timeseries1) 125 max2 = max(timeseries2) 126 print 'Max diff', abs(max1max2) 127 128 min1 = min(timeseries1) 129 min2 = min(timeseries2) 130 print 'Min diff', abs(min1min2) 131 132 # Locations of extrema 133 i1 = num.argmax(timeseries1) 134 i2 = num.argmax(timeseries2) 135 136 res = abs(reference_time[i1]reference_time[i2]) 137 print 'Max loc diff', res 138 139 140 i1 = num.argmin(timeseries1) 141 i2 = num.argmin(timeseries2) 142 143 res = abs(reference_time[i1]reference_time[i2]) 144 print 'Min loc diff', res 130 145 131 146 … … 155 170 156 171 157 def compare_all_timeseries(swwfile1, swwfile2 ):172 def compare_all_timeseries(swwfile1, swwfile2, eps=1.0e6): 158 173 159 174 timevector1, timeseries1 = get_timeseries(swwfile1, gauges) … … 177 192 timeseries1[name], 178 193 timeseries2[name], 179 name=name) 194 name=name, 195 eps=eps) 180 196 181 197 … … 189 205 if __name__ == '__main__': 190 206 191 if len(sys.argv) != 3:207 if len(sys.argv) != 4: 192 208 usage() 193 209 import sys; sys.exit(1) 194 210 195 #res = compare_all_timeseries(sys.argv[1], sys.argv[2])211 eps = float(sys.argv[3]) # Get tolerance to be used in comparisons 196 212 try: 197 res = compare_all_timeseries(sys.argv[1], sys.argv[2] )213 res = compare_all_timeseries(sys.argv[1], sys.argv[2], eps=eps) 198 214 except: 199 215 sys.exit(1) 
anuga_validation/automated_validation_tests/patong_beach_validation/validate.py
r7645 r7649 53 53 'patong.sww.FINAL.tgz' 54 54 ) 55 Optional_Data_Objects = ('patong.sww.BASIC.tgz',) 55 Optional_Data_Objects = ('patong.sww.TRIAL.tgz',) 56 57 # Associated tolerances to be used in comparisons (would depend on discretisation errors) 58 epsilon = {'patong.sww.TRIAL.tgz': 1.0e3, 59 'patong.sww.BASIC.tgz': 1.0e4, 60 'patong.sww.FINAL.tgz': 1.0e5} 61 56 62 57 63 # path to the local data directory … … 314 320 return res == 0 315 321 316 def check_that_output_is_as_expected(expected_sww, valid_sww ):322 def check_that_output_is_as_expected(expected_sww, valid_sww, epsilon): 317 323 '''Check that validation output is as required.''' 318 324 … … 348 354 new_output_sww = os.path.join(output_directory, expected_sww) 349 355 #cmd = 'python cmpsww.py %s %s > cmpsww.stdout' % (local_sww, new_output_sww) 350 cmd = 'python compare_model_timeseries.py %s %s > compare_model_timeseries.stdout' % (local_sww, new_output_sww) 356 cmd = 'python compare_model_timeseries.py %s %s %e > compare_model_timeseries.stdout' %\ 357 (local_sww, new_output_sww, epsilon) 351 358 print '' 352 359 print cmd … … 449 456 (valid_sww, _) = odo.rsplit('.', 1) 450 457 (expected_sww, _) = valid_sww.rsplit('.', 1) 451 check_that_output_is_as_expected(expected_sww, valid_sww )458 check_that_output_is_as_expected(expected_sww, valid_sww, epsilon[odo]) 452 459 453 460 stop_time = time.time()
Note: See TracChangeset
for help on using the changeset viewer.