# IDL programming and data smoothing

1. Mar 17, 2006

### big man

I know this is a long shot, but I thought that I'd try my luck. I've just started programming in IDL and I'm wanting to smooth data. It's fine when I do low order binomial or running average smoothers, but whenever I get to higher order smoothers I get these lines going vertically down from the data.

|
| ________________
||.........................|
||.........................|
||.........................|
||.........................|
|__________________

Above is a crude example of this. The figure should just be a straight horizontal line, but instead it has vertical lines extending from the endpoints. The dots are just there so that the figure looks right when I post it.

I'd expect this to happen if I was defining too many points in the array and obviously it wouldn't have any data to smooth, but I swear I didn't give too many points for the smoothing.
Below is an example of the one smoother that doesn't have a problem and the higher order smoother where I do have the vertical line problem.
The array is 216 columns obviously.

LOW ORDER SMOOTHING WITHOUT VERTICAL LINES
rsmooth=fltarr(216)
rsmooth(0)=Co2(0)
rsmooth(215)=Co2(215)
for l=1,214 do rsmooth(l)=(Co2(l-1)+Co2(l)+Co2(l+1))/3.0
resultr=moment(rsmooth)
window, 0
plot, Date, rsmooth, background=255, color=0

HIGHER ORDER SMOOTHING WITH VERTICAL LINES
rsmooth5=fltarr(216)
rsmooth5(0)=Co2(0)
rsmooth5(215)=Co2(215)
for l=2,213 do rsmooth5(l)=(Co2(l-2)+Co2(l-1)+Co2(l)+Co2(l+1)+Co2(l+2))/5.0
resultr5=moment(rsmooth5)
window, 1
plot, Date, rsmooth5, background=255, color=0

N.B. I'm new to this so there is a good chance I'm missing something really obvious. If someone has an idea and can spare the time to check those few lines of the IDL code then I'd really appreciate it.
Thanks :)

Last edited: Mar 17, 2006