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

re-instate undocumented get_array_slice_dimensions in Python interface #1464

Merged
merged 1 commit into from Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions python/simulation.py
Expand Up @@ -3299,6 +3299,28 @@ def get_array_metadata(self, vol=None, center=None, size=None, dft_cell=None,
return points,weights
return tuple(tics) + (weights,)

def get_array_slice_dimensions(self, component, vol=None, center=None, size=None):
"""
Computes the dimensions of an array slice for a particular `component` (`mp.Ez`, `mp.Ey`, etc.).

Accepts either a volume object (`vol`), or a `center` and `size` `Vector3` pair.

Returns a tuple containing the dimensions (`dim_sizes`), a `Vector3` object
corresponding to the minimum corner of the volume (`min_corner`),
and a `Vector3` object corresponding to the maximum corner (`max_corner`).
"""
if vol is None and center is None and size is None:
v = self.fields.total_volume()
else:
v = self._volume_from_kwargs(vol, center, size)
dim_sizes = np.zeros(3, dtype=np.uintp)
corners = []
_,_ = mp._get_array_slice_dimensions(self.fields, v, dim_sizes, False, False, component, corners)
dim_sizes[dim_sizes==0] = 1
min_corner = corners[0]
max_corner = corners[1]
return dim_sizes, min_corner, max_corner

def get_eigenmode_coefficients(self, flux, bands, eig_parity=mp.NO_PARITY, eig_vol=None,
eig_resolution=0, eig_tolerance=1e-12, kpoint_func=None, direction=mp.AUTOMATIC):
"""
Expand Down