Ignore:
Timestamp:
Aug 6, 2008, 7:09:57 PM (16 years ago)
Author:
sexton
Message:

update to urs2sts testing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r5611 r5622  
    65616561        ordering_filename=os.path.join(testdir, 'thinned_bound_order_test.txt')
    65626562       
    6563        
    65646563        sources = ['1-z.grd','2-z.grd','3-z.grd']
    65656564       
     
    65696568                              [9.5,10.9,12.4,13.9,17.1]])
    65706569
    6571         time_start_e = time_start_z
    6572 
    6573         # FIXME(Ole): Should they really be treated differently?
    6574         time_start_n = array([[10.0,11.5,13,14.5,17.7],
    6575                               [10.6,11.8,12.9,14.2,17.4],
    6576                               [10.6,11.3,12.4,13.9,17.1]])
    6577 
     6570        time_start_e = time_start_n = time_start_z
     6571
     6572        # time step in urs output
     6573        delta_t = 0.1
    65786574       
    65796575        # Make sts file for each source
     
    66046600            for i, name in enumerate(quantity_names):
    66056601                quantities[name] = fid.variables[name][:]
    6606 
    6607             # For each station, compare urs2sts output to known urs output
    6608            
    6609             delta_t = 0.1
    66106602           
    66116603            # Make sure start time from sts file is the minimum starttime
     
    66166608            msg = 'sts starttime for source %d was %f. Should have been %f'\
    66176609                %(source_number, sts_starttime, starttime)
    6618                
    6619             #assert allclose(sts_starttime-delta_t, starttime), msg
    6620             ## FIXME - have done a dodgy to get it through here ###   
    6621            
    6622             #print source_filename, sts_starttime, starttime
    66236610            assert allclose(sts_starttime, starttime), msg             
    6624            
     6611
     6612            # For each station, compare urs2sts output to known urs output
    66256613            for j in range(len(x)):
    66266614                index_start_urs = 0
     
    66536641                start_times_z = time_start_z[source_number-1]
    66546642
    6655                 count = 0
    6656                 # find start and end time for e velocity
    6657                 for i in range(len(urs_e)):
    6658                     if urs_e[i] == 0.0:
    6659                         index_start_urs_e = i+1
    6660                     if int(urs_e[i]) == 99 and count <> 1:
    6661                         count +=1
    6662                         index_end_urs_e = i
    6663 
    6664                 if count == 0: index_end_urs_e = len(urs_e)
    6665 
     6643                # start times for easting velocities should be the same as stage
    66666644                start_times_e = time_start_e[source_number-1]
    6667 
    6668                 count = 0
    6669                 # find start and end time for n velocity
    6670                 for i in range(len(urs_n)):
    6671                     if urs_n[i] == 0.0:
    6672                         index_start_urs_n = i+1
    6673                     if int(urs_n[i]) == 99 and count <> 1:
    6674                         count +=1
    6675                         index_end_urs_n = i
    6676 
    6677                 if count == 0: index_end_urs_n = len(urs_n)
    6678 
     6645                index_start_urs_e = index_start_urs_z
     6646                index_end_urs_e = index_end_urs_z
     6647
     6648                # start times for northing velocities should be the same as stage
    66796649                start_times_n = time_start_n[source_number-1]
     6650                index_start_urs_n = index_start_urs_z
     6651                index_end_urs_n = index_end_urs_z
    66806652               
    66816653                # Check that actual start time matches header information for stage
     
    67076679                index_end_stage = index_start_stage + len(urs_stage[index_start_urs_z:index_end_urs_z])
    67086680
    6709                 index_start_x = 0
    6710                 index_end_x = 0
    6711                 count = 0
    67126681                sts_xmom = quantities['xmomentum'][:,j]
    6713                 for i in range(len(sts_xmom)):
    6714                     if sts_xmom[i] <> 0.0 and count <> 1:
    6715                         count += 1
    6716                         index_start_x = i
    6717                     if int(sts_xmom[i]) == 99 and count <> 1:
    6718                         count += 1
    6719                         index_end_x = i
    6720 
     6682                index_start_x = index_start_stage
    67216683                index_end_x = index_start_x + len(urs_e[index_start_urs_e:index_end_urs_e])
    67226684
    6723                 index_start_y = 0
    6724                 index_end_y = 0
    6725                 count = 0
    67266685                sts_ymom = quantities['ymomentum'][:,j]
    6727                 for i in range(len(sts_ymom)):
    6728                     if sts_ymom[i] <> 0.0 and count <> 1:
    6729                         count += 1
    6730                         index_start_y = i
    6731                     if int(sts_ymom[i]) == 99 and count <> 1:
    6732                         count += 1
    6733                         index_end_y = i
    6734 
     6686                index_start_y = index_start_stage
    67356687                index_end_y = index_start_y + len(urs_n[index_start_urs_n:index_end_urs_n])
    67366688
    67376689                # check that urs stage and sts stage are the same
    6738                 msg = 'urs stage is not equal to sts stage for station %i' %j
     6690                msg = 'urs stage is not equal to sts stage for for source %i and station %i' %(source_number,j)
    67396691                assert allclose(urs_stage[index_start_urs_z:index_end_urs_z],
    67406692                                sts_stage[index_start_stage:index_end_stage],
     
    67426694                               
    67436695                # check that urs e velocity and sts xmomentum are the same
    6744                 msg = 'urs e velocity is not equivalent to sts x momentum for station %i' %j
     6696                msg = 'urs e velocity is not equivalent to sts x momentum for for source %i and station %i' %(source_number,j)
    67456697                assert allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]),
    67466698                                sts_xmom[index_start_x:index_end_x],
     
    67486700               
    67496701                # check that urs n velocity and sts ymomentum are the same
    6750                 msg = 'urs n velocity is not equivalent to sts y momentum for station %i' %j
     6702                #print 'urs n velocity', urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j])
     6703                #print 'sts momentum', sts_ymom[index_start_y:index_end_y]                                                             
     6704                msg = 'urs n velocity is not equivalent to sts y momentum for source %i and station %i' %(source_number,j)
    67516705                assert allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]),
    67526706                                sts_ymom[index_start_y:index_end_y],
     
    67686722        # combined
    67696723        time_start_z = array([9.5,10.9,12.4,13.9,17.1])
    6770         time_start_e = time_start_z
    6771         time_start_n = array([10.0,11.3,12.4,13.9,17.1])
    6772        
     6724        time_start_e = time_start_n = time_start_z
     6725         
    67736726        # make sts file for combined sources
    67746727        weights = [1., 2., 3.]
     
    68136766        msg = 'sts starttime was %f. Should have been %f'\
    68146767            %(sts_starttime, starttime)
    6815         #assert allclose(sts_starttime-delta_t, starttime), msg
    68166768        assert allclose(sts_starttime, starttime), msg
    6817         ## FIXME - have done a dodgy to get it through here ###   
    68186769   
    68196770        #stations = [1,2,3]
     
    68516802            start_times_z = time_start_z[j]
    68526803
    6853             count = 0
    6854             # find start and end time for e velocity
    6855             for i in range(len(urs_e)):
    6856                 if urs_e[i] == 0.0:
    6857                     index_start_urs_e = i+1
    6858                 if int(urs_e[i]) == 99 and count <> 1:
    6859                     count +=1
    6860                     index_end_urs_e = i
    6861 
    6862             if count == 0: index_end_urs_e = len(urs_e)
    6863 
    68646804            start_times_e = time_start_e[j]
    6865 
    6866             count = 0
    6867             # find start and end time for n velocity
    6868             for i in range(len(urs_n)):
    6869                 if urs_n[i] == 0.0:
    6870                     index_start_urs_n = i+1
    6871                 if int(urs_n[i]) == 99 and count <> 1:
    6872                     count +=1
    6873                     index_end_urs_n = i
    6874 
    6875             if count == 0: index_end_urs_n = len(urs_n)
     6805            index_start_urs_e = index_start_urs_z
    68766806
    68776807            start_times_n = time_start_n[j]
     6808            index_start_urs_n = index_start_urs_z
    68786809               
    68796810            # Check that actual start time matches header information for stage
     
    69106841            index_end_stage = index_start_stage + len(urs_stage[index_start_urs_z:index_end_urs_z])
    69116842
    6912             index_start_x = 0
    6913             index_end_x = 0
    6914             count = 0
    6915             count1 = -1
    6916             index_end=[0]
    6917             sts_xmom = quantities['xmomentum'][:,j]
    6918             for i in range(len(sts_xmom)):
    6919                 if sts_xmom[i] <> 0.0 and count <> 1:
    6920                     count += 1
    6921                     index_start_x = i
    6922                 if sts_xmom[i] == 0.0 and i <> 1:
    6923                     index_end.append(i)
    6924                     count1 += 1
    6925                     if index_end[count1]-index_end[count1-1]>1:
    6926                         index_end_x = index_end[count1]
    6927 
    6928             if index_end_x < index_start_x: index_end_x = len(sts_xmom)
     6843            index_start_x = index_start_stage
    69296844            index_end_x = index_start_x + len(urs_stage[index_start_urs_e:index_end_urs_e])
    6930 
    6931             index_start_y = 0
    6932             index_end_y = 0
    6933             count = 0
    6934             count1 = -1
    6935             index_end = [0]
    6936             sts_ymom = quantities['ymomentum'][:,j]
    6937             for i in range(len(sts_ymom)):
    6938                 if sts_ymom[i] <> 0.0 and count <> 1:
    6939                     count += 1
    6940                     index_start_y = i
    6941                 if sts_ymom[i] == 0.0 and i > 1:
    6942                     index_end.append(i)
    6943                     count1 +=1
    6944                     if index_end[count1]-index_end[count1-1]>1:
    6945                         index_end_y = index_end[count1]
    6946 
    6947             if index_end_y < index_start_y: index_end_y = len(sts_ymom)
     6845            sts_xmom = quantities['ymomentum'][:,j]
     6846
     6847            index_start_y = index_start_stage
    69486848            index_end_y = index_start_y + len(urs_stage[index_start_urs_n:index_end_urs_n])
     6849            sts_ymom = quantities['ymomentum'][:,j]
    69496850
    69506851            # check that urs stage and sts stage are the same
     
    1020010101    #suite = unittest.makeSuite(Test_Data_Manager,'covered_')
    1020110102    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_individual_sources')
     10103    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_combined_sources')
    1020210104    #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts')       
    1020310105
Note: See TracChangeset for help on using the changeset viewer.