Beispiel #1
0
def chi(sweep, qbt_index, osc_index, title=None, fig_ax=None):
    """
    Plot dispersive shifts chi_j for a given pair of qubit and oscillator.

    Parameters
    ----------
    sweep: ParameterSweep
    qbt_index: int
        index of the qubit system within the underlying HilbertSpace
    osc_index: int
        index of the oscillator system within the underlying HilbertSpace
    title: str, optional
        plot title
    fig_ax: (Figure, Axes), optional

    Returns
    -------
    Figure, Axes
    """
    data_key = 'chi_osc{}_qbt{}'.format(osc_index, qbt_index)
    ydata = sweep.sweep_data[data_key]
    xdata = sweep.param_vals
    xlabel = sweep.param_name
    ylabel = r'$\chi_j$' + DEFAULT_ENERGY_UNITS
    state_count = ydata.shape[1]
    label_list = list(range(state_count))
    return plot.data_vs_paramvals(xdata, ydata, x_range=None, ymax=None, xlabel=xlabel, ylabel=ylabel, title=title,
                                  label_list=label_list, fig_ax=fig_ax)
Beispiel #2
0
def chi_01(sweep, qbt_index, osc_index, param_index=0, fig_ax=None):
    """
    Plot the dispersive shift chi01 for a given pair of qubit and oscillator.

    Parameters
    ----------
    sweep: ParameterSweep
    qbt_index: int
        index of the qubit system within the underlying HilbertSpace
    osc_index: int
        index of the oscillator system within the underlying HilbertSpace
    param_index: int, optional
        index of the external parameter to be used
    fig_ax: (Figure, Axes), optional

    Returns
    -------
    Figure, Axes
    """
    data_key = 'chi_osc{}_qbt{}'.format(osc_index, qbt_index)
    ydata = sweep.sweep_data[data_key]
    xdata = sweep.param_vals
    xlabel = sweep.param_name
    ylabel = r'$\chi_{{01}}$ [{}]'.format(DEFAULT_ENERGY_UNITS)
    title = r'$\chi_{{01}}=${:.4f} {}'.format(ydata[param_index], DEFAULT_ENERGY_UNITS)
    return plot.data_vs_paramvals(xdata, ydata, x_range=None, ymax=None, xlabel=xlabel, ylabel=ylabel, title=title,
                                  label_list=None, fig_ax=fig_ax)
Beispiel #3
0
 def plot(self, **kwargs) -> Tuple[Figure, Axes]:
     if len(self._parameters) != 1:
         raise ValueError(
             "Plotting of NamedSlotNdarray only supported for a "
             "one-dimensional parameter sweep. (Consider slicing.)")
     return plot.data_vs_paramvals(xdata=self._parameters.paramvals_list[0],
                                   ydata=self,
                                   xlabel=self._parameters.names[0],
                                   **kwargs)
Beispiel #4
0
def chi(datastore: 'DataStore', **kwargs) -> Tuple[Figure, Axes]:
    """
    Plot dispersive shifts chi_j for a given pair of qubit and oscillator.

    Parameters
    ----------
    datastore:
        contains sweep data for the dispersive shift, stored as specdata.chi
    **kwargs:
        standard plotting option (see separate documentation)
    """
    ydata = datastore.chi
    xdata = datastore.param_vals
    state_count = ydata.shape[1]
    label_list = list(range(state_count))
    return plot.data_vs_paramvals(xdata,
                                  ydata,
                                  label_list=label_list,
                                  **defaults.chi(datastore.param_name,
                                                 **kwargs))
Beispiel #5
0
def chi_01(datastore, param_index=0, **kwargs):
    """
    Plot the dispersive shift chi01 for a given pair of qubit and oscillator.

    Parameters
    ----------
    datastore: DataStore
    param_index: int, optional
        index of the external parameter to be used
    **kwargs: dict
        standard plotting option (see separate documentation)

    Returns
    -------
    Figure, Axes
    """
    ydata = datastore.chi
    xdata = datastore.param_vals
    yval = ydata[param_index]
    return plot.data_vs_paramvals(xdata, ydata, label_list=None, **defaults.chi01(datastore.param_name, yval, **kwargs))
Beispiel #6
0
def kerr(datastore: "DataStore",
         qubit_level=None,
         **kwargs) -> Tuple[Figure, Axes]:
    """
    Plot dispersive Kerr energy for a given pair of qubit and oscillator.

    Parameters
    ----------
    datastore:
        contains sweep data for the Kerr shift, stored as specdata.kerr
    **kwargs:
        standard plotting option (see separate documentation)
    """
    ydata = datastore.kerr if qubit_level is None else datastore.kerr[:,
                                                                      qubit_level]
    xdata = datastore.param_vals
    state_count = len(ydata)
    label_list = list(range(state_count)) if qubit_level is None else None
    return plot.data_vs_paramvals(
        xdata, ydata.T, label_list=label_list
    )  # , **defaults.chi(datastore.param_name, **kwargs))
Beispiel #7
0
    def plot_dispersion_vs_paramvals(
        self,
        dispersion_name: str,
        param_name: str,
        param_vals: ndarray,
        ref_param: Optional[str] = None,
        transitions: Union[Tuple[int], Tuple[Tuple[int], ...]] = (0, 1),
        levels: Optional[Union[int, Tuple[int]]] = None,
        point_count: int = 50,
        num_cpus: Optional[int] = None,
        **kwargs,
    ) -> Tuple[Figure, Axes]:
        """Generates a simple plot of a set of curves representing the charge or flux
        dispersion of transition energies.

        Parameters
        ----------
        dispersion_name:
            parameter inducing the dispersion, typically 'ng' or 'flux' (will be
            scanned over range from 0 to 1)
        param_name:
            name of parameter to be varied
        param_vals:
            parameter values to be plugged in
        ref_param:
            optional, name of parameter to use as reference for the parameter value;
            e.g., to compute charge dispersion vs. EJ/EC, use EJ as param_name and
            EC as ref_param
        transitions:
            integer tuple or tuples specifying for which transitions dispersion is to
            be calculated
            (default: = (0,1))
        levels:
            int or tuple specifying level(s) (rather than transitions) for which
            dispersion should be plotted; overrides transitions parameter when given
        point_count:
            number of points scanned for the dispersion parameter for determining min
            and max values of transition energies (default: 50)
        num_cpus:
            number of cores to be used for computation
            (default value: settings.NUM_CPUS)
        **kwargs:
            standard plotting option (see separate documentation)
        """
        specdata = self.get_dispersion_vs_paramvals(
            dispersion_name,
            param_name,
            param_vals,
            ref_param=ref_param,
            transitions=transitions,
            levels=levels,
            point_count=point_count,
            num_cpus=num_cpus,
        )
        if levels is not None:
            if isinstance(levels, int):
                levels = (levels,)
            label_list = [str(j) for j in levels]
        else:
            if isinstance(transitions[0], int):
                transitions = (transitions,)
            label_list = ["{}{}".format(i, j) for i, j in transitions]

        return plot.data_vs_paramvals(
            xdata=specdata.param_vals,
            ydata=specdata.dispersion,
            label_list=label_list,
            xlabel=specdata.param_name,
            ylabel="energy dispersion [{}]".format(units.get_units()),
            yscale="log",
            **kwargs,
        )