original_docstring: Plot beamformer weights from a number of beamformer solutions.
  
      Parameters
      ----------
      beamformer_names : list(str)
          The postfixes of the beamformer weight files to plot. Will open
          beamformer_weights_corr??_`beamformer_name`.dat for each item in
          beamformer_names.
      corrlist : list(int)
          The corrnode numbers.
      antennas_to_plot : list(int)
          The names of the antennas to plot. Defaults to `antennas`.
      antennas : list(int)
          The names of the antennas in the beamformer weight files. Defaults to
          list in dsautils.cnf
      outname : str
          The prefix of the file to save the plot to. If None, no figure is saved.
      pols : list(str)
          The order of the pols in the beamformer weight files.
      show : bool
          If False, the plot is closed after saving.
      gaindir : str
          The directory in which the beamformer weight files are saved.
  
      Returns
      -------
      ndarray
          The beamformer weights.
      
docstring: Plot beamformer weights from a number of beamformer solutions.
  Parameters
  
  beamformer_names : list(str)
  The postfixes of the beamformer weight files to plot.
  
  Returns
  
  ndarray
  The beamformer weights.
docstring_tokens: Plot beamformer weights from a number of beamformer solutions . Parameters beamformer_names : list ( str ) The postfixes of the beamformer weight files to plot . Returns ndarray The beamformer weights .
code: def plot_beamformer_weights(
          beamformer_names,
          corrlist=np.arange(1, 16+1),
          antennas_to_plot=None,
          antennas=None,
          outname=None,
          pols=None,
          show=True,
          gaindir='/home/user/beamformer_weights/'
  ):
      """Plot beamformer weights from a number of beamformer solutions.
  
      Parameters
      ----------
      beamformer_names : list(str)
          The postfixes of the beamformer weight files to plot. Will open
          beamformer_weights_corr??_`beamformer_name`.dat for each item in
          beamformer_names.
      corrlist : list(int)
          The corrnode numbers.
      antennas_to_plot : list(int)
          The names of the antennas to plot. Defaults to `antennas`.
      antennas : list(int)
          The names of the antennas in the beamformer weight files. Defaults to
          list in dsautils.cnf
      outname : str
          The prefix of the file to save the plot to. If None, no figure is saved.
      pols : list(str)
          The order of the pols in the beamformer weight files.
      show : bool
          If False, the plot is closed after saving.
      gaindir : str
          The directory in which the beamformer weight files are saved.
  
      Returns
      -------
      ndarray
          The beamformer weights.
      """
      if pols is None:
          pols = ['B', 'A']
      if antennas is None:
          antennas = np.array(list(CONF.get('corr')['antenna_order'].values()))
      assert len(antennas) == 64
      if antennas_to_plot is None:
          antennas_to_plot = antennas
      # Set shape of the figure
      nplots = 4
      nx = 5
      ny = len(antennas_to_plot)//nx
      if len(antennas_to_plot)%nx != 0:
          ny += 1
      gains = np.zeros(
          (len(beamformer_names), len(antennas), len(corrlist), 48, 2),
          dtype=np.complex
      )
      for i, beamformer_name in enumerate(beamformer_names):
          for corridx, corr in enumerate(corrlist):
              with open(
                      '{0}/beamformer_weights_corr{1:02d}_{2}.dat'.format(
                          gaindir,
                          corr,
                          beamformer_name
                      ),
                      'rb'
              ) as f:
                  data = np.fromfile(f, '<f4')
              temp = data[64:].reshape(64, 48, 2, 2)
              gains[i, :, corridx, :, :] = temp[..., 0]+1.0j*temp[..., 1]
      gains = gains.reshape(
          (len(beamformer_names), len(antennas), len(corrlist)*48, 2)
      )
      #ymax = np.nanmax(np.log10(np.abs(gains)))
      #ymin = np.nanmin(np.log10(np.abs(gains)))
      # Phase, polarization B
      _fig, ax = plt.subplots(
          nplots*ny,
          nx,
          figsize=(6*nx, 2.5*ny*nplots),
          sharex=True,
          sharey=False
      )
      for axi in ax[-1, :]:
          axi.set_xlabel('freq channel')
      for nplot in range(nplots):
          polidx = nplot%2
          angle = nplot//2
          axi = ax[ny*nplot:ny*(nplot+1), :]
          for axii in axi[:, 0]:
              axii.set_ylabel('phase (rad)' if angle else 'amplitude (arb)')
          axi = axi.flatten()
          for i, ant in enumerate(antennas_to_plot):
              for bnidx, beamformer_name in enumerate(beamformer_names):
                  idx = np.where(antennas == ant)[0][0]
                  axi[i].plot(
                      np.angle(gains[bnidx, idx, :, polidx]) if angle else \
                          np.abs(gains[bnidx, idx, :, polidx]),
                      alpha=0.4,
                      ls='None',
                      marker='.',
                      label=beamformer_name
                  )
                  axi[i].set_title('{0} {1}: {2}'.format(
                      ant, pols[polidx], 'phase' if angle else 'amp'
                  ))
              if angle:
                  axi[i].set_ylim(-np.pi, np.pi)
              #else:
              #    axi[i].set_ylim(ymin, ymax)
          axi[0].legend()
  
      if outname is not None:
          plt.savefig('{0}_averagedweights.png'.format(outname))
      if not show:
          plt.close()
      return gains
code_tokens: def plot_beamformer_weights ( beamformer_names , corrlist = np . arange ( 1 , 16 + 1 ) , antennas_to_plot = None , antennas = None , outname = None , pols = None , show = True , gaindir = '/home/user/beamformer_weights/' ) : if pols is None : pols = [ 'B' , 'A' ] if antennas is None : antennas = np . array ( list ( CONF . get ( 'corr' ) [ 'antenna_order' ] . values ( ) ) ) assert len ( antennas ) == 64 if antennas_to_plot is None : antennas_to_plot = antennas nplots = 4 nx = 5 ny = len ( antennas_to_plot ) // nx if len ( antennas_to_plot ) % nx != 0 : ny += 1 gains = np . zeros ( ( len ( beamformer_names ) , len ( antennas ) , len ( corrlist ) , 48 , 2 ) , dtype = np . complex ) for i , beamformer_name in enumerate ( beamformer_names ) : for corridx , corr in enumerate ( corrlist ) : with open ( '{0}/beamformer_weights_corr{1:02d}_{2}.dat' . format ( gaindir , corr , beamformer_name ) , 'rb' ) as f : data = np . fromfile ( f , '<f4' ) temp = data [ 64 : ] . reshape ( 64 , 48 , 2 , 2 ) gains [ i , : , corridx , : , : ] = temp [ ... , 0 ] + 1.0j * temp [ ... , 1 ] gains = gains . reshape ( ( len ( beamformer_names ) , len ( antennas ) , len ( corrlist ) * 48 , 2 ) ) _fig , ax = plt . subplots ( nplots * ny , nx , figsize = ( 6 * nx , 2.5 * ny * nplots ) , sharex = True , sharey = False ) for axi in ax [ - 1 , : ] : axi . set_xlabel ( 'freq channel' ) for nplot in range ( nplots ) : polidx = nplot % 2 angle = nplot // 2 axi = ax [ ny * nplot : ny * ( nplot + 1 ) , : ] for axii in axi [ : , 0 ] : axii . set_ylabel ( 'phase (rad)' if angle else 'amplitude (arb)' ) axi = axi . flatten ( ) for i , ant in enumerate ( antennas_to_plot ) : for bnidx , beamformer_name in enumerate ( beamformer_names ) : idx = np . where ( antennas == ant ) [ 0 ] [ 0 ] axi [ i ] . plot ( np . angle ( gains [ bnidx , idx , : , polidx ] ) if angle else np . abs ( gains [ bnidx , idx , : , polidx ] ) , alpha = 0.4 , ls = 'None' , marker = '.' , label = beamformer_name ) axi [ i ] . set_title ( '{0} {1}: {2}' . format ( ant , pols [ polidx ] , 'phase' if angle else 'amp' ) ) if angle : axi [ i ] . set_ylim ( - np . pi , np . pi ) axi [ 0 ] . legend ( ) if outname is not None : plt . savefig ( '{0}_averagedweights.png' . format ( outname ) ) if not show : plt . close ( ) return gains
short_docstring: Plot beamformer weights from a number of beamformer solutions.
short_docstring_tokens: Plot beamformer weights from a number of beamformer solutions .
comment: """Plot beamformer weights from a number of beamformer solutions.
  
      Parameters
      ----------
      beamformer_names : list(str)
          The postfixes of the beamformer weight files to plot. Will open
          beamformer_weights_corr??_`beamformer_name`.dat for each item in
          beamformer_names.
      corrlist : list(int)
          The corrnode numbers.
      antennas_to_plot : list(int)
          The names of the antennas to plot. Defaults to `antennas`.
      antennas : list(int)
          The names of the antennas in the beamformer weight files. Defaults to
          list in dsautils.cnf
      outname : str
          The prefix of the file to save the plot to. If None, no figure is saved.
      pols : list(str)
          The order of the pols in the beamformer weight files.
      show : bool
          If False, the plot is closed after saving.
      gaindir : str
          The directory in which the beamformer weight files are saved.
  
      Returns
      -------
      ndarray
          The beamformer weights.
      """$SEP$# Set shape of the figure$SEP$#ymax = np.nanmax(np.log10(np.abs(gains)))$SEP$#ymin = np.nanmin(np.log10(np.abs(gains)))$SEP$# Phase, polarization B$SEP$#else:$SEP$#    axi[i].set_ylim(ymin, ymax)