nodes: 0, module; 1, function_definition; 2, function_name:rotation; 3, parameters; 4, block; 5, identifier:f; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, identifier:line; 17, string; 18, comment:""" Find rotation of the survey
  
      Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
  
      The clock-wise rotation is defined as the angle in radians between line
      given by the first and last trace of the first line and the axis that gives
      increasing CDP-Y, in the direction that gives increasing CDP-X.
  
      By default, the first line is the 'fast' direction, which is inlines if the
      file is inline sorted, and crossline if it's crossline sorted.
  
  
      Parameters
      ----------
  
      f : SegyFile
      line : { 'fast', 'slow', 'iline', 'xline' }
  
      Returns
      -------
  
      rotation : float
      cdpx : int
      cdpy : int
  
  
      Notes
      -----
  
      .. versionadded:: 1.2
  
      """; 19, attribute; 20, block; 21, assignment; 22, comparison_operator:line not in lines; 23, block; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, expression_list; 29, string_content:fast; 30, identifier:f; 31, identifier:unstructured; 32, raise_statement; 33, identifier:lines; 34, dictionary; 35, identifier:line; 36, identifier:lines; 37, expression_statement; 38, expression_statement; 39, raise_statement; 40, identifier:l; 41, subscript; 42, identifier:origin; 43, subscript; 44, pattern_list; 45, expression_list; 46, identifier:rot; 47, call; 48, identifier:rot; 49, identifier:cdpx; 50, identifier:cdpy; 51, call; 52, pair; 53, pair; 54, pair; 55, pair; 56, assignment; 57, assignment; 58, call; 59, identifier:lines; 60, identifier:line; 61, subscript; 62, attribute; 63, attribute; 64, identifier:cdpx; 65, identifier:cdpy; 66, subscript; 67, subscript; 68, attribute; 69, argument_list; 70, identifier:ValueError; 71, argument_list; 72, string; 73, attribute; 74, string; 75, attribute; 76, string; 77, attribute; 78, string; 79, attribute; 80, identifier:error; 81, call; 82, identifier:solution; 83, call; 84, identifier:ValueError; 85, argument_list; 86, attribute; 87, integer:0; 88, attribute; 89, identifier:cdpx; 90, attribute; 91, identifier:cdpy; 92, identifier:origin; 93, attribute; 94, identifier:origin; 95, attribute; 96, attribute; 97, identifier:rotation; 98, call; 99, attribute; 100, call; 101, call; 102, string:"Rotation requires a structured file"; 103, string_content:fast; 104, identifier:f; 105, identifier:fast; 106, string_content:slow; 107, identifier:f; 108, identifier:slow; 109, string_content:iline; 110, identifier:f; 111, identifier:iline; 112, string_content:xline; 113, identifier:f; 114, identifier:xline; 115, attribute; 116, argument_list; 117, attribute; 118, argument_list; 119, call; 120, identifier:f; 121, identifier:header; 122, identifier:segyio; 123, identifier:su; 124, identifier:segyio; 125, identifier:su; 126, attribute; 127, identifier:cdpx; 128, attribute; 129, identifier:cdpy; 130, identifier:f; 131, identifier:xfd; 132, identifier:len; 133, argument_list; 134, identifier:l; 135, identifier:stride; 136, identifier:len; 137, argument_list; 138, attribute; 139, argument_list; 140, string:"Unknown line {}"; 141, identifier:format; 142, identifier:line; 143, string:"Must be any of: {}"; 144, identifier:format; 145, call; 146, attribute; 147, argument_list; 148, identifier:segyio; 149, identifier:su; 150, identifier:segyio; 151, identifier:su; 152, identifier:l; 153, attribute; 154, identifier:np; 155, identifier:fromiter; 156, call; 157, keyword_argument; 158, attribute; 159, argument_list; 160, string; 161, identifier:format; 162, identifier:error; 163, identifier:solution; 164, identifier:f; 165, identifier:offsets; 166, attribute; 167, argument_list; 168, identifier:dtype; 169, attribute; 170, string; 171, identifier:join; 172, call; 173, string_content:{} {}; 174, identifier:l; 175, identifier:keys; 176, identifier:np; 177, identifier:intc; 178, string_content:; 179, attribute; 180, argument_list; 181, identifier:lines; 182, identifier:keys
code: def rotation(f, line = 'fast'):
      """ Find rotation of the survey
  
      Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
  
      The clock-wise rotation is defined as the angle in radians between line
      given by the first and last trace of the first line and the axis that gives
      increasing CDP-Y, in the direction that gives increasing CDP-X.
  
      By default, the first line is the 'fast' direction, which is inlines if the
      file is inline sorted, and crossline if it's crossline sorted.
  
  
      Parameters
      ----------
  
      f : SegyFile
      line : { 'fast', 'slow', 'iline', 'xline' }
  
      Returns
      -------
  
      rotation : float
      cdpx : int
      cdpy : int
  
  
      Notes
      -----
  
      .. versionadded:: 1.2
  
      """
  
      if f.unstructured:
          raise ValueError("Rotation requires a structured file")
  
      lines = { 'fast': f.fast,
                'slow': f.slow,
                'iline': f.iline,
                'xline': f.xline,
              }
  
      if line not in lines:
          error = "Unknown line {}".format(line)
          solution = "Must be any of: {}".format(' '.join(lines.keys()))
          raise ValueError('{} {}'.format(error, solution))
  
      l = lines[line]
      origin = f.header[0][segyio.su.cdpx, segyio.su.cdpy]
      cdpx, cdpy = origin[segyio.su.cdpx], origin[segyio.su.cdpy]
  
      rot = f.xfd.rotation( len(l),
                            l.stride,
                            len(f.offsets),
                            np.fromiter(l.keys(), dtype = np.intc) )
      return rot, cdpx, cdpy