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

StatisticalPSDWFE divide by zero #452

Open
philhinzatucsc opened this issue Aug 4, 2021 · 3 comments
Open

StatisticalPSDWFE divide by zero #452

philhinzatucsc opened this issue Aug 4, 2021 · 3 comments

Comments

@philhinzatucsc
Copy link

I have a newbie question/ bug. I have just started using poppy to estimate wavefront error effects on the PSF for Keck/SCALES. To do so, I have a created a FresnelOptical System model and then use StatisticalPSDWFE to create an error for one of the optics. This results in a warning:

. . ./poppy/wfe.py:349: RuntimeWarning: divide by zero encountered in power
psd = np.power(rho, -self.index) # generate power-law PSD

I see why it's complaining. r^-3 is infinite when r=0 (center of the array). So I went to wfe.py and added a really crude hack:
rho[rho == 0] = 0.00001 #get rid of infinity.

Now this works fine and I can happily continue modeling. Is this a real bug, or am I missing something about how to properly use StatisticalPSDWFE?

@mperrin
Copy link
Collaborator

mperrin commented Aug 4, 2021

@jlumbres could you please take a look at this issue and provide your take on this divide by zero issue with StatisticalPSDWFE? Thanks much..

@jlumbres
Copy link
Contributor

jlumbres commented Aug 5, 2021

Oh, hi @philhinzatucsc!

This issue happened with me when I wrote PowerSpectrumWFE. I did a similar solution, too. I overwrote the one pixel where spatial frequency k=0 to be 1*dk (spatial frequency spacing), did my math, then I overwrote the power at that same pixel location to be 0 after the math was done. I set the power to 0 because it was an arbitrary choice on my end. You can see my code here.

@philhinzatucsc
Copy link
Author

philhinzatucsc commented Aug 5, 2021

Ok, thanks for the confirmation. I am new enough to github and poppy that I am not sure what the next step is. For my own work, my internal hack works fine, but presumably I or you should be fixing this for others? I am not sure how to submit a bug fix.

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

3 participants