code: def lindbladR(Pot,OmegaP,m=2,**kwargs):
      
      Pot= flatten(Pot)
      if _APY_LOADED and isinstance(OmegaP,units.Quantity):
          if hasattr(Pot,'_ro'):
              OmegaP= OmegaP.to(1/units.Gyr).value/freq_in_Gyr(Pot._vo,Pot._ro)
          elif hasattr(Pot[0],'_ro'):
              OmegaP= OmegaP.to(1/units.Gyr).value\
                  /freq_in_Gyr(Pot[0]._vo,Pot[0]._ro)
      if isinstance(m,str):
          if 'corot' in m.lower():
              corotation= True
          else:
              raise IOError("'m' input not recognized, should be an integer or 'corotation'")
      else:
          corotation= False
      if corotation:
          try:
              out= optimize.brentq(_corotationR_eq,0.0000001,1000.,
                                   args=(Pot,OmegaP),**kwargs)
          except ValueError:
              return None
          except RuntimeError: #pragma: no cover 
              raise
          return out
      else:
          try:
              out= optimize.brentq(_lindbladR_eq,0.0000001,1000.,
                                   args=(Pot,OmegaP,m),**kwargs)
          except ValueError:
              return None
          except RuntimeError: #pragma: no cover 
              raise
          return out
docs: NAME:
  
         lindbladR
  
      PURPOSE:
  
         calculate the radius of a Lindblad resonance
  
      INPUT:
  
         Pot - Potential instance or list of such instances
  
         OmegaP - pattern speed (can be Quantity)
  
         m= order of the resonance (as in m(O-Op)=kappa (negative m for outer)
            use m='corotation' for corotation
         +scipy.optimize.brentq xtol,rtol,maxiter kwargs
  
      OUTPUT:
  
         radius of Linblad resonance, None if there is no resonance
  
      HISTORY:
  
         2011-10-09 - Written - Bovy (IAS)