original_docstring: 
          This function removed the subareas from subnoinstream
          which do not exist in subnoindemw. 
          
docstring: This function removed the subareas from subnoinstream
  which do not exist in subnoindemw.
docstring_tokens: This function removed the subareas from subnoinstream which do not exist in subnoindemw .
code: def rmExtraStrm(self, subdemwlst, substreamdict):
          '''
          This function removed the subareas from subnoinstream
          which do not exist in subnoindemw. 
          '''
          # substrm is the list of subnumbers in the tree file
          # substrmtorm is the stream number only exists in the 
          # tree file but not in the demw files (the raster map)
          substrm = substreamdict.keys()
          
          substrmtorm = [i for i in substrm
                         if not i in subdemwlst]
          
          # Here I just removed them by reconnecting the streams
  #        print(substrmtorm)
          
          print(substrmtorm)
          
          for subid in range(len(substrmtorm)):
              
  #            print("processing subarea: ", subid)
              # Get the upstream and downstrema of the value to be removed
              tempvalue = None
              tempvalue = substreamdict[substrmtorm[subid]]
  #            print('temo...: ',subid, tempvalue)
              
              # The streams connected by this need to be modified
              # value of dict [sub, downstrm, upstream1, upstream2]
              # upstream1 = tempvalue[2]
              
              # Change this subarea's downstream's upstream to
              # this subarea's downstream
              # There are two upstreams.
              # Since we are removing, and the upstreams will have 
              # a downstream, which is the one to be removed. This downstream
              # will be changed to the to-be-removed stream's downstream 
              # to make the connection. 
              # index 0 is downstream
  #            print('upstream1: ',tempvalue[1],substreamdict[tempvalue[1]])
              substreamdict[tempvalue[1]][0] = tempvalue[0]
  #            print('upstream1 lat: ', tempvalue[1],substreamdict[tempvalue[1]])
              
  #            print('upstream2...: ',tempvalue[2],substreamdict[tempvalue[2]])
              substreamdict[tempvalue[2]][0] = tempvalue[0]
  #            print('upstream2 lat: ', tempvalue[2], substreamdict[tempvalue[2]])
  
              # Change the upstream of this subarea's downstream to
              # its first upstream
              # The downstream might have two upstream, only change the one
              # that is equal to the subarea to be removed.
  #            print('downstream', tempvalue[0], substreamdict[tempvalue[0]][1])
  #            print('downstream', tempvalue[0], substreamdict[tempvalue[0]][2])
              
              if (substreamdict[tempvalue[0]][1] == substrmtorm[subid]):
  #                print('upstream1: ',substreamdict[tempvalue[0]])
                  substreamdict[tempvalue[0]][1] = tempvalue[1]
  #                print('upstream1 later: ',substreamdict[tempvalue[0]])
              elif (substreamdict[tempvalue[0]][2] == substrmtorm[subid]):
  #                print('upstream2: ',substreamdict[tempvalue[0]])
                  substreamdict[tempvalue[0]][2] = tempvalue[1]
  #                print('upstream2 later: ',substreamdict[tempvalue[0]])
              
              # First remove keys in dict
              substreamdict.pop(substrmtorm[subid], None)
              # First remove keys in dict
              substreamdict.pop(subid, None)
  
          return substreamdict
code_tokens: def rmExtraStrm ( self , subdemwlst , substreamdict ) : substrm = substreamdict . keys ( ) substrmtorm = [ i for i in substrm if not i in subdemwlst ] print ( substrmtorm ) for subid in range ( len ( substrmtorm ) ) : tempvalue = None tempvalue = substreamdict [ substrmtorm [ subid ] ] substreamdict [ tempvalue [ 1 ] ] [ 0 ] = tempvalue [ 0 ] substreamdict [ tempvalue [ 2 ] ] [ 0 ] = tempvalue [ 0 ] if ( substreamdict [ tempvalue [ 0 ] ] [ 1 ] == substrmtorm [ subid ] ) : substreamdict [ tempvalue [ 0 ] ] [ 1 ] = tempvalue [ 1 ] elif ( substreamdict [ tempvalue [ 0 ] ] [ 2 ] == substrmtorm [ subid ] ) : substreamdict [ tempvalue [ 0 ] ] [ 2 ] = tempvalue [ 1 ] substreamdict . pop ( substrmtorm [ subid ] , None ) substreamdict . pop ( subid , None ) return substreamdict
short_docstring: This function removed the subareas from subnoinstream
  which do not exist in subnoindemw.
short_docstring_tokens: This function removed the subareas from subnoinstream which do not exist in subnoindemw .
comment: '''
          This function removed the subareas from subnoinstream
          which do not exist in subnoindemw. 
          '''$SEP$# substrm is the list of subnumbers in the tree file$SEP$# substrmtorm is the stream number only exists in the $SEP$# tree file but not in the demw files (the raster map)$SEP$# Here I just removed them by reconnecting the streams$SEP$#        print(substrmtorm)$SEP$#            print("processing subarea: ", subid)$SEP$# Get the upstream and downstrema of the value to be removed$SEP$#            print('temo...: ',subid, tempvalue)$SEP$# The streams connected by this need to be modified$SEP$# value of dict [sub, downstrm, upstream1, upstream2]$SEP$# upstream1 = tempvalue[2]$SEP$# Change this subarea's downstream's upstream to$SEP$# this subarea's downstream$SEP$# There are two upstreams.$SEP$# Since we are removing, and the upstreams will have $SEP$# a downstream, which is the one to be removed. This downstream$SEP$# will be changed to the to-be-removed stream's downstream $SEP$# to make the connection. $SEP$# index 0 is downstream$SEP$#            print('upstream1: ',tempvalue[1],substreamdict[tempvalue[1]])$SEP$#            print('upstream1 lat: ', tempvalue[1],substreamdict[tempvalue[1]])$SEP$#            print('upstream2...: ',tempvalue[2],substreamdict[tempvalue[2]])$SEP$#            print('upstream2 lat: ', tempvalue[2], substreamdict[tempvalue[2]])$SEP$# Change the upstream of this subarea's downstream to$SEP$# its first upstream$SEP$# The downstream might have two upstream, only change the one$SEP$# that is equal to the subarea to be removed.$SEP$#            print('downstream', tempvalue[0], substreamdict[tempvalue[0]][1])$SEP$#            print('downstream', tempvalue[0], substreamdict[tempvalue[0]][2])$SEP$#                print('upstream1: ',substreamdict[tempvalue[0]])$SEP$#                print('upstream1 later: ',substreamdict[tempvalue[0]])$SEP$#                print('upstream2: ',substreamdict[tempvalue[0]])$SEP$#                print('upstream2 later: ',substreamdict[tempvalue[0]])$SEP$# First remove keys in dict$SEP$# First remove keys in dict