Ignore:
Timestamp:
Apr 24, 2009, 5:22:14 PM (15 years ago)
Author:
rwilson
Message:

Back-merge from Numeric trunk to numpy branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/shallow_water/test_data_manager.py

    r6689 r6902  
    1515from struct import pack, unpack
    1616from sets import ImmutableSet
     17import shutil
    1718
    1819from anuga.shallow_water import *
     
    4748       
    4849        self.verbose = Test_Data_Manager.verbose
    49         #Create basic mesh
     50        # Create basic mesh
    5051        points, vertices, boundary = rectangular(2, 2)
    5152
    52         #Create shallow water domain
     53        # Create shallow water domain
    5354        domain = Domain(points, vertices, boundary)
    5455        domain.default_order = 2
    5556
    56         #Set some field values
     57        # Set some field values
    5758        domain.set_quantity('elevation', lambda x,y: -x)
    5859        domain.set_quantity('friction', 0.03)
     
    252253
    253254        # Get the variables
    254         #range = fid.variables['stage_range'][:]
     255        range = fid.variables['stage_range'][:]
    255256        #print range
    256         #assert num.allclose(range,[-0.93519, 0.15]) or\
    257         #       num.allclose(range,[-0.9352743, 0.15]) or\
    258         #       num.allclose(range,[-0.93522203, 0.15000001]) # Old slope limiters
    259        
    260         #range = fid.variables['xmomentum_range'][:]
     257        assert num.allclose(range,[-0.93519, 0.15]) or\
     258               num.allclose(range,[-0.9352743, 0.15]) or\
     259               num.allclose(range,[-0.93522203, 0.15000001]) # Old slope limiters
     260       
     261        range = fid.variables['xmomentum_range'][:]
    261262        ##print range
    262         #assert num.allclose(range,[0,0.4695096]) or \
    263         #       num.allclose(range,[0,0.47790655]) or\
    264         #       num.allclose(range,[0,0.46941957]) or\
    265         #       num.allclose(range,[0,0.47769409])
    266 
    267        
    268         #range = fid.variables['ymomentum_range'][:]
     263        assert num.allclose(range,[0,0.4695096]) or \
     264               num.allclose(range,[0,0.47790655]) or\
     265               num.allclose(range,[0,0.46941957]) or\
     266               num.allclose(range,[0,0.47769409])
     267
     268       
     269        range = fid.variables['ymomentum_range'][:]
    269270        ##print range
    270         #assert num.allclose(range,[0,0.02174380]) or\
    271         #       num.allclose(range,[0,0.02174439]) or\
    272         #       num.allclose(range,[0,0.02283983]) or\
    273         #       num.allclose(range,[0,0.0217342]) or\
    274         #       num.allclose(range,[0,0.0227564]) # Old slope limiters
     271        assert num.allclose(range,[0,0.02174380]) or\
     272               num.allclose(range,[0,0.02174439]) or\
     273               num.allclose(range,[0,0.02283983]) or\
     274               num.allclose(range,[0,0.0217342]) or\
     275               num.allclose(range,[0,0.0227564]) # Old slope limiters
    275276       
    276277        fid.close()
     
    12321233        from Scientific.IO.NetCDF import NetCDFFile
    12331234
    1234         #Setup
     1235        # Setup
    12351236        self.domain.set_name('datatest')
    12361237
     
    12451246        self.domain.set_quantity('stage', 1.0)
    12461247
    1247         self.domain.geo_reference = Geo_reference(56,308500,6189000)
     1248        self.domain.geo_reference = Geo_reference(56, 308500, 6189000)
    12481249
    12491250        sww = get_dataobject(self.domain)
     
    55635564            quantities_init[0].append(this_ha) # HA
    55645565            quantities_init[1].append(this_ua) # UA
    5565             quantities_init[2].append(this_va) # VA
     5566            quantities_init[2].append(this_va) # VA 
    55665567               
    55675568        file_handle, base_name = tempfile.mkstemp("")
     
    61046105                        #print 'writing', time, point_i, q_time[time, point_i]
    61056106                        f.write(pack('f', q_time[time, point_i]))
    6106 
    61076107            f.close()
    61086108
     
    62156215
    62166216        msg='Incorrect gauge depths returned'
    6217         assert num.allclose(elevation,-depth),msg
     6217        assert num.allclose(elevation, -depth),msg
    62186218        msg='incorrect gauge height time series returned'
    6219         assert num.allclose(stage,ha)
     6219        assert num.allclose(stage, ha)
    62206220        msg='incorrect gauge ua time series returned'
    6221         assert num.allclose(xvelocity,ua)
     6221        assert num.allclose(xvelocity, ua)
    62226222        msg='incorrect gauge va time series returned'
    62236223        assert num.allclose(yvelocity, -va) # South is positive in MUX
     
    63976397                if j == 2: assert num.allclose(data[i][:parameters_index], -va0[permutation[i], :])
    63986398       
     6399        self.delete_mux(filesI)
    63996400
    64006401
     
    64076408        wrong values Win32
    64086409
    6409         This test does not pass on Windows but test_read_mux_platform_problem1 does
     6410        This test does not pass on Windows but test_read_mux_platform_problem1
     6411        does
    64106412        """
    64116413       
     
    64226424        times_ref = num.arange(0, time_step_count*time_step, time_step)
    64236425       
    6424         lat_long_points = [(-21.5,114.5), (-21,114.5), (-21.5,115), (-21.,115.), (-22., 117.)]
     6426        lat_long_points = [(-21.5,114.5), (-21,114.5), (-21.5,115),
     6427                           (-21.,115.), (-22., 117.)]
    64256428        n = len(lat_long_points)
    64266429       
     
    64666469             for j in range(0, first_tstep[i]-1) + range(last_tstep[i], time_step_count):
    64676470                 # For timesteps before and after recording range
    6468                  ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0                                  
     6471                 ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0
    64696472
    64706473
     
    64746477        #print 'va', va1[0,:]
    64756478       
    6476         # Write second mux file to be combined by urs2sts                                            
     6479        # Write second mux file to be combined by urs2sts
    64776480        base_nameII, filesII = self.write_mux2(lat_long_points,
    64786481                                               time_step_count, time_step,
     
    66056608
    66066609            f.close()
    6607 
    6608 
    6609 
    6610 
    6611 
    6612 
    6613        
    66146610                                               
    66156611        # Create ordering file
    66166612        permutation = ensure_numeric([4,0,2])
    66176613
    6618         _, ordering_filename = tempfile.mkstemp('')
    6619         order_fid = open(ordering_filename, 'w') 
    6620         order_fid.write('index, longitude, latitude\n')
    6621         for index in permutation:
    6622             order_fid.write('%d, %f, %f\n' %(index,
    6623                                              lat_long_points[index][1],
    6624                                              lat_long_points[index][0]))
    6625         order_fid.close()
    6626        
    6627        
    6628 
     6614       #  _, ordering_filename = tempfile.mkstemp('')
     6615#         order_fid = open(ordering_filename, 'w') 
     6616#         order_fid.write('index, longitude, latitude\n')
     6617#         for index in permutation:
     6618#             order_fid.write('%d, %f, %f\n' %(index,
     6619#                                              lat_long_points[index][1],
     6620#                                              lat_long_points[index][0]))
     6621#         order_fid.close()
     6622       
    66296623        # -------------------------------------
    66306624        # Now read files back and check values
     
    66386632        for j, file in enumerate(filesII):
    66396633            # Read stage, u, v enumerated as j
    6640 
    6641            
    66426634            #print 'Reading', j, file
    66436635            data = read_mux2(1, [file], weights, file_params, permutation, verbose)
     
    66456637            #print 'Data received by Python'
    66466638            #print data[1][8]
    6647 
    6648            
    66496639            number_of_selected_stations = data.shape[0]
    66506640
     
    66596649                #print i, parameters_index
    66606650                #print quantity[i][:]
    6661 
    6662                
    66636651                if j == 0: assert num.allclose(data[i][:parameters_index], ha1[permutation[i], :])
    66646652                if j == 1: assert num.allclose(data[i][:parameters_index], ua1[permutation[i], :])
     
    66696657                    #print j, i
    66706658                    #print 'Input'
    6671                     #print 'u', ua1[permutation[i], 8]                                        
     6659                    #print 'u', ua1[permutation[i], 8]       
    66726660                    #print 'v', va1[permutation[i], 8]
    66736661               
    66746662                    #print 'Output'
    6675                     #print 'v ', data[i][:parameters_index][8]                   
     6663                    #print 'v ', data[i][:parameters_index][8] 
     6664
     6665                    # South is positive in MUX
     6666                    #print "data[i][:parameters_index]", data[i][:parameters_index]
     6667                    #print "-va1[permutation[i], :]", -va1[permutation[i], :]
     6668                    assert num.allclose(data[i][:parameters_index], -va1[permutation[i], :])
     6669       
     6670        self.delete_mux(filesII)
     6671           
     6672    def test_read_mux_platform_problem3(self):
     6673       
     6674        # This is to test a situation where read_mux returned
     6675        # wrong values Win32
     6676
     6677       
     6678        from urs_ext import read_mux2
     6679       
     6680        from anuga.config import single_precision as epsilon       
     6681       
     6682        verbose = False
    66766683               
    6677                     # South is positive in MUX
     6684        tide = 1.5
     6685        time_step_count = 10
     6686        time_step = 0.02
     6687
     6688        '''
     6689        Win results
     6690        time_step = 0.2000001
     6691        This is OK       
     6692        '''
     6693       
     6694        '''
     6695        Win results
     6696        time_step = 0.20000001
     6697
     6698        ======================================================================
     6699ERROR: test_read_mux_platform_problem3 (__main__.Test_Data_Manager)
     6700----------------------------------------------------------------------
     6701Traceback (most recent call last):
     6702  File "test_data_manager.py", line 6718, in test_read_mux_platform_problem3
     6703    ha1[0]=num.sin(times_ref)
     6704ValueError: matrices are not aligned for copy
     6705
     6706        '''
     6707
     6708        '''
     6709        Win results
     6710        time_step = 0.200000001
     6711        FAIL
     6712         assert num.allclose(data[i][:parameters_index],
     6713         -va1[permutation[i], :])
     6714        '''
     6715        times_ref = num.arange(0, time_step_count*time_step, time_step)
     6716        #print "times_ref", times_ref
     6717       
     6718        lat_long_points = [(-21.5,114.5), (-21,114.5), (-21.5,115),
     6719                           (-21.,115.), (-22., 117.)]
     6720        stations = len(lat_long_points)
     6721       
     6722        # Create different timeseries starting and ending at different times
     6723        first_tstep=num.ones(stations, num.int)
     6724        first_tstep[0]+=2   # Point 0 starts at 2
     6725        first_tstep[1]+=4   # Point 1 starts at 4       
     6726        first_tstep[2]+=3   # Point 2 starts at 3
     6727       
     6728        last_tstep=(time_step_count)*num.ones(stations, num.int)
     6729        last_tstep[0]-=1    # Point 0 ends 1 step early
     6730        last_tstep[1]-=2    # Point 1 ends 2 steps early               
     6731        last_tstep[4]-=3    # Point 4 ends 3 steps early       
     6732       
     6733        # Create varying elevation data (positive values for seafloor)
     6734        gauge_depth=20*num.ones(stations, num.float)
     6735        for i in range(stations):
     6736            gauge_depth[i] += i**2
     6737           
     6738        # Create data to be written to second mux file       
     6739        ha1=num.ones((stations,time_step_count), num.float)
     6740        ha1[0]=num.sin(times_ref)
     6741        ha1[1]=2*num.sin(times_ref - 3)
     6742        ha1[2]=5*num.sin(4*times_ref)
     6743        ha1[3]=num.sin(times_ref)
     6744        ha1[4]=num.sin(2*times_ref-0.7)
     6745               
     6746        ua1=num.zeros((stations,time_step_count),num.float)
     6747        ua1[0]=3*num.cos(times_ref)       
     6748        ua1[1]=2*num.sin(times_ref-0.7)   
     6749        ua1[2]=num.arange(3*time_step_count,4*time_step_count)
     6750        ua1[4]=2*num.ones(time_step_count)
     6751       
     6752        va1=num.zeros((stations,time_step_count),num.float)
     6753        va1[0]=2*num.cos(times_ref-0.87)       
     6754        va1[1]=3*num.ones(time_step_count)
     6755        va1[3]=2*num.sin(times_ref-0.71)       
     6756        #print "va1[0]", va1[0]  # The 8th element is what will go bad.
     6757        # Ensure data used to write mux file to be zero when gauges are
     6758        # not recording
     6759        for i in range(stations):
     6760             # For each point
     6761             for j in range(0, first_tstep[i]-1) + range(last_tstep[i],
     6762                                                         time_step_count):
     6763                 # For timesteps before and after recording range
     6764                 ha1[i][j] = ua1[i][j] = va1[i][j] = 0.0
     6765
     6766
     6767        #print 'Second station to be written to MUX'
     6768        #print 'ha', ha1[0,:]
     6769        #print 'ua', ua1[0,:]
     6770        #print 'va', va1[0,:]
     6771       
     6772        # Write second mux file to be combined by urs2sts
     6773        base_nameII, filesII = self.write_mux2(lat_long_points,
     6774                                               time_step_count, time_step,
     6775                                               first_tstep, last_tstep,
     6776                                               depth=gauge_depth,
     6777                                               ha=ha1,
     6778                                               ua=ua1,
     6779                                               va=va1)
     6780        #print "filesII", filesII
     6781
     6782
     6783
     6784
     6785        # Read mux file back and verify it's correcness
     6786
     6787        ####################################################
     6788        # FIXME (Ole): This is where the test should
     6789        # verify that the MUX files are correct.
     6790
     6791        #JJ: It appears as though
     6792        #that certain quantities are not being stored with enough precision
     6793        #inn muxfile or more likely that they are being cast into a
     6794        #lower precision when read in using read_mux2 Time step and q_time
     6795        # are equal but only to approx 1e-7
     6796        ####################################################
     6797
     6798        #define information as it should be stored in mus2 files
     6799        points_num=len(lat_long_points)
     6800        depth=gauge_depth
     6801        ha=ha1
     6802        ua=ua1
     6803        va=va1
     6804       
     6805        quantities = ['HA','UA','VA']
     6806        mux_names = [WAVEHEIGHT_MUX2_LABEL,
     6807                     EAST_VELOCITY_MUX2_LABEL,
     6808                     NORTH_VELOCITY_MUX2_LABEL]
     6809        quantities_init = [[],[],[]]
     6810        latlondeps = []
     6811        #irrelevant header information
     6812        ig=ilon=ilat=0
     6813        mcolat=mcolon=centerlat=centerlon=offset=az=baz=id=0.0
     6814        # urs binary is latitude fastest
     6815        for i,point in enumerate(lat_long_points):
     6816            lat = point[0]
     6817            lon = point[1]
     6818            _ , e, n = redfearn(lat, lon)
     6819            if depth is None:
     6820                this_depth = n
     6821            else:
     6822                this_depth = depth[i]
     6823            latlondeps.append([lat, lon, this_depth])
     6824
     6825            if ha is None:
     6826                this_ha = e
     6827                quantities_init[0].append(num.ones(time_step_count,
     6828                                                   num.float)*this_ha) # HA
     6829            else:
     6830                quantities_init[0].append(ha[i])
     6831            if ua is None:
     6832                this_ua = n
     6833                quantities_init[1].append(num.ones(time_step_count,
     6834                                                   num.float)*this_ua) # UA
     6835            else:
     6836                quantities_init[1].append(ua[i])
     6837            if va is None:
     6838                this_va = e
     6839                quantities_init[2].append(num.ones(time_step_count,
     6840                                                   num.float)*this_va) #
     6841            else:
     6842                quantities_init[2].append(va[i])
     6843
     6844        for i, q in enumerate(quantities):
     6845            #print
     6846            #print i, q
     6847           
     6848            q_time = num.zeros((time_step_count, points_num), num.float)
     6849            quantities_init[i] = ensure_numeric(quantities_init[i])
     6850            for time in range(time_step_count):
     6851                #print i, q, time, quantities_init[i][:,time]
     6852                q_time[time,:] = quantities_init[i][:,time]
     6853                #print i, q, time, q_time[time, :]
     6854
     6855           
     6856            filename = base_nameII + mux_names[i]
     6857            f = open(filename, 'rb')
     6858            if self.verbose: print 'Reading' + filename
     6859            assert abs(points_num-unpack('i',f.read(4))[0])<epsilon
     6860            #write mux 2 header
     6861            for latlondep in latlondeps:
     6862                assert abs(latlondep[0]-unpack('f',f.read(4))[0])<epsilon
     6863                assert abs(latlondep[1]-unpack('f',f.read(4))[0])<epsilon
     6864                assert abs(mcolat-unpack('f',f.read(4))[0])<epsilon
     6865                assert abs(mcolon-unpack('f',f.read(4))[0])<epsilon
     6866                assert abs(ig-unpack('i',f.read(4))[0])<epsilon
     6867                assert abs(ilon-unpack('i',f.read(4))[0])<epsilon
     6868                assert abs(ilat-unpack('i',f.read(4))[0])<epsilon
     6869                assert abs(latlondep[2]-unpack('f',f.read(4))[0])<epsilon
     6870                assert abs(centerlat-unpack('f',f.read(4))[0])<epsilon
     6871                assert abs(centerlon-unpack('f',f.read(4))[0])<epsilon
     6872                assert abs(offset-unpack('f',f.read(4))[0])<epsilon
     6873                assert abs(az-unpack('f',f.read(4))[0])<epsilon
     6874                assert abs(baz-unpack('f',f.read(4))[0])<epsilon
     6875               
     6876                x = unpack('f', f.read(4))[0]
     6877                #print time_step
     6878                #print x
     6879                assert abs(time_step-x)<epsilon
     6880                assert abs(time_step_count-unpack('i',f.read(4))[0])<epsilon
     6881                for j in range(4): # identifier
     6882                    assert abs(id-unpack('i',f.read(4))[0])<epsilon
     6883
     6884            #first_tstep=1
     6885            #last_tstep=time_step_count
     6886            for i,latlondep in enumerate(latlondeps):
     6887                assert abs(first_tstep[i]-unpack('i',f.read(4))[0])<epsilon
     6888            for i,latlondep in enumerate(latlondeps):
     6889                assert abs(last_tstep[i]-unpack('i',f.read(4))[0])<epsilon
     6890
     6891            # Find when first station starts recording
     6892            min_tstep = min(first_tstep)
     6893            # Find when all stations have stopped recording
     6894            max_tstep = max(last_tstep)
     6895
     6896            #for time in  range(time_step_count):
     6897            for time in range(min_tstep-1,max_tstep):
     6898                assert abs(time*time_step-unpack('f',f.read(4))[0])<epsilon
     6899                for point_i in range(points_num):
     6900                    if time+1>=first_tstep[point_i] and time+1<=last_tstep[point_i]:
     6901                        x = unpack('f',f.read(4))[0]
     6902                        #print time, x, q_time[time, point_i]
     6903                        if q == 'VA': x = -x # South is positive in MUX
     6904                        #print q+" q_time[%d, %d] = %f" %(time, point_i,
     6905                                                      #q_time[time, point_i])
     6906                        assert abs(q_time[time, point_i]-x)<epsilon
     6907
     6908            f.close()
     6909                           
     6910        permutation = ensure_numeric([4,0,2])
     6911                   
     6912        # Create ordering file
     6913#         _, ordering_filename = tempfile.mkstemp('')
     6914#         order_fid = open(ordering_filename, 'w') 
     6915#         order_fid.write('index, longitude, latitude\n')
     6916#         for index in permutation:
     6917#             order_fid.write('%d, %f, %f\n' %(index,
     6918#                                              lat_long_points[index][1],
     6919#                                              lat_long_points[index][0]))
     6920#         order_fid.close()
     6921       
     6922        # -------------------------------------
     6923        # Now read files back and check values
     6924        weights = ensure_numeric([1.0])
     6925
     6926        # For each quantity read the associated list of source mux2 file with
     6927        # extention associated with that quantity
     6928        file_params=-1*num.ones(3,num.float) # [nsta,dt,nt]
     6929        OFFSET = 5
     6930
     6931        for j, file in enumerate(filesII):
     6932            # Read stage, u, v enumerated as j
     6933            #print 'Reading', j, file
     6934            #print "file", file
     6935            data = read_mux2(1, [file], weights, file_params,
     6936                             permutation, verbose)
     6937            #print str(j) + "data", data
     6938
     6939            #print 'Data received by Python'
     6940            #print data[1][8]
     6941            number_of_selected_stations = data.shape[0]
     6942            #print "number_of_selected_stations", number_of_selected_stations
     6943            #print "stations", stations
     6944
     6945            # Index where data ends and parameters begin
     6946            parameters_index = data.shape[1]-OFFSET         
     6947                 
     6948            for i in range(number_of_selected_stations):
     6949       
     6950                #print i, parameters_index
     6951                if j == 0:
     6952                    assert num.allclose(data[i][:parameters_index],
     6953                                        ha1[permutation[i], :])
     6954                   
     6955                if j == 1: assert num.allclose(data[i][:parameters_index], ua1[permutation[i], :])
     6956                if j == 2:
    66786957                    assert num.allclose(data[i][:parameters_index], -va1[permutation[i], :])
    6679                    
     6958       
     6959        self.delete_mux(filesII)           
    66806960       
    66816961    def test_urs2sts0(self):
     
    68197099
    68207100        base_name, files = self.write_mux2(lat_long_points,
    6821                                       time_step_count, time_step,
    6822                                       first_tstep, last_tstep,
    6823                                       depth=gauge_depth,
    6824                                       ha=ha,
    6825                                       ua=ua,
    6826                                       va=va)
     7101                                           time_step_count, time_step,
     7102                                           first_tstep, last_tstep,
     7103                                           depth=gauge_depth,
     7104                                           ha=ha,
     7105                                           ua=ua,
     7106                                           va=va)
    68277107
    68287108        urs2sts(base_name,
     
    68507130        y = points[:,1]
    68517131
    6852         #Check that all coordinate are correctly represented       
    6853         #Using the non standard projection (50)
     7132        # Check that all coordinate are correctly represented       
     7133        # Using the non standard projection (50)
    68547134        for i in range(4):
    68557135            zone, e, n = redfearn(lat_long_points[i][0],
     
    68587138            assert num.allclose([x[i],y[i]], [e,n])
    68597139            assert zone==-1
     7140       
     7141        self.delete_mux(files)
    68607142
    68617143           
     
    69157197        y = points[:,1]
    69167198
    6917         #Check that all coordinate are correctly represented       
    6918         #Using the non standard projection (50)
     7199        # Check that all coordinate are correctly represented       
     7200        # Using the non standard projection (50)
    69197201        for i in range(4):
    69207202            zone, e, n = redfearn(lat_long_points[i][0], lat_long_points[i][1],
     
    69227204            assert num.allclose([x[i],y[i]], [e,n])
    69237205            assert zone==geo_reference.zone
     7206       
     7207        self.delete_mux(files)
    69247208
    69257209           
     
    76527936            raise Exception, msg
    76537937
     7938       
     7939        self.delete_mux(filesI)
     7940        self.delete_mux(filesII)
    76547941
    76557942       
     
    80348321        os.remove(sts_file)
    80358322       
    8036        
    8037        
    80388323        #----------------------
    80398324        # Then read the mux files together and test
     
    81488433        os.remove(sts_file)
    81498434       
    8150 
    8151        
    81528435        #---------------
    81538436        # "Manually" add the timeseries up with weights and test
     
    81578440        stage_man = weights[0]*(stage0-tide) + weights[1]*(stage1-tide) + tide
    81588441        assert num.allclose(stage_man, stage)
    8159        
    8160        
    8161        
    8162        
    8163        
    81648442               
    81658443       
     
    82888566                       
    82898567        assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values,
    8290                             domain_drchlt.quantities['xmomentum'].vertex_values)                        
     8568                            domain_drchlt.quantities['xmomentum'].vertex_values)
    82918569                       
    82928570        assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values,
    8293                             domain_drchlt.quantities['ymomentum'].vertex_values)                                               
     8571                            domain_drchlt.quantities['ymomentum'].vertex_values)
    82948572       
    82958573       
    82968574        os.remove(sts_file+'.sts')
    82978575        os.remove(meshname)
    8298        
    8299        
    8300        
    83018576               
    83028577       
     
    84198694
    84208695
    8421 
    8422        
    8423        
    8424        
    8425            
    8426 
    8427        
    84288696        domain_drchlt = Domain(meshname)
    84298697        domain_drchlt.set_quantity('stage', tide)
     
    84478715                       
    84488716        assert num.allclose(domain_fbound.quantities['xmomentum'].vertex_values,
    8449                             domain_drchlt.quantities['xmomentum'].vertex_values)                        
     8717                            domain_drchlt.quantities['xmomentum'].vertex_values)
    84508718                       
    84518719        assert num.allclose(domain_fbound.quantities['ymomentum'].vertex_values,
    8452                             domain_drchlt.quantities['ymomentum'].vertex_values)                                               
    8453        
     8720                            domain_drchlt.quantities['ymomentum'].vertex_values)
    84548721       
    84558722        os.remove(sts_file+'.sts')
    84568723        os.remove(meshname)
    8457 
    8458 
    8459        
    84608724               
    84618725       
     
    1093411198        domain.set_quantity('xmomentum', uh)
    1093511199        domain.set_boundary( {'left': Bd, 'right': Bd, 'top': Br, 'bottom': Br})
     11200
    1093611201        for t in domain.evolve(yieldstep=1, finaltime = t_end):
    1093711202            pass
     
    1135711622
    1135811623           
     11624    def test_copy_code_files(self):
     11625        '''test that the copy_code_files() function is sane.'''
     11626
     11627        def create_file(f):
     11628            fd = open(f, 'w')
     11629            fd.write('%s\n' % f)
     11630            fd.close()
     11631
     11632        # create working directories and test files
     11633        work_dir = tempfile.mkdtemp()
     11634        dst_dir = tempfile.mkdtemp(dir=work_dir)
     11635        src_dir = tempfile.mkdtemp(dir=work_dir)
     11636
     11637        f1 = 'file1'       
     11638        filename1 = os.path.join(src_dir, f1)
     11639        create_file(filename1)
     11640        f2 = 'file2'       
     11641        filename2 = os.path.join(src_dir, f2)
     11642        create_file(filename2)
     11643        f3 = 'file3'       
     11644        filename3 = os.path.join(src_dir, f3)
     11645        create_file(filename3)
     11646        f4 = 'file4'       
     11647        filename4 = os.path.join(src_dir, f4)
     11648        create_file(filename4)
     11649        f5 = 'file5'       
     11650        filename5 = os.path.join(src_dir, f5)
     11651        create_file(filename5)
     11652
     11653        # exercise the copy function
     11654        copy_code_files(dst_dir, filename1)
     11655        copy_code_files(dst_dir, filename1, filename2)
     11656        copy_code_files(dst_dir, (filename4, filename5, filename3))
     11657
     11658        # test that files were actually copied
     11659        self.failUnless(access(os.path.join(dst_dir, f1), F_OK))
     11660        self.failUnless(access(os.path.join(dst_dir, f2), F_OK))
     11661        self.failUnless(access(os.path.join(dst_dir, f3), F_OK))
     11662        self.failUnless(access(os.path.join(dst_dir, f4), F_OK))
     11663        self.failUnless(access(os.path.join(dst_dir, f5), F_OK))
     11664
     11665        # clean up
     11666        shutil.rmtree(work_dir)
    1135911667           
    1136011668#-------------------------------------------------------------
     
    1136211670if __name__ == "__main__":
    1136311671    suite = unittest.makeSuite(Test_Data_Manager,'test')
    11364 
    11365     # FIXME (Ole): This is the test that fails under Windows
    11366     #suite = unittest.makeSuite(Test_Data_Manager,'test_read_mux_platform_problem2')
    11367     #suite = unittest.makeSuite(Test_Data_Manager,'test_file_boundary_stsIV')
    1136811672   
    1136911673    if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V':
Note: See TracChangeset for help on using the changeset viewer.