- Timestamp:
- Jun 12, 2016, 2:22:14 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r813 r816 6638 6638 Njipt = dictionary_key(subfinished, False) 6639 6639 if Njipt is not None: 6640 print Njipt, 'points subflow:', ijsubflow[Njipt]6640 # print Njipt, 'points subflow:', ijsubflow[Njipt] 6641 6641 for ipt in ijsubflow[Njipt]: 6642 6642 if ijfound[ipt] == False: 6643 6643 jipt = ijsubbasin[ipt] 6644 6644 break 6645 print ' working from point:', ipt, 'ji pair:', jipt6645 # print ' working from point:', ipt, 'ji pair:', jipt 6646 6646 ijfound[ipt] = True 6647 6647 Nij = ipt … … 6649 6649 # Keep searching since there are grid-points not found! 6650 6650 print ' ' + fname + ': Keep searching since there are grid-points not found!!' 6651 print ijfound6651 # print ijfound 6652 6652 Nij = dictionary_key(ijfound, False) 6653 6653 if Nij is None: … … 6667 6667 else: 6668 6668 Njipt = Njipt + '1' 6669 print ' ' + fname + "new sub-flow '" + Njipt + "' !!"6669 # print ' ' + fname + "new sub-flow '" + Njipt + "' !!" 6670 6670 subfinished[Njipt] = False 6671 6671 Nij = np.max(ijfound.keys()) 6672 6672 6673 print 'Lluis Nij:', Nij6673 # print 'Lluis Nij:', Nij 6674 6674 # Looking for which point of the sub-flow retake the search 6675 6675 if Nij == 1: … … 6678 6678 6679 6679 ardtrips = vals_around(trips,jipt) 6680 print ' ' + fname + 'ardtrips _______'6681 print ardtrips6680 # print ' ' + fname + 'ardtrips _______' 6681 # print ardtrips 6682 6682 6683 6683 arrive = incomming_flow(ardtrips) 6684 6684 Narrive = np.sum(arrive) 6685 print Nij, ' ' + fname + ' Narrive:', Narrive6685 # print Nij, ' ' + fname + ' Narrive:', Narrive 6686 6686 if Narrive == 0: 6687 6687 ijfound[Nij] = True 6688 6688 subfinished[Njipt] = True 6689 6689 else: 6690 print ' ' + fname + 'arrive _______'6691 print arrive6690 # print ' ' + fname + 'arrive _______' 6691 # print arrive 6692 6692 followvals = np.zeros((3,3), dtype=bool) 6693 6693 followvals = arrive 6694 6694 6695 6695 for ifollow in range(Narrive): 6696 print 'ifollow:',ifollow,'/',Narrive6696 # print 'ifollow:',ifollow,'/',Narrive 6697 6697 6698 6698 # We only want to work with that ij, which have not yet been found 6699 6699 while np.sum(followvals) != 0: 6700 print Nij,' Looking for a non-located point in subbasin ________'6701 print subbasin[jipt[0]-1:jipt[0]+2,jipt[1]-1:jipt[1]+2]6700 # print Nij,' Looking for a non-located point in subbasin ________' 6701 # print subbasin[jipt[0]-1:jipt[0]+2,jipt[1]-1:jipt[1]+2] 6702 6702 jifollow = index_mat(followvals, True) 6703 6703 jiequiv = jifollow - [1,1] … … 6711 6711 else: 6712 6712 Njipt = Njipt + str(ifollow) 6713 print ' ' + fname + "new sub-flow '" + Njipt + "' !!"6713 # print ' ' + fname + "new sub-flow '" + Njipt + "' !!" 6714 6714 subfinished[Njipt] = False 6715 6715 subbasin[jipt[0]+jiequiv[0], jipt[1]+jiequiv[1]] = True … … 6728 6728 ijfound[Nij] = True 6729 6729 subfinished[Njipt] = True 6730 print Nij," subflow '" + Njipt + "' finished!!"6730 # print Nij," subflow '" + Njipt + "' finished!!" 6731 6731 break 6732 6732 … … 6737 6737 quit() 6738 6738 6739 if ijsubflow.has_key(Njipt):6740 print "Lluis points of subflow: '" + Njipt + "' _______=", ijsubflow[Njipt]6741 for isub in ijsubflow[Njipt]:6742 print ' ' , isub , ':', ijsubbasin[isub], ijfound[isub]6743 if Nij == 10: print 'Nij = 9:', ijfound[9]6744 6745 print subbasin6739 # if ijsubflow.has_key(Njipt): 6740 # print "Lluis points of subflow: '" + Njipt + "' _______=", ijsubflow[Njipt] 6741 # for isub in ijsubflow[Njipt]: 6742 # print ' ' , isub , ':', ijsubbasin[isub], ijfound[isub] 6743 # if Nij == 10: print 'Nij = 9:', ijfound[9] 6744 6745 # print subbasin 6746 6746 # if Nij > 4: quit() 6747 6747 6748 6748 return subbasin 6749 6749 6750 # Caceres6751 rivers = np.array([7, 1, 1, 1, 1, 5, 5, 1, \6752 7, 1, 6, 3, 5, 5, 6, 5, \6753 8, 7, 5, 3, 5, 6, 3, 5, \6754 1, 1, 3, 5, 5, 7, 5, 5, \6755 3, 3, 5, 6, 5, 5, 5, 7 ], dtype=int).reshape(5,8)6756 6757 point = [4,4]6750 ## Caceres 6751 #rivers = np.array([7, 1, 1, 1, 1, 5, 5, 1, \ 6752 # 7, 1, 6, 3, 5, 5, 6, 5, \ 6753 # 8, 7, 5, 3, 5, 6, 3, 5, \ 6754 # 1, 1, 3, 5, 5, 7, 5, 5, \ 6755 # 3, 3, 5, 6, 5, 5, 5, 7 ], dtype=int).reshape(5,8) 6756 6757 #point = [4,4] 6758 6758 6759 6759 # Porto Do Alegre … … 6770 6770 #point = [7,0] 6771 6771 6772 print rivers6773 print rivers[point[0], point[1]]6774 6775 masksubbasin, subflows, subflowspt = subbasin_point(rivers, point)6776 print rivers6777 print masksubbasin6778 for subflow in subflows:6779 print subflow, ':', subflows[subflow]6780 for isub in subflows[subflow]:6781 print ' ' , isub , ':', subflowspt[isub]6782 6783 print 'Total sub-basin:', np.sum(masksubbasin)6784 6785 quit()6772 #print rivers 6773 #print rivers[point[0], point[1]] 6774 6775 #masksubbasin, subflows, subflowspt = subbasin_point(rivers, point) 6776 #print rivers 6777 #print masksubbasin 6778 #for subflow in subflows: 6779 # print subflow, ':', subflows[subflow] 6780 # for isub in subflows[subflow]: 6781 # print ' ' , isub , ':', subflowspt[isub] 6782 6783 #print 'Total sub-basin:', np.sum(masksubbasin) 6784 6785 #quit()
Note: See TracChangeset
for help on using the changeset viewer.