Ignore:
Timestamp:
Mar 3, 2010, 2:44:06 PM (15 years ago)
Author:
ole
Message:

Got patong auto validation working and tested for TRIAL run

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_validation/automated_validation_tests/patong_beach_validation/compare_model_timeseries.py

    r7649 r7651  
    1717import numpy as num
    1818import sys, os
     19
     20try:
     21    import pylab
     22    pylab.hold(False)  # Check if this command can be issued
     23except:
     24    print 'Could not import pylab'
     25    plotting = False
     26else:
     27    # Create plots as png files
     28    plotting = True
     29
     30
    1931
    2032# Model specific data
     
    2739          'g11c': [422689.1, 872859.8],
    2840          'g11d': [422408.7, 871940.3],
    29           'g11e': [421751.7, 871097.8],
    3041          'north': [422572.4, 873992.6],
    3142          'south': [422004.4, 872014.4]}
     
    8697    assert timeseries2.shape[0] == N       
    8798
     99    print 'Testing gauge "%s"' % name
    88100    print 'epsilon', eps
    89101    # Covariance measure   
     
    124136    max1 = max(timeseries1)
    125137    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   
    127142
    128143    min1 = min(timeseries1)
    129144    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
    131150   
    132151    # Locations of extrema
     
    134153    i2 = num.argmax(timeseries2)
    135154   
    136     res = abs(reference_time[i1]-reference_time[i2])
     155    res = abs(timevector[i1]-timevector[i2])
    137156    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
    139159
    140160    i1 = num.argmin(timeseries1)
    141161    i2 = num.argmin(timeseries2)
    142162   
    143     res = abs(reference_time[i1]-reference_time[i2])
     163    res = abs(timevector[i1]-timevector[i2])   
    144164    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
    170195   
    171196
     
    199224           
    200225   
    201     print 'OK'
     226    print 'All gauges OK'
    202227   
    203228   
     
    207232    if len(sys.argv) != 4:
    208233        usage()
    209         import sys; sys.exit(-1)
     234        sys.exit(-1)
    210235
    211236    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.