Changeset 4417


Ignore:
Timestamp:
Apr 24, 2007, 10:00:17 AM (17 years ago)
Author:
nick
Message:

clean up and comment validation

Location:
anuga_validation/automated_validation_tests/urs_mux_files_validation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_validation/automated_validation_tests/urs_mux_files_validation/run_Bf.py

    r4410 r4417  
    1717from shutil import copy
    1818import time, sys, os, tempfile
    19 #import sys
    20 #import os
    21 #import tempfile
    2219
    2320# Related major packages
    2421from anuga.shallow_water import Domain,Dirichlet_boundary,File_boundary,Transmissive_boundary, Field_boundary
    25 #from anuga.shallow_water.shallow_water_domain import Field_boundary
    2622from Numeric import allclose, array
    2723from anuga.pmesh.mesh_interface import create_mesh_from_regions
    2824from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files, sww2timeseries, get_data_from_file
    29 #from anuga.caching import myhash
    3025# Application specific imports
    3126
     
    3530#------------------------------------------------------------------------------
    3631out_dir = dirname(abspath(__file__))+sep
    37 #print'temp_name'
    3832fileName="temp"
    39 #import sys
    40 #sys.exit()
     33
    4134meshes_dir_name = 'small.tsh' # this will be local
    4235
    4336tide = 2.4
    44 
    45 
    46 #EVOLVED MODEL
    4737
    4838#--------------------------------------------------------------------------
     
    5343#--------------------------------------------------------------------------
    5444
    55 #all = [[469000,7760000],[470000,7758000],[468000,7758000]]
    56 #all = [[470000,7760000],[469000,7758000],[468000,7760000]]
    57 
    58 #all_large = [[474000,7764000],[474000,7756000],[466000,7756000],[466000,7764000]]
    59 #all = [[470000,7764000],[470000,7756000],[466000,7756000],[466000,7764000]]
    6045all = [[465184,7764500],[470397,7764510],[470407,7758988],[465195,7758979]]
    6146# N, W, S, E
    6247
    6348create_mesh_from_regions(all,
    64 #                             boundary_tags={'ocean': [0,1,2]},
    65 #                             boundary_tags={'ocean': [ 2],'side': [0, 1]},
    6649                             boundary_tags={'ocean': [ 0],'side': [1, 3], 'back': [2]},
    6750                             maximum_triangle_area=50000,
    6851                             filename=meshes_dir_name,
    6952                             use_cache=False,
    70 #                             verbose=True
    7153                             )
    7254
     
    124106#----------------------------------------------------------------------------
    125107
    126 #remove mesh file!!! and o_test.sww
    127108t0 = time.time()
    128109
     
    132113
    133114
    134 
     115#----------------------------------------------------------------------------
    135116#Gets timeseries from boundary sww and evolved sww
     117#----------------------------------------------------------------------------
    136118home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
    137119data = 'data'
     
    164146swwfile = out_dir + fileName + '.sww'
    165147swwfiles[swwfile] = run_time
    166        
     148#----------------------------------------------------------------------------
     149#get timeseries data from evolved sww file       
     150#----------------------------------------------------------------------------
    167151texname, elev_output = sww2timeseries(swwfiles,
    168152                                      out_dir+sep+"gauges.txt",
     
    182166swwfiles[swwfile] = run_time
    183167#print"swwfiles",swwfiles,"shallow_water"
    184        
     168
     169#----------------------------------------------------------------------------
     170#get timeseries data from boundary sww file       
     171#----------------------------------------------------------------------------
    185172texname, elev_output = sww2timeseries(swwfiles,
    186173                                      out_dir+sep+"boundary_gauges.txt",
     
    196183                                      verbose = False)
    197184
    198 #makes the csv files from the evolved model
     185#----------------------------------------------------------------------------
     186# get_data_from file returns a e_data which is an array containing the data from the
     187# file it read
     188#----------------------------------------------------------------------------
    199189e_header, e_data = get_data_from_file(evolved_dir_filename)
    200190
     191# assign columns from array to single vector(arrays)
    201192e_time = e_data[:,0]
    202193e_stage = e_data[:,1]
     
    205196e_elevation = e_data[:,4]
    206197
    207 #print'boundary_dir_filename',boundary_dir_filename
     198#----------------------------------------------------------------------------
     199#get_data_from file returns a b_data which is an array containing the data from the
     200# file it read
     201#----------------------------------------------------------------------------
    208202b_header, b_data = get_data_from_file(boundary_dir_filename)
    209203
     204# assign columns from array to single vector(arrays)
    210205b_time = b_data[:,0]
    211206b_stage = b_data[:,1]
     
    214209b_elevation = b_data[:,4]
    215210
    216 
    217 # compares the 2 models
     211#----------------------------------------------------------------------------
     212# compares the 2 models, make the vector of data from the boundary sww file have the same
     213# time interval as the evolved sww vector. this allows them to be compared with the allclose
     214# statment at the end
     215#----------------------------------------------------------------------------
    218216j=0
    219217k=0
     218#from boundary sww
    220219b_sample = []
     220#from evolved sww
    221221e_sample = []
    222222for i in range(len(b_time)):
     
    230230
    231231
    232 #print len(b_sample), len(e_stage),e_stage,type(e_stage)
    233232e_stage = e_stage.tolist()
    234233e_stage.pop()
    235 #e_stage.pop()
    236  
    237 #print len(b_sample), len(e_stage),e_stage
    238 
    239 
    240 #assert allclose (b_sample, e_stage, 0.2, 0.2)
     234
     235
    241236print "test successful"
    242237print 'fileName',fileName+'.sww'
    243 #os.remove(fileName+'.sww')
    244 #print 'evolved_dir_filename',evolved_dir_filename
    245 #os.remove('gauges_time_series_near_top.csv')
    246 #os.remove('gauges_time_series_b_near_top.csv')
    247 #os.remove('gauges_t0.csv')
    248 #os.remove('gauges_maxmins.csv')
    249238os.remove(meshes_dir_name)
    250 
    251 
     239#----------------------------------------------------------------------------
     240# Compares the two time series
     241#----------------------------------------------------------------------------
    252242assert allclose (b_sample, e_sample, 0.5, 0.5)
    253243
  • anuga_validation/automated_validation_tests/urs_mux_files_validation/validate_Bf.py

    r4410 r4417  
    1111
    1212class Test_Bf(unittest.TestCase):
    13     def test_setUp(self):
     13    def setUp(self):
    1414
    1515        # Remove garbage
     
    2424
    2525    def test_compare_URSsww_vs_EvolveANUGAsww(self):   
     26       
     27        self.setUp()
     28       
    2629        s = 'run_Bf.py'
    2730        #print s
     
    3033        assert res == 0
    3134       
    32     def test_cleanUp(self):
     35        self.cleanUp()
     36       
     37    def cleanUp(self):
    3338
    3439        # Remove garbage
Note: See TracChangeset for help on using the changeset viewer.