Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: datafilter - Constructor Up: mathematics - Module Previous: lsfit.test - Function


datafilter - Tool



Package utility
Module mathematics


Postscript file available

Filtering operations on data arrays

include "image.g"

Constructors
datafilter Construct a Datafilter tool
Functions
done Destroy this tool
filter Filter a data array
medianclip Median clip a data array


Summary

The Datafilter tool provides some simple filtering operations for Glish arrays.

Here is an example where we create a noisy sinusoid with outliers. First we filter the data; you can see how the median filter removes outliers (as well as compressing the noise). Then we also median clip the original data showing how the outliers are effectively removed.



Example
# Generate Gaussian distribution

- include 'randomnumbers.g'
- n := 500
- r := randomnumbers();
- g := r.normal(0.0, 0.5, n);
- r.done()

# Generate data ; sin wave plus noise

- x := (1:n) / 10 / pi
- y := sin(x) + g
#
- include 'pgplotter.g'
- p0 := pgplotter ()
- p0.plotxy (x, y, title='Sin + noise', plotlines=F)

# Now add some outliers

- ii := 1:n
- for (i in ii[ii%50 == 0]) {
y[i] *:= 20;
}
#
- p1 := pgplotter()
- p1.plotxy (x, y, title='Sin + noise + outliers', plotlines=F)

# Generate Datafilter tool

- include 'datafilter.g'
- df := datafilter();

# Median filter returns filtered data

- y2 := df.filter (y, method='median', width=10)
#
- p2 := pgplotter()
- p2.plotxy (x, y2, title='Median filtered', plotlines=F)

# Median clip returns a Boolean mask

- m := df.medianclip (y, width=10, clip=5)
#
- p3 := pgplotter()
- p3.plotxy (x, y, title='Median clipped', plotlines=F, mask=m)




next up previous contents index
Next: datafilter - Constructor Up: mathematics - Module Previous: lsfit.test - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15