code: def normalize_array(a,direction="column"):
      
      b = a.copy()
      if(direction == "column"):
          sums = np.sum(b,0)
          return np.nan_to_num(b/sums)
      elif(direction == "row"):
          sums =np.sum(b,1)
          return  np.nan_to_num((b.transpose() / sums).transpose())
      elif(direction == "all"):
          sums = np.sum(b)
          return np.nan_to_num(b / sums)
      else:
          print "Error non existing normalization"
          return b
docs: Normalizes an array to sum to one, either column wise, 
      or row wise or the full array.
      
      *Directions*
          Column-wise - 0 default
          Row-wise - 1 default
          All - 2 default