On Tuesday, December 13, 2016 at 12:18:32 PM UTC-5, AGW wrote:
> On Tuesday, December 13, 2016 at 10:49:42 AM UTC+2, AGW wrote:
> > Hi,=20
> > If=20
> > lm=3D[623.2,624.5,665.3,778.2]=20
> > S=3Dss[0:300,0:400,0:18,0] ;;; an image=20
> > compute=20
> > x=3D=E2=88=91[(=E2=88=82^2 (s))/(=E2=88=82(lm)^2)] ;;; image
> > How can I do it using IDL?
> lm have 19 value, but I did not write all values, suppose=20
> x=3D=E2=88=91_i[(=E2=88=82^2(s))/(=E2=88=82 lm^2 )]]_i
Well, it's easy and it's hard. If you read the Wikipedia article about fin=
ite differences, it's easy. The expression for finite differences is,
=E2=88=82^2(s))/(=E2=88=82 lm^2) =3D ( s(lm+h) - 2 s(lm) + s(lm-h) ) /h^=
That's easy to express in IDL,
d2s_dlm2 =3D s*0 ;; Initialize to blank array
for i =3D 1, 17 do begin
h2 =3D (lm[i]-lm[i-1])*(lm[i+1]-lm[i]) ;; compute h^2 term
d2s_dlm2[*,*,i] =3D (s[*,*,i+1]-2*s[*,*,i]+s[i-1]) / h2
Note that it's not possible to compute the finite difference second derivat=
ive at the first and last LM position because there's not enough data to es=
Now you want to sum it. That's easy too,
x =3D total(d2s_dlm2,3)
But the problem is that the sum of a second derivative is more or less equi=
valent to the integral of a second derivative, i.e. just a single derivativ=
e. It's really equivalent to computing the mean slope of S. You don't hav=
e to do any of the second derivative stuff to do this. You should basicall=
y get the same answer by doing,
x =3D (s(*,*,18) - s(*,*,0))/(lm(18)-lm(0))
This is not quite true if LM is unevenly spaced.
So you really have to decide if this is what you want.
Did you mean to take an absolute value? Or square the second derivative bef=
ore summing it?