nodes: 0, module; 1, function_definition; 2, function_name:process_data_for_mean; 3, parameters; 4, block; 5, identifier:data; 6, identifier:direction_type_key; 7, expression_statement; 8, expression_statement; 9, comment:# data model 2.5; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, comment:# sort data  into lines and planes and collect cartesian coordinates; 15, for_statement; 16, return_statement; 17, comment:"""
      takes list of dicts with dec and inc as well as direction_type if possible or method_codes and sorts the data into lines and planes and process it for fisher means
  
      @param: data - list of dicts with dec inc and some manner of PCA type info
      @param: direction_type_key - key that indicates the direction type variable in the dictionaries of data
      @return: tuple with values - (
                                  list of lists with [dec, inc, 1.] for all lines
                                  number of line
                                  list of lists with [EL,EM,EN] of all planes
                                  number of planes
                                  list of sum of the cartezian components of all lines
                                  )
      """; 18, assignment; 19, comparison_operator:'dir_dec' in data[0].keys(); 20, comment:# this is data model 3.0; 21, block; 22, assignment; 23, assignment; 24, assignment; 25, identifier:rec; 26, identifier:data; 27, block; 28, expression_list; 29, pattern_list; 30, expression_list; 31, string; 32, call; 33, expression_statement; 34, pattern_list; 35, expression_list; 36, pattern_list; 37, expression_list; 38, identifier:E; 39, list; 40, expression_statement; 41, if_statement; 42, identifier:fdata; 43, identifier:n_lines; 44, identifier:L; 45, identifier:n_planes; 46, identifier:E; 47, identifier:dec_key; 48, identifier:inc_key; 49, identifier:meth_key; 50, string; 51, string; 52, string; 53, string_content:dir_dec; 54, attribute; 55, argument_list; 56, assignment; 57, identifier:n_lines; 58, identifier:n_planes; 59, integer:0; 60, integer:0; 61, identifier:L; 62, identifier:fdata; 63, list; 64, list; 65, integer:0; 66, integer:0; 67, integer:0; 68, assignment; 69, comparison_operator:direction_type_key in list(rec.keys()); 70, block; 71, elif_clause; 72, elif_clause; 73, else_clause; 74, string_content:dec; 75, string_content:inc; 76, string_content:magic_method_codes; 77, subscript; 78, identifier:keys; 79, pattern_list; 80, expression_list; 81, identifier:cart; 82, subscript; 83, identifier:direction_type_key; 84, call; 85, if_statement; 86, comparison_operator:'method_codes' in list(rec.keys()); 87, block; 88, comparison_operator:meth_key in list(rec.keys()); 89, block; 90, comment:# EVERYTHING IS A LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!; 91, block; 92, identifier:data; 93, integer:0; 94, identifier:dec_key; 95, identifier:inc_key; 96, identifier:meth_key; 97, string; 98, string; 99, string; 100, call; 101, integer:0; 102, identifier:list; 103, argument_list; 104, comparison_operator:rec[direction_type_key] == 'p'; 105, comment:# this is a pole to a plane; 106, block; 107, else_clause; 108, string; 109, call; 110, if_statement; 111, identifier:meth_key; 112, call; 113, if_statement; 114, expression_statement; 115, comment:# collect data for fisher calculation; 116, expression_statement; 117, expression_statement; 118, expression_statement; 119, expression_statement; 120, string_content:dir_dec; 121, string_content:dir_inc; 122, string_content:method_codes; 123, identifier:dir2cart; 124, argument_list; 125, call; 126, subscript; 127, string; 128, expression_statement; 129, expression_statement; 130, comment:# this is the "EL, EM, EN" array of MM88; 131, comment:# this is a line; 132, block; 133, string_content:method_codes; 134, identifier:list; 135, argument_list; 136, comparison_operator:"DE-BFP" in rec[meth_key]; 137, comment:# this is a pole to a plane; 138, block; 139, else_clause; 140, identifier:list; 141, argument_list; 142, comparison_operator:"DE-BFP" in rec[meth_key]; 143, comment:# this is a pole to a plane; 144, block; 145, else_clause; 146, augmented_assignment; 147, call; 148, augmented_assignment; 149, augmented_assignment; 150, augmented_assignment; 151, list; 152, attribute; 153, argument_list; 154, identifier:rec; 155, identifier:direction_type_key; 156, string_content:p; 157, augmented_assignment; 158, call; 159, expression_statement; 160, comment:# collect data for fisher calculation; 161, expression_statement; 162, expression_statement; 163, expression_statement; 164, expression_statement; 165, call; 166, string:"DE-BFP"; 167, subscript; 168, expression_statement; 169, expression_statement; 170, comment:# this is the "EL, EM, EN" array of MM88; 171, comment:# this is a line; 172, block; 173, call; 174, string:"DE-BFP"; 175, subscript; 176, expression_statement; 177, expression_statement; 178, comment:# this is the "EL, EM, EN" array of MM88; 179, comment:# this is a line; 180, block; 181, identifier:n_lines; 182, integer:1; 183, attribute; 184, argument_list; 185, subscript; 186, subscript; 187, subscript; 188, subscript; 189, subscript; 190, subscript; 191, call; 192, call; 193, identifier:rec; 194, identifier:keys; 195, identifier:n_planes; 196, integer:1; 197, attribute; 198, argument_list; 199, augmented_assignment; 200, call; 201, augmented_assignment; 202, augmented_assignment; 203, augmented_assignment; 204, attribute; 205, argument_list; 206, identifier:rec; 207, identifier:meth_key; 208, augmented_assignment; 209, call; 210, expression_statement; 211, comment:# collect data for fisher calculation; 212, expression_statement; 213, expression_statement; 214, expression_statement; 215, expression_statement; 216, attribute; 217, argument_list; 218, identifier:rec; 219, identifier:meth_key; 220, augmented_assignment; 221, call; 222, expression_statement; 223, comment:# collect data for fisher calculation; 224, expression_statement; 225, expression_statement; 226, expression_statement; 227, expression_statement; 228, identifier:fdata; 229, identifier:append; 230, list; 231, identifier:E; 232, integer:0; 233, identifier:cart; 234, integer:0; 235, identifier:E; 236, integer:1; 237, identifier:cart; 238, integer:1; 239, identifier:E; 240, integer:2; 241, identifier:cart; 242, integer:2; 243, identifier:float; 244, argument_list; 245, identifier:float; 246, argument_list; 247, identifier:L; 248, identifier:append; 249, identifier:cart; 250, identifier:n_lines; 251, integer:1; 252, attribute; 253, argument_list; 254, subscript; 255, subscript; 256, subscript; 257, subscript; 258, subscript; 259, subscript; 260, identifier:rec; 261, identifier:keys; 262, identifier:n_planes; 263, integer:1; 264, attribute; 265, argument_list; 266, augmented_assignment; 267, call; 268, augmented_assignment; 269, augmented_assignment; 270, augmented_assignment; 271, identifier:rec; 272, identifier:keys; 273, identifier:n_planes; 274, integer:1; 275, attribute; 276, argument_list; 277, augmented_assignment; 278, call; 279, augmented_assignment; 280, augmented_assignment; 281, augmented_assignment; 282, subscript; 283, subscript; 284, float:1.; 285, subscript; 286, subscript; 287, identifier:fdata; 288, identifier:append; 289, list; 290, identifier:E; 291, integer:0; 292, identifier:cart; 293, integer:0; 294, identifier:E; 295, integer:1; 296, identifier:cart; 297, integer:1; 298, identifier:E; 299, integer:2; 300, identifier:cart; 301, integer:2; 302, identifier:L; 303, identifier:append; 304, identifier:cart; 305, identifier:n_lines; 306, integer:1; 307, attribute; 308, argument_list; 309, subscript; 310, subscript; 311, subscript; 312, subscript; 313, subscript; 314, subscript; 315, identifier:L; 316, identifier:append; 317, identifier:cart; 318, identifier:n_lines; 319, integer:1; 320, attribute; 321, argument_list; 322, subscript; 323, subscript; 324, subscript; 325, subscript; 326, subscript; 327, subscript; 328, identifier:rec; 329, identifier:dec_key; 330, identifier:rec; 331, identifier:inc_key; 332, identifier:rec; 333, identifier:dec_key; 334, identifier:rec; 335, identifier:inc_key; 336, call; 337, call; 338, float:1.; 339, identifier:fdata; 340, identifier:append; 341, list; 342, identifier:E; 343, integer:0; 344, identifier:cart; 345, integer:0; 346, identifier:E; 347, integer:1; 348, identifier:cart; 349, integer:1; 350, identifier:E; 351, integer:2; 352, identifier:cart; 353, integer:2; 354, identifier:fdata; 355, identifier:append; 356, list; 357, identifier:E; 358, integer:0; 359, identifier:cart; 360, integer:0; 361, identifier:E; 362, integer:1; 363, identifier:cart; 364, integer:1; 365, identifier:E; 366, integer:2; 367, identifier:cart; 368, integer:2; 369, identifier:float; 370, argument_list; 371, identifier:float; 372, argument_list; 373, subscript; 374, subscript; 375, float:1.; 376, subscript; 377, subscript; 378, float:1.; 379, subscript; 380, subscript; 381, identifier:rec; 382, identifier:dec_key; 383, identifier:rec; 384, identifier:inc_key; 385, identifier:rec; 386, identifier:dec_key; 387, identifier:rec; 388, identifier:inc_key; 389, identifier:rec; 390, identifier:dec_key; 391, identifier:rec; 392, identifier:inc_key
code: def process_data_for_mean(data, direction_type_key):
      """
      takes list of dicts with dec and inc as well as direction_type if possible or method_codes and sorts the data into lines and planes and process it for fisher means
  
      @param: data - list of dicts with dec inc and some manner of PCA type info
      @param: direction_type_key - key that indicates the direction type variable in the dictionaries of data
      @return: tuple with values - (
                                  list of lists with [dec, inc, 1.] for all lines
                                  number of line
                                  list of lists with [EL,EM,EN] of all planes
                                  number of planes
                                  list of sum of the cartezian components of all lines
                                  )
      """
      dec_key, inc_key, meth_key = 'dec', 'inc', 'magic_method_codes'  # data model 2.5
      if 'dir_dec' in data[0].keys():  # this is data model 3.0
          dec_key, inc_key, meth_key = 'dir_dec', 'dir_inc', 'method_codes'
  
      n_lines, n_planes = 0, 0
      L, fdata = [], []
      E = [0, 0, 0]
  
      # sort data  into lines and planes and collect cartesian coordinates
      for rec in data:
          cart = dir2cart([float(rec[dec_key]), float(rec[inc_key])])[0]
          if direction_type_key in list(rec.keys()):
              if rec[direction_type_key] == 'p':  # this is a pole to a plane
                  n_planes += 1
                  L.append(cart)  # this is the "EL, EM, EN" array of MM88
              else:  # this is a line
                  n_lines += 1
                  # collect data for fisher calculation
                  fdata.append([float(rec[dec_key]), float(rec[inc_key]), 1.])
                  E[0] += cart[0]
                  E[1] += cart[1]
                  E[2] += cart[2]
          elif 'method_codes' in list(rec.keys()):
              if "DE-BFP" in rec[meth_key]:  # this is a pole to a plane
                  n_planes += 1
                  L.append(cart)  # this is the "EL, EM, EN" array of MM88
              else:  # this is a line
                  n_lines += 1
                  # collect data for fisher calculation
                  fdata.append([rec[dec_key], rec[inc_key], 1.])
                  E[0] += cart[0]
                  E[1] += cart[1]
                  E[2] += cart[2]
          elif meth_key in list(rec.keys()):
              if "DE-BFP" in rec[meth_key]:  # this is a pole to a plane
                  n_planes += 1
                  L.append(cart)  # this is the "EL, EM, EN" array of MM88
              else:  # this is a line
                  n_lines += 1
                  # collect data for fisher calculation
                  fdata.append([rec[dec_key], rec[inc_key], 1.])
                  E[0] += cart[0]
                  E[1] += cart[1]
                  E[2] += cart[2]
          else:
                  # EVERYTHING IS A LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              n_lines += 1
              # collect data for fisher calculation
              fdata.append([rec[dec_key], rec[inc_key], 1.])
              E[0] += cart[0]
              E[1] += cart[1]
              E[2] += cart[2]
  
      return fdata, n_lines, L, n_planes, E