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

IndexError when calling "ReconstructLayer" #2

Closed
sachin4594 opened this issue Apr 13, 2022 · 2 comments
Closed

IndexError when calling "ReconstructLayer" #2

sachin4594 opened this issue Apr 13, 2022 · 2 comments

Comments

@sachin4594
Copy link

Hi,

I'm trying to visualize the epsilon profile of the patterned layer named "slab" in the example file "phc_slab_circ_hole_spectrum.py", using ReconstructLayer (as defined on line 309 of simulator.py).

I'm not entirely sure about the correct usage of ReconstructLayer but I'm just doing:
s.ReconstructLayer('slab', 100, 100) or s.ReconstructLayer('slab') (since nx and ny both seem to default to 101). In both cases, I get the error:

Traceback (most recent call last):
  File "phc_slab_circ_hole_spectrum.py", line 32, in <module>
    s.ReconstructLayer('slab')
  File "/home/sachin/miniconda3/lib/python3.7/site-packages/inkstone/simulator.py", line 337, in ReconstructLayer
    result = self.layers[name].reconstruct(nx, ny)
  File "/home/sachin/miniconda3/lib/python3.7/site-packages/inkstone/layer.py", line 395, in reconstruct
    for em in [fft.ifftshift(self.epsi_fs, axes=(0, 1)), fft.ifftshift(self.epsi_inv_fs, axes=(0, 1)), fft.ifftshift(self.mu_fs, axes=(0, 1)), fft.ifftshift(self.mu_inv_fs, axes=(0, 1))]]
  File "<__array_function__ internals>", line 6, in ifftshift
  File "/home/sachin/miniconda3/lib/python3.7/site-packages/numpy/fft/helper.py", line 121, in ifftshift
    shift = [-(x.shape[ax] // 2) for ax in axes]
  File "/home/sachin/miniconda3/lib/python3.7/site-packages/numpy/fft/helper.py", line 121, in <listcomp>
    shift = [-(x.shape[ax] // 2) for ax in axes]
IndexError: tuple index out of range

Could you please help me with this?

Thanks!

@alexysong
Copy link
Owner

Your syntax is correct; I cannot reproduce this error. Could you please attach your entire snippet?

@alexysong
Copy link
Owner

This is fixed.
You probably have called ReconstructLayer() before solving. This lead to error because the layer's information hasn't been computed. This is now fixed.

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

No branches or pull requests

2 participants