Changeset 5622
- Timestamp:
- Aug 6, 2008, 7:09:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/test_data_manager.py
r5611 r5622 6561 6561 ordering_filename=os.path.join(testdir, 'thinned_bound_order_test.txt') 6562 6562 6563 6564 6563 sources = ['1-z.grd','2-z.grd','3-z.grd'] 6565 6564 … … 6569 6568 [9.5,10.9,12.4,13.9,17.1]]) 6570 6569 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 6578 6574 6579 6575 # Make sts file for each source … … 6604 6600 for i, name in enumerate(quantity_names): 6605 6601 quantities[name] = fid.variables[name][:] 6606 6607 # For each station, compare urs2sts output to known urs output6608 6609 delta_t = 0.16610 6602 6611 6603 # Make sure start time from sts file is the minimum starttime … … 6616 6608 msg = 'sts starttime for source %d was %f. Should have been %f'\ 6617 6609 %(source_number, sts_starttime, starttime) 6618 6619 #assert allclose(sts_starttime-delta_t, starttime), msg6620 ## FIXME - have done a dodgy to get it through here ###6621 6622 #print source_filename, sts_starttime, starttime6623 6610 assert allclose(sts_starttime, starttime), msg 6624 6611 6612 # For each station, compare urs2sts output to known urs output 6625 6613 for j in range(len(x)): 6626 6614 index_start_urs = 0 … … 6653 6641 start_times_z = time_start_z[source_number-1] 6654 6642 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 6666 6644 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 6679 6649 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 6680 6652 6681 6653 # Check that actual start time matches header information for stage … … 6707 6679 index_end_stage = index_start_stage + len(urs_stage[index_start_urs_z:index_end_urs_z]) 6708 6680 6709 index_start_x = 06710 index_end_x = 06711 count = 06712 6681 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 6721 6683 index_end_x = index_start_x + len(urs_e[index_start_urs_e:index_end_urs_e]) 6722 6684 6723 index_start_y = 06724 index_end_y = 06725 count = 06726 6685 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 6735 6687 index_end_y = index_start_y + len(urs_n[index_start_urs_n:index_end_urs_n]) 6736 6688 6737 6689 # check that urs stage and sts stage are the same 6738 msg = 'urs stage is not equal to sts stage for station %i' %j6690 msg = 'urs stage is not equal to sts stage for for source %i and station %i' %(source_number,j) 6739 6691 assert allclose(urs_stage[index_start_urs_z:index_end_urs_z], 6740 6692 sts_stage[index_start_stage:index_end_stage], … … 6742 6694 6743 6695 # 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' %j6696 msg = 'urs e velocity is not equivalent to sts x momentum for for source %i and station %i' %(source_number,j) 6745 6697 assert allclose(urs_e[index_start_urs_e:index_end_urs_e]*(urs_stage[index_start_urs_e:index_end_urs_e]-elevation[j]), 6746 6698 sts_xmom[index_start_x:index_end_x], … … 6748 6700 6749 6701 # 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) 6751 6705 assert allclose(urs_n[index_start_urs_n:index_end_urs_n]*(urs_stage[index_start_urs_n:index_end_urs_n]-elevation[j]), 6752 6706 sts_ymom[index_start_y:index_end_y], … … 6768 6722 # combined 6769 6723 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 6773 6726 # make sts file for combined sources 6774 6727 weights = [1., 2., 3.] … … 6813 6766 msg = 'sts starttime was %f. Should have been %f'\ 6814 6767 %(sts_starttime, starttime) 6815 #assert allclose(sts_starttime-delta_t, starttime), msg6816 6768 assert allclose(sts_starttime, starttime), msg 6817 ## FIXME - have done a dodgy to get it through here ###6818 6769 6819 6770 #stations = [1,2,3] … … 6851 6802 start_times_z = time_start_z[j] 6852 6803 6853 count = 06854 # find start and end time for e velocity6855 for i in range(len(urs_e)):6856 if urs_e[i] == 0.0:6857 index_start_urs_e = i+16858 if int(urs_e[i]) == 99 and count <> 1:6859 count +=16860 index_end_urs_e = i6861 6862 if count == 0: index_end_urs_e = len(urs_e)6863 6864 6804 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 6876 6806 6877 6807 start_times_n = time_start_n[j] 6808 index_start_urs_n = index_start_urs_z 6878 6809 6879 6810 # Check that actual start time matches header information for stage … … 6910 6841 index_end_stage = index_start_stage + len(urs_stage[index_start_urs_z:index_end_urs_z]) 6911 6842 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 6929 6844 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 6948 6848 index_end_y = index_start_y + len(urs_stage[index_start_urs_n:index_end_urs_n]) 6849 sts_ymom = quantities['ymomentum'][:,j] 6949 6850 6950 6851 # check that urs stage and sts stage are the same … … 10200 10101 #suite = unittest.makeSuite(Test_Data_Manager,'covered_') 10201 10102 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_individual_sources') 10103 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts_combined_sources') 10202 10104 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sts') 10203 10105
Note: See TracChangeset
for help on using the changeset viewer.