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

Getting position data for fields #109

Open
DerekK44 opened this issue Nov 15, 2019 · 2 comments
Open

Getting position data for fields #109

DerekK44 opened this issue Nov 15, 2019 · 2 comments

Comments

@DerekK44
Copy link

Hello!
Is there a way of getting the exact (x,y,z) position for each element in the numpy arrays returned for functions like ms.get_dfield(band)?

Ideally, something like the get_array_metadata() function implemented in MEEP. Right now I am linearly interpolating from the min <-> max values of the simulation region, but this seems to be shifted off by a fraction of a pixel or so.

Let me know if I can clarify my question.

Thanks!

@stevengj
Copy link
Collaborator

stevengj commented Nov 18, 2019

Suppose you have 3 lattice vectors (R₁,R₂,R₃), and the number of points in each direction are (N₁,N₂,N₃). Then for a given pixel indexed by (i₁,i₂,i₃) where iₖ runs from 0 to Nₖ-1, the corresponding Cartesian coordinate vector is (i₁/N₁ - ½) × R₁ + (i₂/N₂ - ½) × R₂ + (i₃/N₃ - ½) × R₃.

Right now I am linearly interpolating from the min <-> max values of the simulation region, but this seems to be shifted off by a fraction of a pixel or so.

This will be off because of the periodicity — the min and max coordinates are actually the same point and it is not stored twice. Hence the last pixel is actually slightly before the max.

@DerekK44
Copy link
Author

Thank you. This answers my question exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants