original_docstring: r"""Plots the gain calibration solutions from the gacal and gpcal tables.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set.  Used to identify the gain calibration
          tables.
      calname : str
          The calibrator used in gain calibration.  Used to identify the gain
          calibration tables.  The tables `msname`\_`calname`\_gacal (assumed to
          contain the gain amplitude soutions) and `msname`\_`calname`\_gpcal
          (assumed to contain the phase amplitude solutions) will be opened.
      plabels : list
          The names of the polarizations in the calibration solutions. Defaults
          to ``['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`\_gaincal.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.
  
      Returns
      -------
      time_days : ndarray
          The times of gain calibration, in days.
      gain_amp : ndarray
          The gain amplitudes. Dimensions (antenna or baseline, time, pol).
      gain_phase : ndarray
          The gain phases. Dimensions (antenna or baseline, time, pol).
      labels : ndarray
          The labels of the antennas or baselines along the 0th axis of the gain
          solutions.
      
docstring: r"""Plots the gain calibration solutions from the gacal and gpcal tables.
  Parameters
  
  msname : str
  The name of the measurement set.  Used to identify the gain calibration
  tables.
  calname : str
  The calibrator used in gain calibration.  Used to identify the gain
  calibration tables.
  
  Returns
  
  time_days : ndarray
  The times of gain calibration, in days.
  gain_amp : ndarray
  The gain amplitudes. Dimensions (antenna or baseline, time, pol).
  gain_phase : ndarray
  The gain phases. Dimensions (antenna or baseline, time, pol).
  labels : ndarray
  The labels of the antennas or baselines along the 0th axis of the gain
  solutions.
docstring_tokens: r " " " Plots the gain calibration solutions from the gacal and gpcal tables . Parameters msname : str The name of the measurement set . Used to identify the gain calibration tables . calname : str The calibrator used in gain calibration . Used to identify the gain calibration tables . Returns time_days : ndarray The times of gain calibration in days . gain_amp : ndarray The gain amplitudes . Dimensions ( antenna or baseline time pol ) . gain_phase : ndarray The gain phases . Dimensions ( antenna or baseline time pol ) . labels : ndarray The labels of the antennas or baselines along the 0th axis of the gain solutions .
code: def plot_gain_calibration(msname, calname, plabels=None, outname=None,
                            show=True):
      r"""Plots the gain calibration solutions from the gacal and gpcal tables.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set.  Used to identify the gain calibration
          tables.
      calname : str
          The calibrator used in gain calibration.  Used to identify the gain
          calibration tables.  The tables `msname`\_`calname`\_gacal (assumed to
          contain the gain amplitude soutions) and `msname`\_`calname`\_gpcal
          (assumed to contain the phase amplitude solutions) will be opened.
      plabels : list
          The names of the polarizations in the calibration solutions. Defaults
          to ``['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`\_gaincal.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.
  
      Returns
      -------
      time_days : ndarray
          The times of gain calibration, in days.
      gain_amp : ndarray
          The gain amplitudes. Dimensions (antenna or baseline, time, pol).
      gain_phase : ndarray
          The gain phases. Dimensions (antenna or baseline, time, pol).
      labels : ndarray
          The labels of the antennas or baselines along the 0th axis of the gain
          solutions.
      """
      if plabels is None:
          plabels = ['A', 'B']
  
      gain_phase, time_phase, _flags, ant1, ant2 = \
          read_caltable('{0}_{1}_gpcal'.format(msname, calname), cparam=True)
      gain_phase = gain_phase.squeeze(axis=3)
      gain_phase = gain_phase.mean(axis=2)
      npol = gain_phase.shape[-1]
      if np.all(ant2 == ant2[0]):
          labels = ant1
      else:
          labels = np.array([ant1, ant2]).T
      nlab = labels.shape[0]
  
      gain_amp, time, _flags, _ant1, _ant2 = \
          read_caltable('{0}_{1}_gacal'.format(msname, calname), cparam=True)
      gain_amp = gain_amp.squeeze(axis=3)
      gain_amp = gain_amp.mean(axis=2)
      time_days = time.copy()
      t0 = time[0]
      time = ((time-t0)*u.d).to_value(u.min)
      time_phase = ((time_phase-t0)*u.d).to_value(u.min)
  
      idx_to_plot = np.where(np.abs(gain_amp.reshape(nlab, -1).mean(1)-1)
                             > 1e-10)[0]
  
      ccyc = plt.rcParams['axes.prop_cycle'].by_key()['color']
      lcyc = ['-', ':']
      _, ax = plt.subplots(1, 2, figsize=(16, 6), sharex=True)
  
      if gain_amp.shape[1] > 1:
          tplot = time
          gplot = gain_amp
      else:
          tplot = [0, 1]
          gplot = np.tile(gain_amp, [1, 2, 1])
  
      for i, bidx in enumerate(idx_to_plot):
          for pidx in range(npol):
              ax[0].plot(tplot, np.abs(gplot[bidx, :, pidx]),
                         label='{0} {1}'.format(labels[bidx]+1, plabels[pidx]),
                         color=ccyc[i%len(ccyc)], ls=lcyc[pidx])
  
      if gain_phase.shape[1] > 1:
          tplot = time_phase
          gplot = gain_phase
      else:
          tplot = [tplot[0], tplot[-1]] # use the time from the gains
          gplot = np.tile(gain_phase, [1, 2, 1])
  
      for i, bidx in enumerate(idx_to_plot):
          for pidx in range(npol):
              ax[1].plot(tplot, np.angle(gplot[bidx, :, pidx]),
                         label='{0} {1}'.format(labels[bidx]+1, plabels[pidx]),
                         color=ccyc[i%len(ccyc)], ls=lcyc[pidx])
  
      ax[0].set_xlim(tplot[0], tplot[-1])
      ax[1].set_ylim(-np.pi, np.pi)
      ax[0].legend(ncol=10, fontsize='x-small', bbox_to_anchor=(0.05, -0.1),
                   loc='upper left')
      ax[0].set_xlabel('time (min)')
      ax[1].set_xlabel('time (min)')
      ax[0].set_ylabel('Abs of gain')
      ax[1].set_ylabel('Phase of gain')
      if outname is not None:
          plt.savefig('{0}_gaincal.png'.format(outname), bbox_inches='tight')
      if not show:
          plt.close()
      return time_days, gain_amp, gain_phase, labels
code_tokens: def plot_gain_calibration ( msname , calname , plabels = None , outname = None , show = True ) : if plabels is None : plabels = [ 'A' , 'B' ] gain_phase , time_phase , _flags , ant1 , ant2 = read_caltable ( '{0}_{1}_gpcal' . format ( msname , calname ) , cparam = True ) gain_phase = gain_phase . squeeze ( axis = 3 ) gain_phase = gain_phase . mean ( axis = 2 ) npol = gain_phase . shape [ - 1 ] if np . all ( ant2 == ant2 [ 0 ] ) : labels = ant1 else : labels = np . array ( [ ant1 , ant2 ] ) . T nlab = labels . shape [ 0 ] gain_amp , time , _flags , _ant1 , _ant2 = read_caltable ( '{0}_{1}_gacal' . format ( msname , calname ) , cparam = True ) gain_amp = gain_amp . squeeze ( axis = 3 ) gain_amp = gain_amp . mean ( axis = 2 ) time_days = time . copy ( ) t0 = time [ 0 ] time = ( ( time - t0 ) * u . d ) . to_value ( u . min ) time_phase = ( ( time_phase - t0 ) * u . d ) . to_value ( u . min ) idx_to_plot = np . where ( np . abs ( gain_amp . reshape ( nlab , - 1 ) . mean ( 1 ) - 1 ) > 1e-10 ) [ 0 ] ccyc = plt . rcParams [ 'axes.prop_cycle' ] . by_key ( ) [ 'color' ] lcyc = [ '-' , ':' ] _ , ax = plt . subplots ( 1 , 2 , figsize = ( 16 , 6 ) , sharex = True ) if gain_amp . shape [ 1 ] > 1 : tplot = time gplot = gain_amp else : tplot = [ 0 , 1 ] gplot = np . tile ( gain_amp , [ 1 , 2 , 1 ] ) for i , bidx in enumerate ( idx_to_plot ) : for pidx in range ( npol ) : ax [ 0 ] . plot ( tplot , np . abs ( gplot [ bidx , : , pidx ] ) , label = '{0} {1}' . format ( labels [ bidx ] + 1 , plabels [ pidx ] ) , color = ccyc [ i % len ( ccyc ) ] , ls = lcyc [ pidx ] ) if gain_phase . shape [ 1 ] > 1 : tplot = time_phase gplot = gain_phase else : tplot = [ tplot [ 0 ] , tplot [ - 1 ] ] gplot = np . tile ( gain_phase , [ 1 , 2 , 1 ] ) for i , bidx in enumerate ( idx_to_plot ) : for pidx in range ( npol ) : ax [ 1 ] . plot ( tplot , np . angle ( gplot [ bidx , : , pidx ] ) , label = '{0} {1}' . format ( labels [ bidx ] + 1 , plabels [ pidx ] ) , color = ccyc [ i % len ( ccyc ) ] , ls = lcyc [ pidx ] ) ax [ 0 ] . set_xlim ( tplot [ 0 ] , tplot [ - 1 ] ) ax [ 1 ] . set_ylim ( - np . pi , np . pi ) ax [ 0 ] . legend ( ncol = 10 , fontsize = 'x-small' , bbox_to_anchor = ( 0.05 , - 0.1 ) , loc = 'upper left' ) ax [ 0 ] . set_xlabel ( 'time (min)' ) ax [ 1 ] . set_xlabel ( 'time (min)' ) ax [ 0 ] . set_ylabel ( 'Abs of gain' ) ax [ 1 ] . set_ylabel ( 'Phase of gain' ) if outname is not None : plt . savefig ( '{0}_gaincal.png' . format ( outname ) , bbox_inches = 'tight' ) if not show : plt . close ( ) return time_days , gain_amp , gain_phase , labels
short_docstring: r"""Plots the gain calibration solutions from the gacal and gpcal tables.
short_docstring_tokens: r " " " Plots the gain calibration solutions from the gacal and gpcal tables .
comment: r"""Plots the gain calibration solutions from the gacal and gpcal tables.
  
      Parameters
      ----------
      msname : str
          The name of the measurement set.  Used to identify the gain calibration
          tables.
      calname : str
          The calibrator used in gain calibration.  Used to identify the gain
          calibration tables.  The tables `msname`\_`calname`\_gacal (assumed to
          contain the gain amplitude soutions) and `msname`\_`calname`\_gpcal
          (assumed to contain the phase amplitude solutions) will be opened.
      plabels : list
          The names of the polarizations in the calibration solutions. Defaults
          to ``['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`\_gaincal.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.
  
      Returns
      -------
      time_days : ndarray
          The times of gain calibration, in days.
      gain_amp : ndarray
          The gain amplitudes. Dimensions (antenna or baseline, time, pol).
      gain_phase : ndarray
          The gain phases. Dimensions (antenna or baseline, time, pol).
      labels : ndarray
          The labels of the antennas or baselines along the 0th axis of the gain
          solutions.
      """$SEP$# use the time from the gains