original_docstring: r"""Plots the bandpass calibration solutions in the bcal table.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set. Used to identify the calibration table
          to plot.
      calname : str
          The name of the calibrator used in calibration. The calibration table
          `msname`\_`calname`\_bcal is opened.
      plabels : list
          The labels for the polarizations.  Defaults ``['A', 'B']``.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_bandpass.png if an `outname` is not set to
          ``None``. If `outname` is set to ``None``, the plot is not saved.
          Defaults ``None``.
      show : boolean
          If set to ``False``, the plot is closed after it is generated.
  
      Returns
      -------
      bpass : ndarray
          The bandpass solutions, dimensions (antenna or baseline, frequency).
      fobs : array
          The frequencies at which the bandpass solutions are calculated, in GHz.
      labels : ndarray
          The antenna or baseline labels along the 0th axis of the bandpass
          solutions.
      
docstring: r"""Plots the bandpass calibration solutions in the bcal table.
  Parameters
  
  msname : str
  The name of the measurement set. Used to identify the calibration table
  to plot.
  calname : str
  The name of the calibrator used in calibration. The calibration table
  `msname`\_`calname`\_bcal is opened.
  plabels : list
  The labels for the polarizations.
  
  Returns
  
  bpass : ndarray
  The bandpass solutions, dimensions (antenna or baseline, frequency).
  fobs : array
  The frequencies at which the bandpass solutions are calculated, in GHz.
  labels : ndarray
  The antenna or baseline labels along the 0th axis of the bandpass
  solutions.
docstring_tokens: r " " " Plots the bandpass calibration solutions in the bcal table . Parameters msname : str The name of the measurement set . Used to identify the calibration table to plot . calname : str The name of the calibrator used in calibration . The calibration table ` msname ` \ _ ` calname ` \ _bcal is opened . plabels : list The labels for the polarizations . Returns bpass : ndarray The bandpass solutions dimensions ( antenna or baseline frequency ) . fobs : array The frequencies at which the bandpass solutions are calculated in GHz . labels : ndarray The antenna or baseline labels along the 0th axis of the bandpass solutions .
code: def plot_bandpass(msname, calname,
                    plabels=None, outname=None, show=True):
      r"""Plots the bandpass calibration solutions in the bcal table.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set. Used to identify the calibration table
          to plot.
      calname : str
          The name of the calibrator used in calibration. The calibration table
          `msname`\_`calname`\_bcal is opened.
      plabels : list
          The labels for the polarizations.  Defaults ``['A', 'B']``.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_bandpass.png if an `outname` is not set to
          ``None``. If `outname` is set to ``None``, the plot is not saved.
          Defaults ``None``.
      show : boolean
          If set to ``False``, the plot is closed after it is generated.
  
      Returns
      -------
      bpass : ndarray
          The bandpass solutions, dimensions (antenna or baseline, frequency).
      fobs : array
          The frequencies at which the bandpass solutions are calculated, in GHz.
      labels : ndarray
          The antenna or baseline labels along the 0th axis of the bandpass
          solutions.
      """
      if plabels is None:
          plabels = ['A', 'B']
  
      bpass, _tbpass, _flags, ant1, ant2 = read_caltable('{0}_{1}_bcal'.format(
          msname, calname), cparam=True)
      # squeeze along the time axis
      # baseline, time, spw, frequency, pol
      bpass = bpass.squeeze(axis=1)
      bpass = bpass.reshape(bpass.shape[0], -1, bpass.shape[-1])
      npol = bpass.shape[-1]
  
      with table('{0}.ms/SPECTRAL_WINDOW'.format(msname)) as tb:
          fobs = (np.array(tb.col('CHAN_FREQ')[:])/1e9).reshape(-1)
  
      if bpass.shape[1] != fobs.shape[0]:
          nint = fobs.shape[0]//bpass.shape[1]
          fobs_plot = np.mean(fobs[:nint]) + \
              np.arange(bpass.shape[1])*np.median(np.diff(fobs))*nint
      else:
          fobs_plot = fobs.copy()
  
      if np.all(ant2 == ant2[0]):
          labels = ant1+1
      else:
          labels = np.array([ant1+1, ant2+1]).T
      nant = len(ant1)
  
      idxs_to_plot = np.where(np.abs(np.abs(bpass).reshape(nant, -1).mean(1)-1) >
                              1e-5)[0]
  
      ccyc = plt.rcParams['axes.prop_cycle'].by_key()['color']
      lcyc = ['-', ':']
      _, ax = plt.subplots(1, 2, figsize=(16, 6), sharex=True)
      for i, bidx in enumerate(idxs_to_plot):
          for pidx in range(npol):
              ax[0].plot(fobs_plot, np.abs(bpass[bidx, :, pidx]), '.',
                         label='{0} {1}'.format(labels[bidx], plabels[pidx]),
                         alpha=0.5, ls=lcyc[pidx], color=ccyc[i%len(ccyc)])
              ax[1].plot(fobs_plot, np.angle(bpass[bidx, :, pidx]), '.',
                         label='{0} {1}'.format(labels[bidx], plabels[pidx]),
                         alpha=0.5, ls=lcyc[pidx], color=ccyc[i%len(ccyc)])
      ax[0].set_xlabel('freq (GHz)')
      ax[1].set_xlabel('freq (GHz)')
      ax[0].set_ylabel('B cal amp')
      ax[1].set_ylabel('B cal phase (rad)')
      ax[0].legend(ncol=3, fontsize='small')
      if outname is not None:
          plt.savefig('{0}_bandpass.png'.format(outname), bbox_inches='tight')
      if not show:
          plt.close()
  
      return bpass, fobs, labels
code_tokens: def plot_bandpass ( msname , calname , plabels = None , outname = None , show = True ) : if plabels is None : plabels = [ 'A' , 'B' ] bpass , _tbpass , _flags , ant1 , ant2 = read_caltable ( '{0}_{1}_bcal' . format ( msname , calname ) , cparam = True ) bpass = bpass . squeeze ( axis = 1 ) bpass = bpass . reshape ( bpass . shape [ 0 ] , - 1 , bpass . shape [ - 1 ] ) npol = bpass . shape [ - 1 ] with table ( '{0}.ms/SPECTRAL_WINDOW' . format ( msname ) ) as tb : fobs = ( np . array ( tb . col ( 'CHAN_FREQ' ) [ : ] ) / 1e9 ) . reshape ( - 1 ) if bpass . shape [ 1 ] != fobs . shape [ 0 ] : nint = fobs . shape [ 0 ] // bpass . shape [ 1 ] fobs_plot = np . mean ( fobs [ : nint ] ) + np . arange ( bpass . shape [ 1 ] ) * np . median ( np . diff ( fobs ) ) * nint else : fobs_plot = fobs . copy ( ) if np . all ( ant2 == ant2 [ 0 ] ) : labels = ant1 + 1 else : labels = np . array ( [ ant1 + 1 , ant2 + 1 ] ) . T nant = len ( ant1 ) idxs_to_plot = np . where ( np . abs ( np . abs ( bpass ) . reshape ( nant , - 1 ) . mean ( 1 ) - 1 ) > 1e-5 ) [ 0 ] ccyc = plt . rcParams [ 'axes.prop_cycle' ] . by_key ( ) [ 'color' ] lcyc = [ '-' , ':' ] _ , ax = plt . subplots ( 1 , 2 , figsize = ( 16 , 6 ) , sharex = True ) for i , bidx in enumerate ( idxs_to_plot ) : for pidx in range ( npol ) : ax [ 0 ] . plot ( fobs_plot , np . abs ( bpass [ bidx , : , pidx ] ) , '.' , label = '{0} {1}' . format ( labels [ bidx ] , plabels [ pidx ] ) , alpha = 0.5 , ls = lcyc [ pidx ] , color = ccyc [ i % len ( ccyc ) ] ) ax [ 1 ] . plot ( fobs_plot , np . angle ( bpass [ bidx , : , pidx ] ) , '.' , label = '{0} {1}' . format ( labels [ bidx ] , plabels [ pidx ] ) , alpha = 0.5 , ls = lcyc [ pidx ] , color = ccyc [ i % len ( ccyc ) ] ) ax [ 0 ] . set_xlabel ( 'freq (GHz)' ) ax [ 1 ] . set_xlabel ( 'freq (GHz)' ) ax [ 0 ] . set_ylabel ( 'B cal amp' ) ax [ 1 ] . set_ylabel ( 'B cal phase (rad)' ) ax [ 0 ] . legend ( ncol = 3 , fontsize = 'small' ) if outname is not None : plt . savefig ( '{0}_bandpass.png' . format ( outname ) , bbox_inches = 'tight' ) if not show : plt . close ( ) return bpass , fobs , labels
short_docstring: r"""Plots the bandpass calibration solutions in the bcal table.
short_docstring_tokens: r " " " Plots the bandpass calibration solutions in the bcal table .
comment: r"""Plots the bandpass calibration solutions in the bcal table.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set. Used to identify the calibration table
          to plot.
      calname : str
          The name of the calibrator used in calibration. The calibration table
          `msname`\_`calname`\_bcal is opened.
      plabels : list
          The labels for the polarizations.  Defaults ``['A', 'B']``.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_bandpass.png if an `outname` is not set to
          ``None``. If `outname` is set to ``None``, the plot is not saved.
          Defaults ``None``.
      show : boolean
          If set to ``False``, the plot is closed after it is generated.
  
      Returns
      -------
      bpass : ndarray
          The bandpass solutions, dimensions (antenna or baseline, frequency).
      fobs : array
          The frequencies at which the bandpass solutions are calculated, in GHz.
      labels : ndarray
          The antenna or baseline labels along the 0th axis of the bandpass
          solutions.
      """$SEP$# squeeze along the time axis$SEP$# baseline, time, spw, frequency, pol