original_docstring: r"""Plot the bandpass phase observed over multiple calibrators.
  
      Parameters:
      -----------
      filenames : dict
          The details of the calibrator passes to plot.
      antennas : list
          The antenna names (as ints) to plot.
      refant : int
          The reference antenna to plot phases against.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_phase.png if `outname` is not ``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 being generated.
      
docstring: r"""Plot the bandpass phase observed over multiple calibrators.
  Parameters.
  
  filenames : dict
  The details of the calibrator passes to plot.
  antennas : list
  The antenna names (as ints) to plot.
  refant : int
  The reference antenna to plot phases against.
  outname : str
  The base to use for the name of the png file the plot is saved to.
docstring_tokens: r " " " Plot the bandpass phase observed over multiple calibrators . Parameters . filenames : dict The details of the calibrator passes to plot . antennas : list The antenna names ( as ints ) to plot . refant : int The reference antenna to plot phases against . outname : str The base to use for the name of the png file the plot is saved to .
code: def plot_bandpass_phases(
          filenames, antennas, refant=24, outname=None, show=True,
          msdir='/mnt/data/dsa110/calibration/'
  ):
      r"""Plot the bandpass phase observed over multiple calibrators.
  
      Parameters:
      -----------
      filenames : dict
          The details of the calibrator passes to plot.
      antennas : list
          The antenna names (as ints) to plot.
      refant : int
          The reference antenna to plot phases against.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_phase.png if `outname` is not ``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 being generated.
      """
      nentries = 0
      for date in filenames.keys():
          nentries += len(filenames[date].keys())
      gains = [None]*nentries
      calnames = [None]*nentries
      gshape = None
  
      i = 0
      for date in filenames.keys():
          cals = filenames[date].keys()
          transit_times = [filenames[date][cal]['transit_time'] for cal in cals]
          transit_times, cals = zip(*sorted(zip(transit_times, cals)))
          for cal in cals:
              calnames[i] = cal
              msname = '{0}/{1}_{2}'.format(msdir, date, cal)
              if os.path.exists('{0}_{1}_bpcal'.format(msname, cal)):
                  with table('{0}_{1}_bpcal'.format(msname, cal)) as tb:
                      gains[i] = np.array(tb.CPARAM[:])
                  gshape = gains[i].shape
              i += 1
      for i, gain in enumerate(gains):
          if gain is None:
              gains[i] = np.zeros(gshape, dtype=np.complex64)
      gains = np.array(gains)
      nx = 4
      ny = len(antennas)//nx
      if len(antennas)%nx > 0:
          ny += 1
      _, ax = plt.subplots(
          ny,
          nx,
          figsize=(3*nx, 3*ny),
          sharex=True,
          sharey=True
      )
      ax[0, 0].set_yticks(np.arange(nentries))
      for axi in ax[0, :]:
          axi.set_yticklabels(calnames)
      ax = ax.flatten()
      for i in np.arange(len(antennas)):
          ax[i].imshow(
              np.angle(gains[:, antennas[i]-1, :, 0]/gains[:, refant-1, :, 0]),
              vmin=-np.pi,
              vmax=np.pi,
              aspect='auto',
              origin='lower',
              interpolation='None',
              cmap=plt.get_cmap('RdBu')
          )
          ax[i].annotate(
              '{0}'.format(antennas[i]),
              (0, 1),
              xycoords='axes fraction'
          )
          ax[i].set_xlabel('Frequency channel')
      if outname is not None:
          plt.savefig('{0}_phases.png'.format(outname))
      if not show:
          plt.close()
code_tokens: def plot_bandpass_phases ( filenames , antennas , refant = 24 , outname = None , show = True , msdir = '/mnt/data/dsa110/calibration/' ) : nentries = 0 for date in filenames . keys ( ) : nentries += len ( filenames [ date ] . keys ( ) ) gains = [ None ] * nentries calnames = [ None ] * nentries gshape = None i = 0 for date in filenames . keys ( ) : cals = filenames [ date ] . keys ( ) transit_times = [ filenames [ date ] [ cal ] [ 'transit_time' ] for cal in cals ] transit_times , cals = zip ( * sorted ( zip ( transit_times , cals ) ) ) for cal in cals : calnames [ i ] = cal msname = '{0}/{1}_{2}' . format ( msdir , date , cal ) if os . path . exists ( '{0}_{1}_bpcal' . format ( msname , cal ) ) : with table ( '{0}_{1}_bpcal' . format ( msname , cal ) ) as tb : gains [ i ] = np . array ( tb . CPARAM [ : ] ) gshape = gains [ i ] . shape i += 1 for i , gain in enumerate ( gains ) : if gain is None : gains [ i ] = np . zeros ( gshape , dtype = np . complex64 ) gains = np . array ( gains ) nx = 4 ny = len ( antennas ) // nx if len ( antennas ) % nx > 0 : ny += 1 _ , ax = plt . subplots ( ny , nx , figsize = ( 3 * nx , 3 * ny ) , sharex = True , sharey = True ) ax [ 0 , 0 ] . set_yticks ( np . arange ( nentries ) ) for axi in ax [ 0 , : ] : axi . set_yticklabels ( calnames ) ax = ax . flatten ( ) for i in np . arange ( len ( antennas ) ) : ax [ i ] . imshow ( np . angle ( gains [ : , antennas [ i ] - 1 , : , 0 ] / gains [ : , refant - 1 , : , 0 ] ) , vmin = - np . pi , vmax = np . pi , aspect = 'auto' , origin = 'lower' , interpolation = 'None' , cmap = plt . get_cmap ( 'RdBu' ) ) ax [ i ] . annotate ( '{0}' . format ( antennas [ i ] ) , ( 0 , 1 ) , xycoords = 'axes fraction' ) ax [ i ] . set_xlabel ( 'Frequency channel' ) if outname is not None : plt . savefig ( '{0}_phases.png' . format ( outname ) ) if not show : plt . close ( )
short_docstring: r"""Plot the bandpass phase observed over multiple calibrators.
short_docstring_tokens: r " " " Plot the bandpass phase observed over multiple calibrators .
comment: r"""Plot the bandpass phase observed over multiple calibrators.
  
      Parameters:
      -----------
      filenames : dict
          The details of the calibrator passes to plot.
      antennas : list
          The antenna names (as ints) to plot.
      refant : int
          The reference antenna to plot phases against.
      outname : str
          The base to use for the name of the png file the plot is saved to. The
          plot is saved to `outname`\_phase.png if `outname` is not ``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 being generated.
      """