Changeset 4339
- Timestamp:
- Mar 29, 2007, 5:00:45 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_validation/automated_validation_tests/okushiri_tank_validation/compare_timeseries_with_measures.py
r4337 r4339 107 107 validation_data[key] = ensure_numeric(validation_data[key]) 108 108 109 110 109 #-------------------------------------------------- 111 110 # Read and interpolate model output … … 125 124 126 125 127 def report_difference(name, computed_value, reference_value, eps): 128 129 # print '%s = %.18e' %(name, computed_value) 130 131 #if computed_value < reference_value-eps: 132 # print ' Result is better than expected by: %.18e'\ 133 # %(computed_value - reference_value) 134 # print ' Expect = %.18e' %reference_value 135 #elif computed_value > reference_value+eps: 136 # print ' FAIL: Result is worse than expected by: %.18e'\ 137 # %(computed_value-reference_value) 138 # print ' Expect = %.18e' %reference_value 139 #else: 140 # pass 126 def report_difference(name, computed_value, reference_value, rtol, atol): 141 127 142 128 if abs(reference_value) > 0: … … 144 130 %(name, reference_value, computed_value, 145 131 abs(reference_value-computed_value)/reference_value) 146 else: 147 msg = '%s (expected, computed):\n (%.18e, %.18e):\n Absolute error=%.18e'\ 148 %(name, reference_value, computed_value, 149 abs(reference_value-computed_value)) 150 #print msg 151 #print 'Allclose:', allclose(reference_value, computed_value, rtol=eps) 152 assert allclose(reference_value, computed_value, rtol=eps), msg 132 print msg 133 134 135 msg = ' Absolute error=%.18e'\ 136 %(abs(reference_value-computed_value)) 137 print msg 138 139 140 #print 'Allclose:', allclose(reference_value, computed_value, 141 # rtol=rtol, atol=atol) 142 assert allclose(reference_value, computed_value, rtol=rtol, atol=atol), msg 153 143 154 144 … … 158 148 #-------------------------------------------------- 159 149 160 eps = get_machine_precision() 161 print 'Machine precision: ', eps 150 151 #eps = get_machine_precision() 152 153 # Windows tolerances 154 rtol = 1.0e-2 155 atol = 1.0e-3 156 print 'Precisions used: rtol=%e, atol=%e' %(rtol, atol) 157 162 158 for k, name in enumerate(gauge_names): 159 163 160 sqsum = 0 164 161 denom = 0 … … 172 169 # Covariance measure 173 170 res = cov(observed_timeseries, model) 174 report_difference('Covariance', res, expected_covariance[name], eps)171 report_difference('Covariance', res, expected_covariance[name], rtol, atol) 175 172 176 173 # Difference measures 177 174 res = sum(abs(observed_timeseries-model))/len(model) 178 175 report_difference('Accumulated difference', res, 179 expected_difference[name], eps)176 expected_difference[name], rtol, atol) 180 177 181 178 # Extrema 182 179 res = max(model) 183 report_difference('Maximum', res, expected_maximum[name], eps)180 report_difference('Maximum', res, expected_maximum[name], rtol, atol) 184 181 185 182 res = min(model) 186 report_difference('Minimum', res, expected_minimum[name], eps)183 report_difference('Minimum', res, expected_minimum[name], rtol, atol) 187 184 188 185 # Locations of extrema … … 190 187 i1 = argmax(model) 191 188 res = reference_time[i1] 192 report_difference('Location of maximum', res, expected_argmax[name], eps) 193 194 195 #i0 = argmin(observed_timeseries) 196 i1 = argmin(model) 197 res = reference_time[i1] 198 report_difference('Location of minimum', res, expected_argmin[name], eps) 189 report_difference('Location of maximum', res, expected_argmax[name], rtol, atol) 190 191 192 if name <> 'ch9': 193 # Minimum of ch9 is very flat and hard to pinpoint 194 i1 = argmin(model) 195 res = reference_time[i1] 196 report_difference('Location of minimum', res, expected_argmin[name], 197 rtol, atol) 199 198 200 199
Note: See TracChangeset
for help on using the changeset viewer.