FUNCTION time_smooth, y, tim_arr0, width=width, npts=npts

;first deal with the time array.
   tsiz = size(tim_arr0) & ttyp = tsiz(tsiz(0)+1)
   numbers = ttyp EQ 1 OR ttyp EQ 2 OR ttyp EQ 3 OR ttyp EQ 4 OR ttyp EQ 5
   IF(numbers) THEN BEGIN
      IF(tsiz(0) EQ 2) AND (tsiz(1) EQ 7) THEN tim_sec = int2secarr(anytim2ints(tim_arr0)) $
        ELSE tim_sec = tim_arr0-tim_arr0(0)
   ENDIF ELSE tim_sec = int2secarr(anytim2ints(tim_arr0))

   ny = N_ELEMENTS(y)
   IF(ny LT 3) THEN BEGIN
      message, /info, 'Not enough elements for Smoothing.'
      RETURN, y
   ENDIF
   IF(N_ELEMENTS(tim_sec) NE ny) THEN message, /info, 'Array Mismatch, I''ll crash...'

;Ok, now the high time resolution array
   IF(KEYWORD_SET(npts)) THEN n = long(npts(0)) ELSE n = 10*ny
   IF(n LT ny) THEN n = ny      ;to be careful

   dtime = (tim_sec(ny-1)-tim_sec(0))/float(n-1)
   hi_time = tim_sec(0)+dtime*findgen(n)

;Smoothing parameter
   IF(KEYWORD_SET(width)) THEN w = width(0) ELSE w = 31
;interpolate, smooth, interpolate
   y1 = interpu_1d(y, tim_sec, hi_time)
   y1 = smooth(y1, w)
   y1 = interpu_1d(y1, hi_time, tim_sec)

   RETURN, y1
END