-
-
Notifications
You must be signed in to change notification settings - Fork 39
Math FastFourierTransformation
Serge Stinckwich edited this page Jun 26, 2018
·
1 revision
this package is just an adaptation of Squeaks fft package. you can use it eg like this:
"first we construct some data to play with:"
data := (1 to: 11.23 by: 0.01) collect: [:i|i sin + (i *3) cos].
"the data for a FastFourierTransform must have a size of a power of two:"
data size." -->1024" "that is ok (you'll get an error otherwise,
when you initialize the FastFourierTransform)"
"lets blur that data a bit:"
blurredData := data collect: [:i|i + Float random -0.5].
"lets have look with Roassal2 (can be found and loaded via
the Configuration Browser) at our data"
b := RTGrapher new.
ds := RTDataSet new.
ds noDot.
ds points: (1 to: 1024).
ds y: [:i| blurredData at: i].
ds x: #yourself.
ds connectColor: (Color green).
b add: ds.
ds := RTDataSet new.
ds noDot.
ds points: (1 to: 1024).
ds y: [:i| data at: i].
ds x: #yourself.
ds connectColor: (Color blue).
b add: ds.
b
"you initialize a FastFourierTransform simply like that:"
f:=FastFourierTransform data:blurredData.
"and do the transform:"
f transform.
"lets have look at the transform:"
a := RTGrapher new.
ds := RTDataSet new.
ds noDot.
ds points: (1to:1024).
ds y: [:i|f imaginaryData at:i].
ds x: #yourself.
ds connectColor: (Color blue).
a add: ds.
ds := RTDataSet new.
ds noDot.
ds points: (1to:1024).
ds y: [:i|f realData at:i].
ds x: #yourself.
ds connectColor: (Color red).
a add: ds.
a build.
a view openWithMenu .
"the boring part is obviously in the middle, lets have
a more detailed look at this part:"
a := RTGrapher new.
ds := RTDataSet new.
ds noDot.
ds points: (14to:1010).
ds y: [:i|f imaginaryData at:i].
ds x: #yourself.
ds connectColor: (Color blue).
a add: ds.
ds := RTDataSet new.
ds noDot.
ds points: (14to:1010).
ds y: [:i|f realData at:i].
ds x: #yourself.
ds connectColor: (Color red).
a add: ds.
a build.
a view openWithMenu .
"it seems that the boring part is within a +-0.75 range.
we simply set that part to zero"
f chop:0.75.
"and then do an inverse transform:"
f inverseTransform.
"now lets see what we got as a smoothed form of the blurred data:"
ds := RTDataSet new.
ds noDot.
ds points: (1to:1024).
ds y: [:i|f realData at:i].
ds x: #yourself.
ds connectColor: (Color red).
b add: ds.
b build.
b view open.