Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bandwidth feature#889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
murrayrm merged 14 commits intopython-control:mainfromSCLiao47:feature_bandwidth
May 15, 2023
Merged

Conversation

SCLiao47
Copy link
Contributor

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

Implementation:

  1. The range of possible frequency is extracted fromfreqplot._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 benp.nan, which follows the convention of Matlab.
  2. The above approach is chosen to solve the bandwidth instead of thescipy.optimize.root suggested in issueCreate 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.

@murrayrm
Copy link
Member

Thanks for this contribution,@SCLiao47.

I think the_bandwidth method should be renamed tobandwidth and put in theLTI class inlti.py. With that change, you should be able to get rid of thebandwidth methods inTransferFunction andStateSpace, since they will get the method from their parent class. You will probably have to overridebandwidth inFrequencyResponseData since thedcgain 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.

@coveralls
Copy link

coveralls commentedMay 2, 2023
edited
Loading

Coverage Status

Coverage: 94.652% (+0.003%) from 94.649% when pullingab68562 on SCLiao47:feature_bandwidth intoc06a205 on python-control:main.

@SCLiao47
Copy link
ContributorAuthor

SCLiao47 commentedMay 3, 2023
edited
Loading

@murrayrm thank you for the comments and suggestions.

The_bandwidth method was implemented as I was following the_dcgain method in theLTIclass inlti.py. But as you suggested renaming it tobandwidth can simplify the code structure. One other thing I wasn't so sure about is "what other classes should have thebandwidth method." TheFrequencyResponseData 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. Thecontribute 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 themaster branch tomain. Maybe there needs some edition to the wiki page but I'm not so sure.

@sawyerbfuller
Copy link
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.

@murrayrm
Copy link
Member

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

SCLiao47 reacted with thumbs up emoji

@SCLiao47
Copy link
ContributorAuthor

@sawyerbfuller@murrayrm thank you for the suggestions and comments. I've restructured thebandwidthmethod in theLTI class inlti.py.

FRD

As for theFrequencyResponseData class, I wonder how you would suggest implementing thebandwidth 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 thecontribute wiki page, the intention is to update and sync thelocal code (on my machine) to theupstream version (python-control/python-control).

What happened in the instructions:

  1. After clickingsync fork andUpdate branch on github.com, myforked repo (SCLiao47/python-control) will be sync to theupstream version. Both repos are remote on github.
  2. The first chunk of command lines (on my machine) is to sync mylocal main branch to themain of theforked repo on GitHub.
  3. The second chunk of command lines is to bring the commits in thelocal feature branch to thelocal main. Thegit rebase allows resolving conflict before merginglocal feature intoupstream main and maintaining a cleaner git graph.

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

  1. Thelocal main is not intended to be developed and made changed from my understanding. Why do we need togit push aftermerge origin/main?
  2. Can we skipsync fork on github.com and replacegit merge origin/main withgit merge upstream/main? This will have the same result that thelocal main will be synced toupstream main, right?

@murrayrmmurrayrm merged commit15ed92c intopython-control:mainMay 15, 2023
@bnavigator
Copy link
Contributor

What happened in the instructions:

  1. After clickingsync fork andUpdate branch on github.com, myforked repo (SCLiao47/python-control) will be sync to theupstream version. Both repos are remote on github.

Correct.

  1. The first chunk of command lines (on my machine) is to sync mylocal main branch to themain of theforked repo on GitHub.

Correct.

  1. The second chunk of command lines is to bring the commits in thelocal feature branch to thelocal main. Thegit rebase allows resolving conflict before merginglocal feature intoupstream 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 localmain which should now be at the same commit asupstream/main

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

  1. Thelocal main is not intended to be developed and made changed from my understanding. Why do we need togit push aftermerge 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 skipsync fork on github.com and replacegit merge origin/main withgit merge upstream/main? This will have the same result that thelocal main will be synced toupstream main, right?

Yes, but then you need the push so that yourorigin/main does not stay behind. These sequences are equivalent, assumingorigin/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

@murrayrmmurrayrm added this to the0.9.4 milestoneJun 7, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@murrayrmmurrayrmmurrayrm left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
0.9.4
Development

Successfully merging this pull request may close these issues.

5 participants
@SCLiao47@murrayrm@coveralls@sawyerbfuller@bnavigator

[8]ページ先頭

©2009-2025 Movatter.jp