I am getting NaN for all calculated SPI https://colab.research.google.com/drive/158Qci_a3tb4GwVlCC_qFBp2KIhXC73YB#scrollTo=0CWA77m8gL9e The code can be seen here. It contains two examples. The first one is working but second is not.