Changeset 7651


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

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  
    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)
  • anuga_validation/automated_validation_tests/patong_beach_validation/project.py

    r7645 r7651  
    3636
    3737use_buildings = True
    38 setup = 'basic'         # This can be one of three values
     38setup = 'trial'         # This can be one of three values
    3939                        #    trial - coarsest mesh, fast
    4040                        #    basic - coarse mesh
  • anuga_validation/automated_validation_tests/patong_beach_validation/validate.py

    r7650 r7651  
    5353                         'patong.sww.FINAL.tgz'
    5454                        )
    55 #Optional_Data_Objects = ('patong.sww.TRIAL.tgz')
     55#Optional_Data_Objects = ('patong.sww.TRIAL.tgz',)
    5656
    5757# Associated tolerances to be used in comparisons (would depend on discretisation errors)
     
    364364    log.debug("check_that_output_is_as_expected: res=%d" % res)
    365365    log.critical()
     366    print 'Result', res
    366367    if res == 0:
    367368        log.info('Simulation results are as expected.')
     
    395396log.log_logging_level = log.DEBUG
    396397
    397 log.debug("Machine we are running on is '%s'" % get_host_name())
     398log.debug('Machine we are running on is "%s"' % get_host_name())
    398399setup()
    399400
    400401# prepare user for what is about to happen
    401402log.critical('''
    402 Please note that this validation test is accurate only on 64bit Linux or
    403 Windows.  Running the validation on a 32bit operating system will result in
    404 small differences in the generated mesh which defeats the simplistic test for
    405 equality between the generated and expected SWW files.
    406 
    407403This validation requires a working internet connection to refresh its files.
    408404You may still run this validation without an internet connection if you have the
     
    451447    vtype = vtype.lower()
    452448    log.critical('#' * 72)
    453     log.critical("Running Patong '%s' validation ..." % vtype)
     449    log.critical('Running Patong "%s" validation ...' % vtype)
    454450    if run_simulation(vtype, odo):
    455451        # get SWW names expected and valid, check 'equal'
     
    459455
    460456    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))
    462458
    463459# clean up
Note: See TracChangeset for help on using the changeset viewer.