GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bandwidth feature by SCLiao47 · Pull Request #889 · python-control/python-control

Conversation

@SCLiao47

@SCLiao47 SCLiao47 commented May 1, 2023

Copy link
Copy Markdown
Contributor

As discussed in #690, the bandwidth feature is added to the LTI class.

Implementation:

  1. The range of possible frequency is extracted from freqplot._default_frequency_range.
  2. The index, $idx$, is identified, which corresponds to the first frequency dropped by a desired amount relative to the DC gain.
  3. Bisection search (scipy.optimize.root_scalar) is used to solve for the bandwidth in the frequency bracket $[\omega[idx-1], \omega[idx]]$.

Notes:

  1. The bandwidth of a system with infinite DC gain is set to be np.nan, which follows the convention of Matlab.
  2. The above approach is chosen to solve the bandwidth instead of the scipy.optimize.root suggested in issue Create matlab's equivalent to bandwidth. #690. The suggested approach requires an initial guess and might fail, e.g., a system with a resonant peak at a frequency higher than the bandwidth.

Notes on git commits:
git commits are duplicated as I was having some issues to push. I pulled (suggested by git error hint), and it prompts "merge made by the 'recursive' strategy. Not sure whether this is a problem.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
SCLiao47 added 11 commits April 28, 2023 00:41
@SCLiao47
solve bandwidth by bisection for zero-crossing
65988d1
@SCLiao47
testing suggested method by Kreijstal
86ff95c
@SCLiao47
Implemented and passed nominal test
70e912f
@SCLiao47
Handle integrator, all-pass filters
0c81cb2
@SCLiao47
adjust for PEP8 coding style
d59d19a
@SCLiao47
solve bandwidth by bisection for zero-crossing
bc2ddff
@SCLiao47
testing suggested method by Kreijstal
409d0c6
@SCLiao47
Implemented and passed nominal test
723ddc8
@SCLiao47
Handle integrator, all-pass filters
6b51432
@SCLiao47
adjust for PEP8 coding style
9f86b41
@SCLiao47
Merge branch 'feature_bandwidth' of https://github.com/SCLiao47/pytho…
28859c2
…n-control into feature_bandwidth
@murrayrm

murrayrm commented May 2, 2023

Copy link
Copy Markdown
Member

Thanks for this contribution, @SCLiao47.

I think the _bandwidth method should be renamed to bandwidth and put in the LTI class in lti.py. With that change, you should be able to get rid of the bandwidth methods in TransferFunction and StateSpace, since they will get the method from their parent class. You will probably have to override bandwidth in FrequencyResponseData since the dcgain method is not implemented there.

I have some other suggestions, but if you agree with the change above then I would start there, since it will move things around.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented May 2, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

Coverage: 94.652% (+0.003%) from 94.649% when pulling ab68562 on SCLiao47:feature_bandwidth into c06a205 on python-control:main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SCLiao47

SCLiao47 commented May 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@murrayrm thank you for the comments and suggestions.

The _bandwidth method was implemented as I was following the _dcgain method in the LTI class in lti.py. But as you suggested renaming it to bandwidth can simplify the code structure. One other thing I wasn't so sure about is "what other classes should have the bandwidth method." The FrequencyResponseData class is one of them as you mentioned, and I wonder if there are others as well?

[Regarding development flow]

  • I'm still learning the development flow on GitHub. The contribute wiki page (step 11) mentioned that I could keep working on the branch under my own fork. However, does the new commit directly sync to this pull request?
  • One other thing I notice while following the contribute wiki page. It seems like GitHub has renamed the master branch to main. Maybe there needs some edition to the wiki page but I'm not so sure.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sawyerbfuller

sawyerbfuller commented May 3, 2023

Copy link
Copy Markdown
Contributor

Hi @SCLiao47

i think only the classes that derive from LTI should get a bandwidth method: tf, ss, and frd.

As for your question about development: adding new commits to your branch is very seamless. Add them to your own branch (on your own computer) and then, when you do git push origin, they will appear right here on your pull request.

Our main branch name is grandfathered in as master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm

murrayrm commented May 3, 2023

Copy link
Copy Markdown
Member

I've updated the documentation to refer to the main branch (master is deprecated).

SCLiao47 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SCLiao47
remove _bandwidth method in lti.py
a370cdb
@SCLiao47

SCLiao47 commented May 4, 2023

Copy link
Copy Markdown
Contributor Author

@sawyerbfuller @murrayrm thank you for the suggestions and comments. I've restructured the bandwidth method in the LTI class in lti.py.

FRD

As for the FrequencyResponseData class, I wonder how you would suggest implementing the bandwidth method for it? At the moment, the class seems to not support interpolating, which is needed to infer DC gain and compute the bandwidth. However, this will probably fall outside of the scope of this feature. Is there a way to get around this?

Development flow

I think I need to make sure I understand the flow and might need some clarification. In step 8 of the contribute wiki page, the intention is to update and sync the local code (on my machine) to the upstream version (python-control/python-control).

What happened in the instructions:

  1. After clicking sync fork and Update branch on github.com, my forked repo (SCLiao47/python-control) will be sync to the upstream version. Both repos are remote on github.
  2. The first chunk of command lines (on my machine) is to sync my local main branch to the main of the forked repo on GitHub.
  3. The second chunk of command lines is to bring the commits in the local feature branch to the local main. The git rebase allows resolving conflict before merging local feature into upstream main and maintaining a cleaner git graph.

If the above understanding is correct, I wonder about the following:

  1. The local main is not intended to be developed and made changed from my understanding. Why do we need to git push after merge origin/main?
  2. Can we skip sync fork on github.com and replace git merge origin/main with git merge upstream/main? This will have the same result that the local main will be synced to upstream main, right?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

murrayrm
murrayrm reviewed May 6, 2023
View reviewed changes
Comment thread control/xferfcn.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

SCLiao47 added 2 commits May 7, 2023 19:27
@SCLiao47
resolving format issues in xfrefcn.py
02172b7
@SCLiao47
add docstring to lti.bandwidth
ab68562
@murrayrm
murrayrm merged commit 15ed92c into python-control:main May 15, 2023
@bnavigator

bnavigator commented May 15, 2023

Copy link
Copy Markdown
Contributor

What happened in the instructions:

  1. After clicking sync fork and Update branch on github.com, my forked repo (SCLiao47/python-control) will be sync to the upstream version. Both repos are remote on github.

Correct.

  1. The first chunk of command lines (on my machine) is to sync my local main branch to the main of the forked repo on GitHub.

Correct.

  1. The second chunk of command lines is to bring the commits in the local feature branch to the local main. The git rebase allows resolving conflict before merging local feature into upstream main and maintaining a cleaner git graph.

Yes, the commands make sure that your local feature branch also has all the recent changes of your recently updated local main which should now be at the same commit as upstream/main

If the above understanding is correct, I wonder about the following:

  1. The local main is not intended to be developed and made changed from my understanding. Why do we need to git push after merge origin/main?

If you didn't change anything in your local main before the merge, you don't need to push. The push is a noop then. In that case the merge will be a fast-forward and it is sufficient to alternatively just.

git switch main; git pull

But if you have changes in local main (which you should not), you will notice here.

  1. Can we skip sync fork on github.com and replace git merge origin/main with git merge upstream/main? This will have the same result that the local main will be synced to upstream main, right?

Yes, but then you need the push so that your origin/main does not stay behind. These sequences are equivalent, assuming origin/main is already the tracked remote branch of your local clone.

  1. git switch main; git fetch --all; git merge upstream/main; git push
    
  2. on main press "sync fork", then:
    git switch main; git pull
    
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murrayrm murrayrm added this to the 0.9.4 milestone Jun 7, 2023
@roryyorke roryyorke mentioned this pull request Jul 14, 2024
Create matlab's equivalent to bandwidth. #690
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@murrayrm murrayrm murrayrm left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

0.9.4

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@SCLiao47 @murrayrm @coveralls @sawyerbfuller @bnavigator
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.