tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

deal with nans in my tutorial

Open EvanBianco opened this issue 10 years ago • 1 comments

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 avatar Jul 09 '15 16:07 EvanBianco

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

EvanBianco avatar Jul 09 '15 16:07 EvanBianco