code: def parse_plunge_bearing(plunge, bearing):
      
      bearing = parse_azimuth(bearing)
      plunge, direction = split_trailing_letters(plunge)
  
      if direction is not None:
          if opposite_end(bearing, direction):
              bearing +=180
  
      if plunge < 0:
          bearing += 180
          plunge = -plunge
      if plunge > 90:
          bearing += 180
          plunge = 180 - plunge
  
      if bearing > 360:
          bearing -= 360
  
      return plunge, bearing
docs: Parses strings of plunge and bearing and returns a consistent plunge and
      bearing measurement as floats. Plunge angles returned by this function will
      always be between 0 and 90.
  
      If no direction letter(s) is present, the plunge is assumed to be measured
      from the end specified by the bearing. If a direction letter(s) is present,
      the bearing will be switched to the opposite (180 degrees) end if the
      specified direction corresponds to the opposite end specified by the
      bearing.
  
      Parameters
      ----------
      plunge : string
          A plunge measurement.
      bearing : string
          A bearing measurement. May be in azimuth or quadrant format.
  
      Returns
      -------
      plunge, bearing: floats
          The plunge and bearing following the conventions outlined above.
  
      Examples
      ---------
  
          >>> parse_plunge_bearing("30NW", 160)
          ... (30, 340)