code: def RZToverticalPotential(RZPot,R):
      
      RZPot= flatten(RZPot)
      if _APY_LOADED and isinstance(R,units.Quantity):
          if hasattr(RZPot,'_ro'):
              R= R.to(units.kpc).value/RZPot._ro
          else:
              R= R.to(units.kpc).value/RZPot[0]._ro
      if isinstance(RZPot,list):
          out= []
          for pot in RZPot:
              if isinstance(pot,linearPotential):
                  out.append(pot)
              elif isinstance(pot,Potential):
                  out.append(verticalPotential(pot,R))
              elif isinstance(pot,planarPotential):
                  raise PotentialError("Input to 'RZToverticalPotential' cannot be a planarPotential")
              else:
                  raise PotentialError("Input to 'RZToverticalPotential' is neither an RZPotential-instance or a list of such instances")
          return out
      elif isinstance(RZPot,Potential):
          return verticalPotential(RZPot,R)
      elif isinstance(RZPot,linearPotential):
          return RZPot
      elif isinstance(RZPot,planarPotential):
          raise PotentialError("Input to 'RZToverticalPotential' cannot be a planarPotential")
      else:
          raise PotentialError("Input to 'RZToverticalPotential' is neither an RZPotential-instance or a list of such instances")
docs: NAME:
  
         RZToverticalPotential
  
      PURPOSE:
  
         convert a RZPotential to a vertical potential at a given R
  
      INPUT:
  
         RZPot - RZPotential instance or list of such instances
  
         R - Galactocentric radius at which to evaluate the vertical potential (can be Quantity)
  
      OUTPUT:
  
         (list of) linearPotential instance(s)
  
      HISTORY:
  
         2010-07-21 - Written - Bovy (NYU)