def update( cls, calibrations: Calibrations, exp_data: ExperimentData, result_index: Optional[int] = -1, group: str = "default", angles_schedules: List[Tuple[float, str, Union[str, ScheduleBlock]]] = None, **options, ): """Update the amplitude of pulses. The value of the amplitude must be derived from the fit so the base method cannot be used. Args: calibrations: The calibrations to update. exp_data: The experiment data from which to update. result_index: The result index to use which defaults to -1. group: The calibrations group to update. Defaults to "default." angles_schedules: A list of tuples specifying which angle to update for which pulse schedule. Each tuple is of the form: (angle, parameter_name, schedule). Here, angle is the rotation angle for which to extract the amplitude, parameter_name is the name of the parameter whose value is to be updated, and schedule is the schedule or its name that contains the parameter. options: Trailing options. Raises: CalibrationError: If the experiment is not of the supported type. """ from qiskit_experiments.library.calibration.rabi import Rabi if angles_schedules is None: angles_schedules = [(np.pi, "amp", "xp")] if isinstance(exp_data.experiment, Rabi): rate = 2 * np.pi * BaseUpdater.get_value(exp_data, "rabi_rate", result_index) for angle, param, schedule in angles_schedules: qubits = exp_data.metadata["physical_qubits"] prev_amp = calibrations.get_parameter_value(param, qubits, schedule, group=group) value = np.round(angle / rate, decimals=8) * np.exp( 1.0j * np.angle(prev_amp)) cls.add_parameter_value(calibrations, exp_data, value, param, schedule, group) else: raise CalibrationError( f"{cls.__name__} updates from {type(Rabi.__name__)}.")
def update( cls, calibrations: Calibrations, exp_data: ExperimentData, parameter: str, schedule: Union[ScheduleBlock, str], result_index: Optional[int] = -1, group: str = "default", target_angle: float = np.pi, **options, ): """Update the value of a drag parameter measured by the FineDrag experiment. Args: calibrations: The calibrations to update. exp_data: The experiment data from which to update. parameter: The name of the parameter in the calibrations to update. schedule: The ScheduleBlock instance or the name of the instance to which the parameter is attached. result_index: The result index to use. By default search entry by name. group: The calibrations group to update. Defaults to "default." target_angle: The target rotation angle of the pulse. options: Trailing options. Raises: CalibrationError: If we cannot get the pulse's standard deviation from the schedule. """ qubits = exp_data.metadata["physical_qubits"] if isinstance(schedule, str): schedule = calibrations.get_schedule(schedule, qubits) # Obtain sigma as it is needed for the fine DRAG update rule. sigma = None for block in schedule.blocks: if isinstance(block, Play) and hasattr(block.pulse, "sigma"): sigma = getattr(block.pulse, "sigma") if sigma is None: raise CalibrationError(f"Could not infer sigma from {schedule}.") d_theta = BaseUpdater.get_value(exp_data, "d_theta", result_index) # See the documentation in fine_drag.py for the derivation of this rule. d_beta = -np.sqrt(np.pi) * d_theta * sigma / target_angle**2 old_beta = calibrations.get_parameter_value(parameter, qubits, schedule, group=group) new_beta = old_beta + d_beta cls.add_parameter_value(calibrations, exp_data, new_beta, parameter, schedule, group)