original_docstring: Takes fft in the phi direction in each radial bin. Bins in the fi direction using phibins. Returns list of ffts
      each weighted by respective weights (None corresponds to by mass.)
docstring: Takes fft in the phi direction in each radial bin. Bins in the fi direction using phibins. Returns list of ffts
  each weighted by respective weights (None corresponds to by mass.)
docstring_tokens: Takes fft in the phi direction in each radial bin . Bins in the fi direction using phibins . Returns list of ffts each weighted by respective weights ( None corresponds to by mass . )
code: def bar_cyl_fft(snap, rbins=None, phibins=None, weights=(None,)):
      """Takes fft in the phi direction in each radial bin. Bins in the fi direction using phibins. Returns list of ffts
      each weighted by respective weights (None corresponds to by mass.)"""
      if rbins is None:
          rbins = np.linspace(0., 10, 50)
      if phibins is None:
          phibins = np.linspace(-math.pi, math.pi, 361)
  
      rcyl = torch.norm(snap.positions[:, 0:2], dim=-1)
      phi = torch.atan2(snap.positions[:, 1], snap.positions[:, 0])
  
      ft_out = []
      for weight in weights:
          if weight is None:
              totalweight = snap.masses
          else:
              totalweight = snap.masses * weight
          h, redges, phiedges = np.histogram2d(rcyl.detach().cpu().numpy(),
                                               phi.detach().cpu().numpy(),
                                               (rbins, phibins),
                                               weights=totalweight.detach().cpu().numpy())
          area = 0.5 * (redges[1:, np.newaxis] ** 2 - redges[:-1, np.newaxis] ** 2) * \
              (phiedges[np.newaxis, 1:] - phiedges[np.newaxis, :-1])
          surfdens = h / area
          ft_out += [np.fft.fft(surfdens, axis=1)]
      if len(ft_out) == 1:
          ft_out = ft_out[0]
      rmid = 0.5 * (redges[:-1] + redges[1:])
  
      return rmid, ft_out
code_tokens: def bar_cyl_fft ( snap , rbins = None , phibins = None , weights = ( None , ) ) : if rbins is None : rbins = np . linspace ( 0. , 10 , 50 ) if phibins is None : phibins = np . linspace ( - math . pi , math . pi , 361 ) rcyl = torch . norm ( snap . positions [ : , 0 : 2 ] , dim = - 1 ) phi = torch . atan2 ( snap . positions [ : , 1 ] , snap . positions [ : , 0 ] ) ft_out = [ ] for weight in weights : if weight is None : totalweight = snap . masses else : totalweight = snap . masses * weight h , redges , phiedges = np . histogram2d ( rcyl . detach ( ) . cpu ( ) . numpy ( ) , phi . detach ( ) . cpu ( ) . numpy ( ) , ( rbins , phibins ) , weights = totalweight . detach ( ) . cpu ( ) . numpy ( ) ) area = 0.5 * ( redges [ 1 : , np . newaxis ] ** 2 - redges [ : - 1 , np . newaxis ] ** 2 ) * ( phiedges [ np . newaxis , 1 : ] - phiedges [ np . newaxis , : - 1 ] ) surfdens = h / area ft_out += [ np . fft . fft ( surfdens , axis = 1 ) ] if len ( ft_out ) == 1 : ft_out = ft_out [ 0 ] rmid = 0.5 * ( redges [ : - 1 ] + redges [ 1 : ] ) return rmid , ft_out
short_docstring: Takes fft in the phi direction in each radial bin.
short_docstring_tokens: Takes fft in the phi direction in each radial bin .
comment: """Takes fft in the phi direction in each radial bin. Bins in the fi direction using phibins. Returns list of ffts
      each weighted by respective weights (None corresponds to by mass.)"""