1. Enter the following command to create a sinewave function with a frequency that increases over time and store it in a variable called original:The FINDGEN function returns a floating-point array in which each element holds the value of its subscript, giving us the increasing time values upon which the sinewave is based. The sine function of each time value divided by 35 and raised to the 2.5 power is stored in an element of the variable original.original=sin((findgen(200)/35)^2.5)
2. To view a quick plot of this dataset, shown in the following, enter:plot,original

3. Now add some uniformly-distributed random noise to this dataset and store it in a new variable:noisy=original+((randomu(seed,200)-.5)/2)4. Now plot the array:plot,noisy

5. Display the original dataset and the noisy version simultaneously by entering the following commands:The XTITLE and YTITLE keywords are used to create the X and Y axis titles. The OPLOT command plots the noisy dataset over the existing plot of original without erasing. Setting the THICK keyword causes the default line thickness to be multiplied by the value assigned to THICK, so you can differentiate between the data. This result can be seen in the following figure.plot, original, xtitle="Time",ytitle="Amplitude",thick=36. Then overplot the previous data:oplot,noisy

1. Create a new variable to hold the smoothed dataset by entering the following command:The TITLE keyword draws the title text centered over the plot. Notice that while SMOOTH did a fairly good job of removing noise spikes, the resulting amplitudes taper off as the frequency increases.smoothed=smooth(noisy,5)2. Now plot your new data set:plot,smoothed,title='Smoothed Data'

1. Create a floating point array using FINDGEN which sets each element to the value of its subscript and stores it in the variable y by entering:
y=[findgen(100),findgen(100)-100]
2. Next, make the last 99 elements of y a mirror image of the first 99 elements:
y[101:199]=reverse(y[0:98])
3. Now, create a variable filter to hold the filter function based on y:
filter=1.0/(1+(y/40)^10)
4. Finally, plot:
plot,filter

5. Now we can use a lowpass filter on the noisy dataset and store the filtered data in the variable lowpass by entering:
lowpass=fft(fft(noisy,1)*filter,-1)
6. Then plot:
plot,lowpass

7. The same filter function can be used as a high-pass filter (allowing only the high frequency or noise components through) by entering:
highpass=fft(fft(noisy,1)*(1.0-filter),-1)
8. Then plot:
plot,highpass

1. To display all plots at the same time with two columns and three rows, enter:
!p.multi=[0,2,3]
2. Now, display original dataset, upper-left:
plot,original,title='Original (Ideal) Data'
3. Next, display noisy dataset in the upper-right:
plot,noisy,title='Noisy Data'
4. Display filter function, middle-left. The SHIFT function was used to show thefilters peak as centered.
plot,shift(filter,100),title='Filter Function'
5. Now, display low-pass filtered dataset in the middle-right:
plot,lowpass,title='Lowpass Filtered'
6. Display high-frequency noise, lower-left:
plot,highpass,title='Highpass Filtered'
7. Finally, display the SMOOTH function dataset for comparison with the low-pass filtered data in the lower right.
plot, smoothed, title = 'Smoothed with Boxcar average'

8. Before continuing with the rest of the chapters, reset the plotting window to display a single image by entering the command:!p.multi = 0
| This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528. | ||||||||||||
|
HOME |
QUESTIONS |
FEEDBACK
|
||||||||||||
|
||||||||||||