tutorials
tutorials copied to clipboard
deal with nans in my tutorial
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.
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