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

deal with nans in my tutorial #19

Open
EvanBianco opened this issue Jul 9, 2015 · 1 comment
Open

deal with nans in my tutorial #19

EvanBianco opened this issue Jul 9, 2015 · 1 comment

Comments

@EvanBianco
Copy link

Need to deal with nans encountered in the despiking function, and in turn make sure that zeros are not encountered in the denominator when trying to compute reflection coefficient series.

@EvanBianco
Copy link
Author

I actually see this warning message as well, however it doesn't seem to throw an error. I think what is happening here is that the despike function isn't written to deal with nan values or missing values. I should update the notebook on GitHub, especially since it has been about a year and a half since I wrote this, and it's surely not as comprehensive or elegant as it could be / should be. In the meantime, let me suggest three changes to you, that you should be able to get you back on track.

Change 1: add the following two lines of code to the despike function.

curve = np.nan_to_num(curve)
curve_sm = np.nan_to_num(curve_sm)

Change 2: we need to undo this change when we convert slowness (dt) into pvelocity. We can't divide by zero, but we can (oddly enough) divide by a nan

so add the following line of code before computing the pvelocity

dt[dt==0] = np.nan

​Change 3: modify Z before computing reflection coefficients. Do this,​

rho[rho==0] = np.nan
Z = pvelocity * rho

instead of this...
Inline image 3
​So we don't encounter zeros in the denominator (which will cause an error) when doing this ,​
Inline image 4

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

1 participant