nodes: 0, module; 1, function_definition; 2, function_name:check_photometry_categorize; 3, parameters; 4, block; 5, identifier:x; 6, identifier:y; 7, identifier:levels; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, comment:# Mean of the upper half; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, if_statement; 21, for_statement; 22, return_statement; 23, identifier:tags; 24, None; 25, string; 26, assignment; 27, assignment; 28, assignment; 29, call; 30, assignment; 31, augmented_assignment; 32, assignment; 33, assignment; 34, assignment; 35, comparison_operator:tags is None; 36, block; 37, pattern_list; 38, call; 39, block; 40, else_clause; 41, expression_list; 42, string_content:Put every point in its category.
  
      levels must be sorted.; 43, identifier:x; 44, call; 45, identifier:y; 46, call; 47, identifier:ys; 48, call; 49, attribute; 50, argument_list; 51, identifier:m; 52, call; 53, identifier:y; 54, identifier:m; 55, identifier:m; 56, float:1.0; 57, identifier:s; 58, call; 59, identifier:result; 60, list; 61, identifier:tags; 62, None; 63, expression_statement; 64, identifier:l; 65, identifier:t; 66, identifier:zip; 67, argument_list; 68, expression_statement; 69, if_statement; 70, block; 71, identifier:result; 72, tuple; 73, attribute; 74, argument_list; 75, attribute; 76, argument_list; 77, attribute; 78, argument_list; 79, identifier:ys; 80, identifier:sort; 81, attribute; 82, argument_list; 83, attribute; 84, argument_list; 85, assignment; 86, identifier:levels; 87, identifier:tags; 88, assignment; 89, call; 90, block; 91, expression_statement; 92, identifier:m; 93, identifier:s; 94, identifier:numpy; 95, identifier:asarray; 96, identifier:x; 97, identifier:numpy; 98, identifier:asarray; 99, identifier:y; 100, identifier:y; 101, identifier:copy; 102, subscript; 103, identifier:mean; 104, subscript; 105, identifier:std; 106, identifier:tags; 107, call; 108, identifier:indc; 109, comparison_operator:y < l; 110, attribute; 111, argument_list; 112, expression_statement; 113, expression_statement; 114, expression_statement; 115, expression_statement; 116, expression_statement; 117, call; 118, identifier:ys; 119, slice; 120, identifier:ys; 121, slice; 122, identifier:list; 123, argument_list; 124, identifier:y; 125, identifier:l; 126, identifier:indc; 127, identifier:any; 128, assignment; 129, assignment; 130, call; 131, assignment; 132, assignment; 133, attribute; 134, argument_list; 135, binary_operator:len(ys) // 2; 136, binary_operator:len(ys) // 2; 137, call; 138, identifier:x1; 139, subscript; 140, identifier:y1; 141, subscript; 142, attribute; 143, argument_list; 144, identifier:x; 145, subscript; 146, identifier:y; 147, subscript; 148, identifier:result; 149, identifier:append; 150, tuple; 151, call; 152, integer:2; 153, call; 154, integer:2; 155, attribute; 156, argument_list; 157, identifier:x; 158, identifier:indc; 159, identifier:y; 160, identifier:indc; 161, identifier:result; 162, identifier:append; 163, tuple; 164, identifier:x; 165, unary_operator; 166, identifier:y; 167, unary_operator; 168, identifier:x; 169, identifier:y; 170, subscript; 171, identifier:len; 172, argument_list; 173, identifier:len; 174, argument_list; 175, attribute; 176, identifier:range; 177, binary_operator:len(levels) + 1; 178, identifier:x1; 179, identifier:y1; 180, identifier:t; 181, identifier:indc; 182, identifier:indc; 183, identifier:tags; 184, unary_operator; 185, identifier:ys; 186, identifier:ys; 187, identifier:six; 188, identifier:moves; 189, call; 190, integer:1; 191, integer:1; 192, identifier:len; 193, argument_list; 194, identifier:levels
code: def check_photometry_categorize(x, y, levels, tags=None):
      '''Put every point in its category.
  
      levels must be sorted.'''
      x = numpy.asarray(x)
      y = numpy.asarray(y)
      ys = y.copy()
      ys.sort()
      # Mean of the upper half
      m = ys[len(ys) // 2:].mean()
      y /= m
      m = 1.0
      s = ys[len(ys) // 2:].std()
      result = []
  
      if tags is None:
          tags = list(six.moves.range(len(levels) + 1))
  
      for l, t in zip(levels, tags):
          indc = y < l
          if indc.any():
              x1 = x[indc]
              y1 = y[indc]
              result.append((x1, y1, t))
  
              x = x[~indc]
              y = y[~indc]
      else:
          result.append((x, y, tags[-1]))
  
      return result, (m, s)