-
Notifications
You must be signed in to change notification settings - Fork 0
/
bc-fourier-cont.m
51 lines (35 loc) · 1.28 KB
/
bc-fourier-cont.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(* Continuous Fourier transforms to approximate data such as
solar/lunar positions *)
(* given a collection of data, return the cosine-ish function that
approximates it. From
http://stackoverflow.com/questions/4463481/continuous-fourier-transform-on-discrete-data-using-mathematica
*)
(* TODO: dislike returning f[x] instead of a pure function f, but
can't find fix for now *)
(* tmp isn't mirrored so this data [obtained from
http://ssd.jpl.nasa.gov/?horizons] isn't available in this repo [but
will be if I find it more useful] *)
data = ReadList["/home/barrycarter/BCGIT/tmp/moondec.txt"]
data = Table[43.2316 + 43.9356*Cos[81.7904*x/1000 - 1.59204], {x,1,1000}]
superfourier[data]
(* defining h1 to be 0 is silly, but useful; h2 is effectively
superfourier on the data *)
h[0] = 0 &
h[n_] := h[n] = refine[data,h[n-1]]
t[n_] := Table[h[n][x], {x,1,Length[data]}]
ListPlot[data-t[0]]
ListPlot[data-t[1]]
ListPlot[data-t[2]]
(* 1.5 deg error below *)
ListPlot[data-t[3]]
(* upto 1.0 deg error below *)
ListPlot[data-t[5]]
(* 0.5 below *)
ListPlot[data-t[7]]
ListPlot[data-t[11]]
ListPlot[data-t[15]]
ListPlot[data-t[25]]
showit := Module[{},
Export["/tmp/math.jpg",%, ImageSize->{800,600}]; Run["display /tmp/math.jpg&"]]
normalized = (data-Mean[data])/Max[Abs[data]]
acn = ArcCos[normalized]