docs: def gauge_from_t(t, SI=True, schedule='BWG'):
      r'''Looks up the gauge of a given wire thickness of given schedule.
      Values are all non-linear, and tabulated internally.
  
      Parameters
      ----------
      t : float
          Thickness, [m]
      SI : bool, optional
          If False, requires that the thickness is given in inches not meters
      schedule : str
          Gauge schedule, one of 'BWG', 'AWG', 'SWG', 'MWG', 'BSWG', or 'SSWG'
  
      Returns
      -------
      gauge : float-like
          Wire Gauge, [-]
  
      Notes
      -----
      An internal variable, tol, is used in the selection of the wire gauge. If
      the next smaller wire gauge is within 10% of the difference between it and
      the previous wire gauge, the smaller wire gauge is selected. Accordingly,
      this function can return a gauge with a thickness smaller than desired
      in some circumstances.
  
      * Birmingham Wire Gauge (BWG) ranges from 0.2 (0.5 inch) to 36 (0.004 inch).
      * American Wire Gauge (AWG) ranges from 0.167 (0.58 inch) to 51 (0.00099
        inch). These are used for electrical wires.
      * Steel Wire Gauge (SWG) ranges from 0.143 (0.49 inch) to 51 (0.0044 inch).
        Also called Washburn & Moen wire gauge, American Steel gauge, Wire Co.
        gauge, and Roebling wire gauge.
      * Music Wire Gauge (MWG) ranges from 0.167 (0.004 inch) to 46 (0.18
        inch). Also called Piano Wire Gauge.
      * British Standard Wire Gage (BSWG) ranges from 0.143 (0.5 inch) to
        51 (0.001 inch). Also called Imperial Wire Gage (IWG).
      * Stub's Steel Wire Gage (SSWG) ranges from 1 (0.227 inch) to 80 (0.013 inch)
  
      Examples
      --------
      >>> gauge_from_t(.5, SI=False, schedule='BWG')
      0.2
  
      References
      ----------
      .. [1] Oberg, Erik, Franklin D. Jones, and Henry H. Ryffel. Machinery's
         Handbook. Industrial Press, Incorporated, 2012.
      '''
      tol = 0.1
      # Handle units
      if SI:
          t_inch = round(t/inch, 9) # all schedules are in inches
      else:
          t_inch = t
  
      # Get the schedule
      try:
          sch_integers, sch_inch, sch_SI, decreasing = wire_schedules[schedule]
      except:
          raise ValueError('Wire gauge schedule not found')
  
      # Check if outside limits
      sch_max, sch_min = sch_inch[0], sch_inch[-1]
      if t_inch > sch_max:
          raise ValueError('Input thickness is above the largest in the selected schedule')
  
  
      # If given thickness is exactly in the index, be happy
      if t_inch in sch_inch:
          gauge = sch_integers[sch_inch.index(t_inch)]
  
      else:
          for i in range(len(sch_inch)):
              if sch_inch[i] >= t_inch:
                  larger = sch_inch[i]
              else:
                  break
          if larger == sch_min:
              gauge = sch_min # If t is under the lowest schedule, be happy
          else:
              smaller = sch_inch[i]
              if (t_inch - smaller) <= tol*(larger - smaller):
                  gauge = sch_integers[i]
              else:
                  gauge = sch_integers[i-1]
      return gauge