Quanlse/QWaveform.py
def addWave(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]] = None,
                onSubSys: Union[int, List[int]] = None, waves: Union[QWaveform, List[QWaveform]] = None,
                t0: Union[int, float] = None, strength: Union[int, float] = 1.0,
                freq: Optional[Union[int, float]] = None, phase: Optional[Union[int, float]] = None,
                phase0: Optional[Union[int, float]] = None, name: str = None, tag: str = None, flag: int = None) \
            -> None:
        """
        This method adds control terms and waveforms to a QJob object. Users can specify the operators(QOperator object)
        , subsystem's indexes, wave information (QWaveform object), wave strength, wave frequency, wave phase. Moreover,
        the users can specify a tag and flag for identifying the purposes of the wave.

        :param operators: wave operator
        :param onSubSys: what subsystem the wave is acting upon
        :param waves: a QWaveform object
        :param t0: start time
        :param strength: wave strength
        :param freq: wave frequency shift
        :param phase: pulse phase shift (will accumulate during the entire pulse execution)
        :param phase0: pulse phase shift (will not accumulate during the entire pulse execution)
        :param name: a user-given name to the wave
        :param tag: wave tag indicating purpose
        :param flag: wave flag
        :return: None
        """

        def _addOperator(_flag):
            """ Add Operator """
            if operators is not None and onSubSys is not None:
                # Generate the operator key
                _opKey = self.addOperators(operators, onSubSys, name=name,
                                           flagDoNotClear=(_flag & QWAVEFORM_FLAG_DO_NOT_CLEAR) > 0)
            elif name is not None:
                _opKey = name
            else:
                raise Error.ArgumentError(
                    "You must indicate the operators with onSubSys or the name of the term.")
            return _opKey

        def _getFlagAndWaveContainer(_wave):
            """ Return Flag or wave container. """
            _realFlag = 0
            if flag is not None:
                _realFlag = flag
            elif _wave.flag is not None:
                _realFlag = _wave.flag
            if (_realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR) and self.parent is None:
                raise Error.ArgumentError("Current QJob object has no parent, hence cannot add "
                                          "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR.")
            elif _realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR:
                _containerWaves = self.parent.doNotClearFlagWaves
            else:
                _containerWaves = self._waves
            return _realFlag, _containerWaves

        _waves = waves.copy()
        if isinstance(_waves, list):
            for wave in _waves:
                _flag, containerWaves = _getFlagAndWaveContainer(wave)
                opKey = _addOperator(_flag)
                wave.dt = self.dt
                wave.t0 = wave.t0 if t0 is None else t0
                wave.strength = wave.strength if strength is None else strength
                wave.freq = wave.freq if freq is None else freq
                wave.phase = wave.phase if phase is None else phase
                wave.phase0 = wave.phase0 if phase0 is None else phase0
                wave.tag = wave.tag if tag is None else tag
                wave.flag = _flag
                containerWaves[opKey].append(wave)
        elif isinstance(_waves, QWaveform):
            _flag, containerWaves = _getFlagAndWaveContainer(_waves)
            opKey = _addOperator(_flag)
            _waves.dt = self.dt
            _waves.t0 = _waves.t0 if t0 is None else t0
            _waves.strength = _waves.strength if strength is None else strength
            _waves.freq = _waves.freq if freq is None else freq
            _waves.phase = _waves.phase if phase is None else phase
            _waves.phase0 = _waves.phase0 if phase0 is None else phase0
            _waves.tag = _waves.tag if tag is None else tag
            _waves.flag = _flag
            containerWaves[opKey].append(_waves)
        else:
            raise Error.ArgumentError("Parameter waves must be a (or a list of) QWaveform object(s).")

        # Compute the end time
        self.computeMaxTime()
        self.clearCache()

        This method adds control terms and waveforms to a QJob object. Users can specify the operators(QOperator object)
        , subsystem's indexes, wave information (QWaveform object), wave strength, wave frequency, wave phase. Moreover,
        the users can specify a tag and flag for identifying the purposes of the wave.

        :param operators: wave operator
        :param onSubSys: what subsystem the wave is acting upon
        :param waves: a QWaveform object
        :param t0: start time
        :param strength: wave strength
        :param freq: wave frequency shift
        :param phase: pulse phase shift (will accumulate during the entire pulse execution)
        :param phase0: pulse phase shift (will not accumulate during the entire pulse execution)
        :param name: a user-given name to the wave
        :param tag: wave tag indicating purpose
        :param flag: wave flag
        :return: None
        
This method adds control terms and waveforms to a QJob object. Users can specify the operators(QOperator object)
, subsystem's indexes, wave information (QWaveform object), wave strength, wave frequency, wave phase. Moreover,
the users can specify a tag and flag for identifying the purposes of the wave.
This method adds control terms and waveforms to a QJob object . Users can specify the operators ( QOperator object ) subsystem ' s indexes wave information ( QWaveform object ) wave strength wave frequency wave phase . Moreover the users can specify a tag and flag for identifying the purposes of the wave .
def addWave(self, operators: Union[QOperator, Callable, List[QOperator], List[Callable]] = None,
                onSubSys: Union[int, List[int]] = None, waves: Union[QWaveform, List[QWaveform]] = None,
                t0: Union[int, float] = None, strength: Union[int, float] = 1.0,
                freq: Optional[Union[int, float]] = None, phase: Optional[Union[int, float]] = None,
                phase0: Optional[Union[int, float]] = None, name: str = None, tag: str = None, flag: int = None) \
            -> None:
        def _addOperator(_flag):
            if operators is not None and onSubSys is not None:
                _opKey = self.addOperators(operators, onSubSys, name=name,
                                           flagDoNotClear=(_flag & QWAVEFORM_FLAG_DO_NOT_CLEAR) > 0)
            elif name is not None:
                _opKey = name
            else:
                raise Error.ArgumentError(
                    "You must indicate the operators with onSubSys or the name of the term.")
            return _opKey
        def _getFlagAndWaveContainer(_wave):
            _realFlag = 0
            if flag is not None:
                _realFlag = flag
            elif _wave.flag is not None:
                _realFlag = _wave.flag
            if (_realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR) and self.parent is None:
                raise Error.ArgumentError("Current QJob object has no parent, hence cannot add "
                                          "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR.")
            elif _realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR:
                _containerWaves = self.parent.doNotClearFlagWaves
            else:
                _containerWaves = self._waves
            return _realFlag, _containerWaves
        _waves = waves.copy()
        if isinstance(_waves, list):
            for wave in _waves:
                _flag, containerWaves = _getFlagAndWaveContainer(wave)
                opKey = _addOperator(_flag)
                wave.dt = self.dt
                wave.t0 = wave.t0 if t0 is None else t0
                wave.strength = wave.strength if strength is None else strength
                wave.freq = wave.freq if freq is None else freq
                wave.phase = wave.phase if phase is None else phase
                wave.phase0 = wave.phase0 if phase0 is None else phase0
                wave.tag = wave.tag if tag is None else tag
                wave.flag = _flag
                containerWaves[opKey].append(wave)
        elif isinstance(_waves, QWaveform):
            _flag, containerWaves = _getFlagAndWaveContainer(_waves)
            opKey = _addOperator(_flag)
            _waves.dt = self.dt
            _waves.t0 = _waves.t0 if t0 is None else t0
            _waves.strength = _waves.strength if strength is None else strength
            _waves.freq = _waves.freq if freq is None else freq
            _waves.phase = _waves.phase if phase is None else phase
            _waves.phase0 = _waves.phase0 if phase0 is None else phase0
            _waves.tag = _waves.tag if tag is None else tag
            _waves.flag = _flag
            containerWaves[opKey].append(_waves)
        else:
            raise Error.ArgumentError("Parameter waves must be a (or a list of) QWaveform object(s).")
        self.computeMaxTime()
        self.clearCache()
def addWave ( self , operators : Union [ QOperator , Callable , List [ QOperator ] , List [ Callable ] ] = None , onSubSys : Union [ int , List [ int ] ] = None , waves : Union [ QWaveform , List [ QWaveform ] ] = None , t0 : Union [ int , float ] = None , strength : Union [ int , float ] = 1.0 , freq : Optional [ Union [ int , float ] ] = None , phase : Optional [ Union [ int , float ] ] = None , phase0 : Optional [ Union [ int , float ] ] = None , name : str = None , tag : str = None , flag : int = None ) -> None : def _addOperator ( _flag ) : """ Add Operator """ if operators is not None and onSubSys is not None : _opKey = self . addOperators ( operators , onSubSys , name = name , flagDoNotClear = ( _flag & QWAVEFORM_FLAG_DO_NOT_CLEAR ) > 0 ) elif name is not None : _opKey = name else : raise Error . ArgumentError ( "You must indicate the operators with onSubSys or the name of the term." ) return _opKey def _getFlagAndWaveContainer ( _wave ) : """ Return Flag or wave container. """ _realFlag = 0 if flag is not None : _realFlag = flag elif _wave . flag is not None : _realFlag = _wave . flag if ( _realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR ) and self . parent is None : raise Error . ArgumentError ( "Current QJob object has no parent, hence cannot add " "waves with QWAVEFORM_FLAG_DO_NOT_CLEAR." ) elif _realFlag & QWAVEFORM_FLAG_DO_NOT_CLEAR : _containerWaves = self . parent . doNotClearFlagWaves else : _containerWaves = self . _waves return _realFlag , _containerWaves _waves = waves . copy ( ) if isinstance ( _waves , list ) : for wave in _waves : _flag , containerWaves = _getFlagAndWaveContainer ( wave ) opKey = _addOperator ( _flag ) wave . dt = self . dt wave . t0 = wave . t0 if t0 is None else t0 wave . strength = wave . strength if strength is None else strength wave . freq = wave . freq if freq is None else freq wave . phase = wave . phase if phase is None else phase wave . phase0 = wave . phase0 if phase0 is None else phase0 wave . tag = wave . tag if tag is None else tag wave . flag = _flag containerWaves [ opKey ] . append ( wave ) elif isinstance ( _waves , QWaveform ) : _flag , containerWaves = _getFlagAndWaveContainer ( _waves ) opKey = _addOperator ( _flag ) _waves . dt = self . dt _waves . t0 = _waves . t0 if t0 is None else t0 _waves . strength = _waves . strength if strength is None else strength _waves . freq = _waves . freq if freq is None else freq _waves . phase = _waves . phase if phase is None else phase _waves . phase0 = _waves . phase0 if phase0 is None else phase0 _waves . tag = _waves . tag if tag is None else tag _waves . flag = _flag containerWaves [ opKey ] . append ( _waves ) else : raise Error . ArgumentError ( "Parameter waves must be a (or a list of) QWaveform object(s)." ) self . computeMaxTime ( ) self . clearCache ( )
This method adds control terms and waveforms to a QJob object.
This method adds control terms and waveforms to a QJob object .
"""
        This method adds control terms and waveforms to a QJob object. Users can specify the operators(QOperator object)
        , subsystem's indexes, wave information (QWaveform object), wave strength, wave frequency, wave phase. Moreover,
        the users can specify a tag and flag for identifying the purposes of the wave.

        :param operators: wave operator
        :param onSubSys: what subsystem the wave is acting upon
        :param waves: a QWaveform object
        :param t0: start time
        :param strength: wave strength
        :param freq: wave frequency shift
        :param phase: pulse phase shift (will accumulate during the entire pulse execution)
        :param phase0: pulse phase shift (will not accumulate during the entire pulse execution)
        :param name: a user-given name to the wave
        :param tag: wave tag indicating purpose
        :param flag: wave flag
        :return: None
        """ """ Add Operator """ # Generate the operator key """ Return Flag or wave container. """ # Compute the end time
None
self
operators
Union[QOperator, Callable, List[QOperator], List[Callable]]
None
onSubSys
Union[int, List[int]]
None
waves
Union[QWaveform, List[QWaveform]]
a QWaveform object
a QWaveform object
t0
Union[int, float]
None
strength
Union[int, float]
None
freq
Optional[Union[int, float]]
wave frequency shift
wave frequency shift
phase
Optional[Union[int, float]]
pulse phase shift (will accumulate during the entire pulse execution)
pulse phase shift ( will accumulate during the entire pulse execution )
phase0
Optional[Union[int, float]]
pulse phase shift (will not accumulate during the entire pulse execution)
pulse phase shift ( will not accumulate during the entire pulse execution )
name
str
a user-given name to the wave
a user - given name to the wave
tag
str
wave tag indicating purpose
wave tag indicating purpose
flag
int
None