I have received data values for a spline (which was already fit to some ndvi data). I just have only the data points of the spline and do not know the function that the spline follows. My goal is to find the first and second derivatives of the fitted spline. After reading up several posts most suggests, using a finite difference method approximation to calculate the derivatives of the spline data points.

This can be achieved using pythons (numpy package) diff method which calculates the difference between successive data points. (out[i] = a[i+1] - a[i]) where a is an array. From what I presume the derivative should be the difference in successive points divide by delta x (which is one day in this situation).

ndvi_vals = df['fitted.values'].to_numpy()
successive_diff = np.diff(ndvi_vals)
#deravative = successive_diff / 1 day
ndvi_derv = successive_diff / 1 

This part of the code calculates this. However, when I plot the original spline and its derivative, it's not what I expected. The first derivative has a far smaller amplitude and is well below the spline. It doesn't, for example, look similar to how a sin function and its derivative (cos function) would look like. Any ideas about what I may be doing wrong?.

Access to the data and jupyter notebook is here : https://github.com/imantha-das/GEE/blob/master/Finding%20Deravatives/Finding_Derivatives.ipynb

enter image description here

Note: Ndvi is the normalized difference vegetation index. When you look at remotely sensed data/imagery, it is the : (near-infrared band - infrared band) / (near-infrared band + infrared band). It represents at point in time how photosynthetically active the vegetation is

  • $\begingroup$ Can you please explain "ndvi"? $\endgroup$ – kjetil b halvorsen Mar 10 at 13:41
  • $\begingroup$ Ndvi is normalised vegetation index. When when you look at remotely sensed data / imagary, it is the (near infrared band - infrared band) / (near infrared band+ infrared band). It represents at point in time how photosynthetically active the vegetation is. $\endgroup$ – imantha Mar 10 at 15:01
  • $\begingroup$ Can you please add that new information to the Q itself? Not everybody read comments ... $\endgroup$ – kjetil b halvorsen Mar 10 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.