How to use the control.config._get_param function in control

To help you get started, we’ve selected a few control examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-control / python-control / control / freqplot.py View on Github external
\omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
    timebase.  If not timebase is specified (dt = True), dt is set to 1.

    Examples
    --------
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> mag, phase, omega = bode(sys)

    """
    # Make a copy of the kwargs dictonary since we will modify it
    kwargs = dict(kwargs)

    # Get values for params (and pop from list to allow keyword use in plot)
    dB = config._get_param('bode', 'dB', kwargs, _bode_defaults, pop=True)
    deg = config._get_param('bode', 'deg', kwargs, _bode_defaults, pop=True)
    Hz = config._get_param('bode', 'Hz', kwargs, _bode_defaults, pop=True)
    grid = config._get_param('bode', 'grid', kwargs, _bode_defaults, pop=True)
    Plot = config._get_param('bode', 'grid', Plot, True)
    margins = config._get_param('bode', 'margins', margins, False)

    # If argument was a singleton, turn it into a list
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    if omega is None:
        if omega_limits is None:
            # Select a default range if none is provided
            omega = default_frequency_range(syslist, Hz=Hz,
                                            number_of_samples=omega_num)
        else:
            omega_limits = np.array(omega_limits)
            if Hz:
github python-control / python-control / control / freqplot.py View on Github external
--------
    >>> from matlab import ss
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> omega = default_frequency_range(sys)

    """
    # This code looks at the poles and zeros of all of the systems that
    # we are plotting and sets the frequency range to be one decade above
    # and below the min and max feature frequencies, rounded to the nearest
    # integer.  It excludes poles and zeros at the origin.  If no features
    # are found, it turns logspace(-1, 1)

    # Set default values for options
    number_of_samples = config._get_param(
        'freqplot', 'number_of_samples', number_of_samples)
    feature_periphery_decades = config._get_param(
        'freqplot', 'feature_periphery_decades', feature_periphery_decades, 1)

    # Find the list of all poles and zeros in the systems
    features = np.array(())
    freq_interesting = []

    # detect if single sys passed by checking if it is sequence-like
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    for sys in syslist:
        try:
            # Add new features to the list
            if sys.isctime():
                features_ = np.concatenate((np.abs(sys.pole()),
                                            np.abs(sys.zero())))
github python-control / python-control / control / freqplot.py View on Github external
Examples
    --------
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> mag, phase, omega = bode(sys)

    """
    # Make a copy of the kwargs dictonary since we will modify it
    kwargs = dict(kwargs)

    # Get values for params (and pop from list to allow keyword use in plot)
    dB = config._get_param('bode', 'dB', kwargs, _bode_defaults, pop=True)
    deg = config._get_param('bode', 'deg', kwargs, _bode_defaults, pop=True)
    Hz = config._get_param('bode', 'Hz', kwargs, _bode_defaults, pop=True)
    grid = config._get_param('bode', 'grid', kwargs, _bode_defaults, pop=True)
    Plot = config._get_param('bode', 'grid', Plot, True)
    margins = config._get_param('bode', 'margins', margins, False)

    # If argument was a singleton, turn it into a list
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    if omega is None:
        if omega_limits is None:
            # Select a default range if none is provided
            omega = default_frequency_range(syslist, Hz=Hz,
                                            number_of_samples=omega_num)
        else:
            omega_limits = np.array(omega_limits)
            if Hz:
                omega_limits *= 2. * math.pi
            if omega_num:
                omega = sp.logspace(np.log10(omega_limits[0]),
github python-control / python-control / control / freqplot.py View on Github external
Examples
    --------
    >>> from matlab import ss
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> omega = default_frequency_range(sys)

    """
    # This code looks at the poles and zeros of all of the systems that
    # we are plotting and sets the frequency range to be one decade above
    # and below the min and max feature frequencies, rounded to the nearest
    # integer.  It excludes poles and zeros at the origin.  If no features
    # are found, it turns logspace(-1, 1)

    # Set default values for options
    number_of_samples = config._get_param(
        'freqplot', 'number_of_samples', number_of_samples)
    feature_periphery_decades = config._get_param(
        'freqplot', 'feature_periphery_decades', feature_periphery_decades, 1)

    # Find the list of all poles and zeros in the systems
    features = np.array(())
    freq_interesting = []

    # detect if single sys passed by checking if it is sequence-like
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    for sys in syslist:
        try:
            # Add new features to the list
            if sys.isctime():
github python-control / python-control / control / freqplot.py View on Github external
Examples
    --------
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> mag, phase, omega = bode(sys)

    """
    # Make a copy of the kwargs dictonary since we will modify it
    kwargs = dict(kwargs)

    # Get values for params (and pop from list to allow keyword use in plot)
    dB = config._get_param('bode', 'dB', kwargs, _bode_defaults, pop=True)
    deg = config._get_param('bode', 'deg', kwargs, _bode_defaults, pop=True)
    Hz = config._get_param('bode', 'Hz', kwargs, _bode_defaults, pop=True)
    grid = config._get_param('bode', 'grid', kwargs, _bode_defaults, pop=True)
    Plot = config._get_param('bode', 'grid', Plot, True)
    margins = config._get_param('bode', 'margins', margins, False)

    # If argument was a singleton, turn it into a list
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    if omega is None:
        if omega_limits is None:
            # Select a default range if none is provided
            omega = default_frequency_range(syslist, Hz=Hz,
                                            number_of_samples=omega_num)
        else:
            omega_limits = np.array(omega_limits)
            if Hz:
                omega_limits *= 2. * math.pi
            if omega_num:
github python-control / python-control / control / pzmap.py View on Github external
Plot: bool
        If ``True`` a graph is generated with Matplotlib,
        otherwise the poles and zeros are only computed and returned.
    grid: boolean (default = False)
        If True plot omega-damping grid.

    Returns
    -------
    pole: array
        The systems poles
    zeros: array
        The system's zeros.
    """
    # Get parameter values
    Plot = config._get_param('rlocus', 'Plot', Plot, True)
    grid = config._get_param('rlocus', 'grid', grid, False)
    
    if not isinstance(sys, LTI):
        raise TypeError('Argument ``sys``: must be a linear system.')

    poles = sys.pole()
    zeros = sys.zero()

    if (Plot):
        import matplotlib.pyplot as plt

        if grid:
            if isdtime(sys, strict=True):
                ax, fig = zgrid()
            else:
                ax, fig = sgrid()
        else:
github python-control / python-control / control / rlocus.py View on Github external
PrintGain : bool
        If True (default), report mouse clicks when close to the root locus
        branches, calculate gain, damping and print.
    grid : bool
        If True plot omega-damping grid.  Default is False.

    Returns
    -------
    rlist : ndarray
        Computed root locations, given as a 2D array
    klist : ndarray or list
        Gains used.  Same as klist keyword argument if provided.
    """
    # Get parameter values
    plotstr = config._get_param('rlocus', 'plotstr', plotstr, _rlocus_defaults)
    grid = config._get_param('rlocus', 'grid', grid, _rlocus_defaults)
    PrintGain = config._get_param(
        'rlocus', 'PrintGain', PrintGain, _rlocus_defaults)

    # Convert numerator and denominator to polynomials if they aren't
    (nump, denp) = _systopoly1d(sys)

    if kvect is None:
        start_mat = _RLFindRoots(nump, denp, [1])
        kvect, mymat, xlim, ylim = _default_gains(nump, denp, xlim, ylim)
    else:
        start_mat = _RLFindRoots(nump, denp, [kvect[0]])
        mymat = _RLFindRoots(nump, denp, kvect)
        mymat = _RLSortRoots(mymat)

    # Check for sisotool mode
    sisotool = False if 'sisotool' not in kwargs else True
github python-control / python-control / control / nichols.py View on Github external
Parameters
    ----------
    sys_list : list of LTI, or LTI
        List of linear input/output systems (single system is OK)
    omega : array_like
        Range of frequencies (list or bounds) in rad/sec
    grid : boolean, optional
        True if the plot should include a Nichols-chart grid. Default is True.

    Returns
    -------
    None
    """
    # Get parameter values
    grid = config._get_param('nichols', 'grid', grid, True)


    # If argument was a singleton, turn it into a list
    if not getattr(sys_list, '__iter__', False):
        sys_list = (sys_list,)

    # Select a default range if none is provided
    if omega is None:
        omega = default_frequency_range(sys_list)

    for sys in sys_list:
        # Get the magnitude and phase of the system
        mag_tmp, phase_tmp, omega = sys.freqresp(omega)
        mag = np.squeeze(mag_tmp)
        phase = np.squeeze(phase_tmp)
github python-control / python-control / control / freqplot.py View on Github external
along the upper branch of the unit circle, using the mapping z = exp(j
    \omega dt) where omega ranges from 0 to pi/dt and dt is the discrete
    timebase.  If not timebase is specified (dt = True), dt is set to 1.

    Examples
    --------
    >>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
    >>> mag, phase, omega = bode(sys)

    """
    # Make a copy of the kwargs dictonary since we will modify it
    kwargs = dict(kwargs)

    # Get values for params (and pop from list to allow keyword use in plot)
    dB = config._get_param('bode', 'dB', kwargs, _bode_defaults, pop=True)
    deg = config._get_param('bode', 'deg', kwargs, _bode_defaults, pop=True)
    Hz = config._get_param('bode', 'Hz', kwargs, _bode_defaults, pop=True)
    grid = config._get_param('bode', 'grid', kwargs, _bode_defaults, pop=True)
    Plot = config._get_param('bode', 'grid', Plot, True)
    margins = config._get_param('bode', 'margins', margins, False)

    # If argument was a singleton, turn it into a list
    if not getattr(syslist, '__iter__', False):
        syslist = (syslist,)

    if omega is None:
        if omega_limits is None:
            # Select a default range if none is provided
            omega = default_frequency_range(syslist, Hz=Hz,
                                            number_of_samples=omega_num)
        else:
            omega_limits = np.array(omega_limits)