Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input-output selection in bode_plot #1916

Merged
merged 17 commits into from Jan 20, 2023

Conversation

MohamedAdelNaguib
Copy link
Contributor

@MohamedAdelNaguib MohamedAdelNaguib commented Jan 10, 2023

Problem statement :
Currently, the bode_plot function plots multiple graphs/plots depending on the values of dim_input and dim_output.

Goal:
The goal is to restrict one or more input-output pair from these plots to be displayed to the user instead of displaying all the plots.

Solution:
By introducing two new optional arguments , input_indices and output_indices, which indicate the index of the input or the output that we are interested in.

Examples:
If we have dim_input=3, dim_output=3,

  • By passing output_indices = [1,2] and input indices = [0,2] that will result in displaying all the subplots with the following indices {(1,0), (1,2), (2,0), (2,2)}. also if output_indices=None and input_indices = [1,2] the function should display the subplot with the following indices {(0,1) , (0,2) , (1,1), (1,2) , (2,1) ,(2,2)}.
  • By passing input_indices=None and output_indices=[1,2], that will result in displaying the subplots with the following indices {(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)}.
  • if you did not specify a value for both input_indices and output_indices, all the subplots will be dispalyed

I tested my implementation by using the same code here #1615 with some edits in the bode_plot calls giving it different values for the new added parameters input_indices and output_indices and it gives me the corresponding plots of my chosen indices.

closes #1767

@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as draft January 11, 2023 09:24
@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as ready for review January 11, 2023 09:24
@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as draft January 11, 2023 09:24
@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as ready for review January 11, 2023 09:28
@pmli pmli self-assigned this Jan 11, 2023
@pmli pmli added this to the 2023.1 milestone Jan 11, 2023
@pmli pmli added the pr:new-feature Introduces a new feature label Jan 11, 2023
@MohamedAdelNaguib MohamedAdelNaguib changed the title Input-output selection in bode_plot #1767 Input-output selection in bode_plot Jan 11, 2023
Copy link
Member

@pmli pmli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Below are two comments.

It would be good to also add a test or edit the LTI system tutorial.

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as draft January 11, 2023 21:32
Copy link
Member

@pmli pmli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better now, I just have a few minor remarks below (the point about adding a test or editing the tutorial remains).

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@MohamedAdelNaguib
Copy link
Contributor Author

@pmli, For adding a tutorial part I am currently still working on it. sorry for being late but I think I found a bug so I am further investigating it before opening a new issue for it.

@MohamedAdelNaguib MohamedAdelNaguib marked this pull request as ready for review January 12, 2023 17:28
Copy link
Member

@pmli pmli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments. I'll take a closer look tomorrow.

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
docs/source/tutorial_lti_systems.md Outdated Show resolved Hide resolved
docs/source/tutorial_lti_systems.md Outdated Show resolved Hide resolved
docs/source/tutorial_lti_systems.md Outdated Show resolved Hide resolved
@pmli pmli requested a review from artpelling January 14, 2023 14:53
@pmli
Copy link
Member

pmli commented Jan 14, 2023

Oh, I just remembered, could you add yourself to AUTHORS.md @MohamedAdelNaguib? You would just need to start a new "pyMOR 2023.1" section under "Contributors".

Copy link
Member

@HenKlei HenKlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MohamedAdelNaguib, thanks for your contribution! I have some minor comments, mostly regarding documentation.

@pmli, @MohamedAdelNaguib, what do you think about adding a subtitle to the plots (respectively the rows and columns) to make clear which inputs and outputs are displayed in the respective plot?

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
Copy link
Member

@artpelling artpelling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MohamedAdelNaguib, welcome to pyMOR ✨

Thanks for your contribution, this feature is long overdue. I left some comments, let me know what you think.

@pmli This seems also related to the slicing of LTIModels we talked about. At the moment, restricting the indices wouldn't really result in faster computations. If we had a slicing mechanism, we could envoke it here.
However, I'm not sure when we actually get around to implement that..

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@MohamedAdelNaguib MohamedAdelNaguib requested review from artpelling and HenKlei and removed request for artpelling January 16, 2023 14:57
Copy link
Member

@HenKlei HenKlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the wording, this now looks good to me.

What do you think @artpelling, @pmli?

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@HenKlei
Copy link
Member

HenKlei commented Jan 16, 2023

You should rebase on main @MohamedAdelNaguib, since AUTHORS.md has changed.

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@artpelling artpelling self-requested a review January 16, 2023 18:04
Copy link
Member

@artpelling artpelling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the import sorting, this looks good to me now 👍

src/pymor/models/transfer_function.py Outdated Show resolved Hide resolved
@pmli
Copy link
Member

pmli commented Jan 16, 2023

@MohamedAdelNaguib Looking at the commits, it seems like some other PRs got mixed in. Could you try rebasing again on the main branch? On my system, I could do it by running git rebase -i main, deleting commits that start with a bracket "[", fixing the conflict in AUTHORS.md twice, and running git rebase --continue once more.

@pmli, @MohamedAdelNaguib, what do you think about adding a subtitle to the plots (respectively the rows and columns) to make clear which inputs and outputs are displayed in the respective plot?

I thought about this, and I think it would be nice to do something similar to Matlab, but I don't know how to nicely add both horizontal and vertical subtitles. That's way I thought it would be better to do it later in another PR.

@pmli This seems also related to the slicing of LTIModels we talked about. At the moment, restricting the indices wouldn't really result in faster computations. If we had a slicing mechanism, we could envoke it here. However, I'm not sure when we actually get around to implement that..

Yes, I agree it would be good to have slicing here, and that we'll do it some other time.

@MohamedAdelNaguib
Copy link
Contributor Author

MohamedAdelNaguib commented Jan 17, 2023

@MohamedAdelNaguib Looking at the commits, it seems like some other PRs got mixed in. Could you try rebasing again on the main branch? On my system, I could do it by running git rebase -i main, deleting commits that start with a bracket "[", fixing the conflict in AUTHORS.md twice, and running git rebase --continue once more.

@pmli I am currently working on it but there are a lot of issues while rebase so I am trying to solve them.

@pmli
Copy link
Member

pmli commented Jan 19, 2023

Ok, just let me know if you get stuck.

@pmli pmli merged commit 6532dbf into pymor:main Jan 20, 2023
@pmli
Copy link
Member

pmli commented Jan 20, 2023

Thanks @MohamedAdelNaguib and congrats for your first pyMOR contribution 🎉
Thanks @HenKlei and @artpelling for the review.

@MohamedAdelNaguib
Copy link
Contributor Author

Thank @pmli, @HenKlei and @artpelling for your help and support during this process.

@MohamedAdelNaguib MohamedAdelNaguib deleted the input-output_selection_bode_plot branch January 22, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:new-feature Introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Input-output selection in bode_plot
4 participants