nodes: 0, module; 1, function_definition; 2, function_name:get_tdata; 3, parameters; 4, block; 5, identifier:t_format; 6, identifier:files; 7, expression_statement; 8, function_definition; 9, import_statement; 10, import_from_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, expression_statement; 15, for_statement; 16, expression_statement; 17, comment:# sort according to time; 18, expression_statement; 19, expression_statement; 20, return_statement; 21, comment:"""
      Get the time information from file names
  
      Parameters
      ----------
      t_format: str
          The string that can be used to get the time information in the files.
          Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but
          not non-numeric strings like %b, etc. See [1]_ for the datetime format
          strings
      files: list of str
          The that contain the time informations
  
      Returns
      -------
      pandas.Index
          The time coordinate
      list of str
          The file names as they are sorten in the returned index
  
      References
      ----------
      .. [1] https://docs.python.org/2/library/datetime.html"""; 22, function_name:median; 23, parameters; 24, block; 25, dotted_name; 26, dotted_name; 27, dotted_name; 28, assignment; 29, pattern_list; 30, call; 31, block; 32, assignment; 33, assignment; 34, pattern_list; 35, call; 36, block; 37, assignment; 38, assignment; 39, assignment; 40, expression_list; 41, identifier:arr; 42, return_statement; 43, identifier:re; 44, identifier:pandas; 45, identifier:Index; 46, identifier:t_pattern; 47, identifier:t_format; 48, identifier:fmt; 49, identifier:patt; 50, attribute; 51, argument_list; 52, expression_statement; 53, identifier:t_pattern; 54, call; 55, identifier:time; 56, call; 57, identifier:i; 58, identifier:f; 59, identifier:enumerate; 60, argument_list; 61, expression_statement; 62, identifier:ind; 63, call; 64, identifier:files; 65, subscript; 66, identifier:time; 67, subscript; 68, call; 69, identifier:files; 70, binary_operator:arr.min() + (arr.max() - arr.min())/2; 71, identifier:t_patterns; 72, identifier:items; 73, assignment; 74, attribute; 75, argument_list; 76, identifier:list; 77, argument_list; 78, identifier:files; 79, assignment; 80, attribute; 81, argument_list; 82, call; 83, identifier:ind; 84, call; 85, identifier:ind; 86, identifier:to_datetime; 87, argument_list; 88, call; 89, binary_operator:(arr.max() - arr.min())/2; 90, identifier:t_pattern; 91, call; 92, identifier:re; 93, identifier:compile; 94, identifier:t_pattern; 95, call; 96, subscript; 97, call; 98, identifier:np; 99, identifier:argsort; 100, identifier:time; 101, attribute; 102, argument_list; 103, attribute; 104, argument_list; 105, call; 106, attribute; 107, argument_list; 108, parenthesized_expression; 109, integer:2; 110, attribute; 111, argument_list; 112, identifier:range; 113, argument_list; 114, identifier:time; 115, identifier:i; 116, identifier:median; 117, argument_list; 118, identifier:np; 119, identifier:array; 120, identifier:files; 121, identifier:np; 122, identifier:array; 123, identifier:time; 124, identifier:Index; 125, argument_list; 126, identifier:arr; 127, identifier:min; 128, binary_operator:arr.max() - arr.min(); 129, identifier:t_pattern; 130, identifier:replace; 131, identifier:fmt; 132, identifier:patt; 133, call; 134, call; 135, identifier:time; 136, keyword_argument; 137, call; 138, call; 139, identifier:len; 140, argument_list; 141, attribute; 142, argument_list; 143, identifier:name; 144, string; 145, attribute; 146, argument_list; 147, attribute; 148, argument_list; 149, identifier:files; 150, identifier:np; 151, identifier:array; 152, call; 153, string_content:time; 154, identifier:arr; 155, identifier:max; 156, identifier:arr; 157, identifier:min; 158, identifier:list; 159, argument_list; 160, call; 161, identifier:map; 162, argument_list; 163, lambda; 164, call; 165, lambda_parameters; 166, call; 167, attribute; 168, argument_list; 169, identifier:s; 170, attribute; 171, argument_list; 172, identifier:t_pattern; 173, identifier:findall; 174, identifier:f; 175, identifier:np; 176, identifier:datetime64; 177, call; 178, attribute; 179, argument_list; 180, attribute; 181, identifier:strptime; 182, identifier:s; 183, identifier:t_format; 184, identifier:dt; 185, identifier:datetime
code: def get_tdata(t_format, files):
      """
      Get the time information from file names
  
      Parameters
      ----------
      t_format: str
          The string that can be used to get the time information in the files.
          Any numeric datetime format string (e.g. %Y, %m, %H) can be used, but
          not non-numeric strings like %b, etc. See [1]_ for the datetime format
          strings
      files: list of str
          The that contain the time informations
  
      Returns
      -------
      pandas.Index
          The time coordinate
      list of str
          The file names as they are sorten in the returned index
  
      References
      ----------
      .. [1] https://docs.python.org/2/library/datetime.html"""
      def median(arr):
          return arr.min() + (arr.max() - arr.min())/2
      import re
      from pandas import Index
      t_pattern = t_format
      for fmt, patt in t_patterns.items():
          t_pattern = t_pattern.replace(fmt, patt)
      t_pattern = re.compile(t_pattern)
      time = list(range(len(files)))
      for i, f in enumerate(files):
          time[i] = median(np.array(list(map(
              lambda s: np.datetime64(dt.datetime.strptime(s, t_format)),
              t_pattern.findall(f)))))
      ind = np.argsort(time)  # sort according to time
      files = np.array(files)[ind]
      time = np.array(time)[ind]
      return to_datetime(Index(time, name='time')), files