1 | pro fteqs,q,int,r,ft,lorch=lorch |
---|
2 | |
---|
3 | ; FT of int(Q) -> ft(r) the meaning of Q and r may be reversed ; actually it calculates sum i(Q) sin(Qr)/(Qr) Q^2 dQ |
---|
4 | |
---|
5 | if (not var_defined(lorch)) then lorch=0 |
---|
6 | |
---|
7 | dq=q(1)-q(0) |
---|
8 | ; Q or r is assumed to be equidistant |
---|
9 | |
---|
10 | int1=int*q^2 |
---|
11 | ; multiply with Q^2 beforehand |
---|
12 | |
---|
13 | nq=n_elements(q) |
---|
14 | if n_elements(r) eq 0 then r=(dindgen(nq))*!pi/max(q) ; if r is undefined, define it. |
---|
15 | |
---|
16 | nr=n_elements(r) |
---|
17 | ft=dblarr(nr) |
---|
18 | ; define ft as a double precision vector |
---|
19 | |
---|
20 | if (lorch eq 0) then begin&for i=0,nr-1 do begin&x=q*r(i)& ft(i)=total(int1*j0(x)) &end&end |
---|
21 | |
---|
22 | if (lorch ne 0) then begin&for i=0,nr-1 do begin&x=q*r(i)& ft(i)=total(int1*j0(x)*j0(!pi*q/max(q))) &end&end |
---|
23 | |
---|
24 | ; do the summation |
---|
25 | |
---|
26 | ft=ft*dq |
---|
27 | ; multiply with dQ afterwards |
---|
28 | return |
---|
29 | end |
---|
30 | |
---|
31 | function j0,x |
---|
32 | ; this function calculates sin(x)/x, avoiding division by zero (sin(0)/0=1) |
---|
33 | |
---|
34 | y=x |
---|
35 | w=where(x gt 1e-20,n) |
---|
36 | if n gt 0 then y(w)=sin(x(w))/x(w) |
---|
37 | w=where(x lt 1e-20,n) |
---|
38 | if n gt 0 then y(w)=1.d0 |
---|
39 | return,y |
---|
40 | end |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|