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

Added shift_field and outer_dot_shifted function to ElectroMagneticFi… #1916

Draft
wants to merge 1 commit into
base: pre/2.8
Choose a base branch
from

Conversation

prashkh
Copy link
Contributor

@prashkh prashkh commented Aug 22, 2024

…eldData Class

@momchil-flex Based on your suggestion a few weeks ago, I started adding functions to the ElectroMagneticFieldData class so that we can easily shift fields and do mode overlaps. Let me know if this is what you were thinking of for implementation. I checked the results of the new outer_dot_shifted with the results fromouter_dot when the relative shift is (0,0) and things are consistent.

@momchil-flex momchil-flex changed the base branch from pre/3.0 to pre/2.8 August 23, 2024 08:50
Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

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

Thanks @prashkh, this would certainly be super useful to have.

I had a somewhat different idea about how this can be incorporated in the code, but maybe I didn't convey it too well, or maybe you had your reasons to make some of these design decisions. But here's what I had in mind, let me think if you think this will work:

We can have something like a ElectromagneticFieldData.translated_copy method which allows you to translate the data along x, y, z. This does not interpolate - it just shifts all relevant data like the coordinates and the associated monitor position, as illustrated here. This was written very quickly and would need to be tested, and also I think we need to shift grid_expanded (and just overall take a look at what attributes field data contains and shift everything that needs shifting).

This first step is the nontrivial one, but after that doesn't everything just come for free? Our current outer_dot already handles data that are not on the same grid, and I think it handles even the case where the grid spans are not the same, but if not, it could be fixed to do so. So a user would just do something like

outer_dot_shifted = data1.outer_dot(data2.translated_copy(dx=5, dy=0))

Basically you won't need to re-interpolate to a uniform grid, you won't need to handle things like not knowing which dimensions exactly are the tangential ones, and you won't need to introduce a lot of duplicated code in your current outer_dot_shifted method.

Regarding the point that you don't need to care about which dimensions are the tangential ones, in my example above I assume the user knows that and uses the translated_copy method properly. That is to say we allow translating along x y and z and it's up to the user to translate along x and y if their normal direction is z, etc.

@prashkh
Copy link
Contributor Author

prashkh commented Aug 23, 2024

@momchil-flex thanks for the feedback and the detailed explanation. I think the approach you described makes sense now. Let me try to implement that sometime next week and I'll let you know if I run into any issues.

@caseyflex
Copy link
Contributor

Will this resolve this issue?
#1526

@momchil-flex
Copy link
Collaborator

Will this resolve this issue? #1526

Yeah I reference it in my comment. It just needs to be done a bit more carefully and tested.

@caseyflex
Copy link
Contributor

Will this resolve this issue? #1526

Yeah I reference it in my comment. It just needs to be done a bit more carefully and tested.

Maybe the link was wrong in your comment?

@momchil-flex
Copy link
Collaborator

momchil-flex commented Sep 3, 2024

Ah you are right sorry! Updated it just in case someone clicks it in the future.

@momchil-flex momchil-flex marked this pull request as draft November 5, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants