original_docstring: Computes the bar length of a snapshot using either the point where the m=2 mode twists by phaselim,
      or the power in m=2/m=0 drops by fractional_m2 of its maximum.
docstring: Computes the bar length of a snapshot using either the point where the m=2 mode twists by phaselim,
  or the power in m=2/m=0 drops by fractional_m2 of its maximum.
docstring_tokens: Computes the bar length of a snapshot using either the point where the m = 2 mode twists by phaselim or the power in m = 2 / m = 0 drops by fractional_m2 of its maximum .
code: def barlen(snap, phaselim=None, fractional_m2=None, max_r=7):
      """Computes the bar length of a snapshot using either the point where the m=2 mode twists by phaselim,
      or the power in m=2/m=0 drops by fractional_m2 of its maximum."""
      barlens = ()
      rmid, surfdensft = bar_cyl_fft(snap)
      gd_i = (rmid < max_r)
  
      m2 = np.abs(surfdensft[gd_i, 2]) / np.abs(surfdensft[gd_i, 0])
      ifid = np.argmax(m2)
      if phaselim is not None:
          # ang = np.cumsum(-0.5*np.angle(surfdensft[:, 2], deg=True)) / np.arange(1, len(surfdensft[:, 2]) + 1)
          ang = -0.5 * np.angle(surfdensft[:, 2], deg=True)
          ang -= ang[ifid]
          barlens += (interplen(rmid, np.abs(ang), phaselim, ifid, 'lt'),)
      if fractional_m2 is not None:
          barlens += (interplen(rmid, m2 / m2[ifid], fractional_m2, ifid, 'gt'),)
      return barlens
code_tokens: def barlen ( snap , phaselim = None , fractional_m2 = None , max_r = 7 ) : barlens = ( ) rmid , surfdensft = bar_cyl_fft ( snap ) gd_i = ( rmid < max_r ) m2 = np . abs ( surfdensft [ gd_i , 2 ] ) / np . abs ( surfdensft [ gd_i , 0 ] ) ifid = np . argmax ( m2 ) if phaselim is not None : ang = - 0.5 * np . angle ( surfdensft [ : , 2 ] , deg = True ) ang -= ang [ ifid ] barlens += ( interplen ( rmid , np . abs ( ang ) , phaselim , ifid , 'lt' ) , ) if fractional_m2 is not None : barlens += ( interplen ( rmid , m2 / m2 [ ifid ] , fractional_m2 , ifid , 'gt' ) , ) return barlens
short_docstring: Computes the bar length of a snapshot using either the point where the m=2 mode twists by phaselim,
  or the power in m=2/m=0 drops by fractional_m2 of its maximum.
short_docstring_tokens: Computes the bar length of a snapshot using either the point where the m = 2 mode twists by phaselim or the power in m = 2 / m = 0 drops by fractional_m2 of its maximum .
comment: """Computes the bar length of a snapshot using either the point where the m=2 mode twists by phaselim,
      or the power in m=2/m=0 drops by fractional_m2 of its maximum."""$SEP$# ang = np.cumsum(-0.5*np.angle(surfdensft[:, 2], deg=True)) / np.arange(1, len(surfdensft[:, 2]) + 1)