# Re: FLN interpolation (controlling the gap width to fill)

```
```
--- Begin Message ---
```Hi Ed,

With a little effort you can do it with the current Ferret transformation.

The transformations @CIA, and @CIB (see docs pasted below) allow you to know how far you
are from a valid point. You can use these to create a mask showing how large the gaps
are:

let gap_size = my_var[i=@cia] + my_var[i=@cib]
let gap_mask = if gap_size LE BIGGEST_GAP_ALLOWED THEN 1

Now you  use

Or you can combine the whole mess into one expression (bigger than 15 point gap to be
rejected):

let my_answer = IF (my_var[i=@cia]+my_var[i=@cib]) LE 15 THEN my_var[i=@fln]

Alternatively, you can use the CDA & CDB transformations and work in terms of gaps
measured in time or distance instead of number of missing points.

- steve

=========================================

2.4.29 @CDA--closest distance above

The transformation @CDA will compute at each grid point how far it is to the
closest valid point above this coordinate position on the
indicated axis. The distance will be reported in the units of the axis. If a
given grid point is valid (not missing) then the result of @CDA for
that point will be 0.0.

2.4.30 @CDB--closest distance below

The transformation @CDB will compute at each grid point how far it is to the
closest valid point below this coordinate position on the
indicated axis. The distance will be reported in the units of the axis. If a
given grid point is valid (not missing) then the result of @CDB for
that point will be 0.0.

2.4.31 @CIA--closest index below

The transformation @CIA will compute at each grid point how far it is to the
closest valid point above this coordinate position on the
indicated axis. The distance will be reported in terms of the number of points
(distance in index space). If a given grid point is valid (not
missing) then the result of @CIA for that point will be 0.0.

2.4.32 @CIB--closest index below

The transformation @CIB will compute at each grid point how far it is to the
closest valid point below this coordinate position on the
indicated axis. The distance will be reported in terms of the number of points
(distance in index space). If a given grid point is valid (not
missing) then the result of @CIB for that point will be 0.0.

Ed Harrison wrote:

> Hi Steve
>
> how hard would it be to implement a filling routine that only fills gaps if there are
> data within 'n' points of the grid point, where one specifies 'n'?
>
> there have been a number of situations where such a function would be helpful to
> me...because i wanted to be able to tell someone that i'd only filled gaps of 'n' (or
> 2n) width or less.
>
> hope you had a fine Christmas!
>
> ed
>
> Steve Hankin wrote:
>
> > Hi Gerard,
> >
> > @FLN fills in gaps, regardless of the width of the gap, as long as it has a
> > valid data point on either side of the gap from which to interpolate. The
> > optional "n" parameter (see
> > http://ferret.wrc.noaa.gov/Ferret/Documentation/Users_Guide/v50/chapter3.html#FLN
> > transformation\$linear interpolation) tells Ferret how far to read beyond the
> > edges of the requested region for valid data points from which to interpolate.
> >
> >     - steve
> >
> > ======================================
> >
> > Gerard Eldin wrote:
> >
> > > Hi fereteers,
> > >
> > > There something I don't understand with the @FLN:n interpolation function.
> > > I have a gappy time series of temperatures that I want to interpolate, but
> > > without filling gaps larger than, say, 6 months. When I use @FLN:n, every
> > > gap, even 12 months long, is filled by linear interpolation, it doesn't
> > > seem to care what value of n I give.
> > >
> > > Could it be a bug ?
> > >
> > > Sincerely,
> > >
> > >       --------------------------------------------------
> > >        Dr. Gerard ELDIN,          Tel: 00 5 61 33 28 72
> > >        IRD, LEGOS/GRGS,           Fax: 00 5 61 25 32 05
> > >        18 Av. Edouard Belin,
> > >        31401 TOULOUSE CEDEX 4     Gerard.Eldin@cnes.fr
> > >        FRANCE                     or     eldin@ird.fr
> > >       --------------------------------------------------
> >
> > --
> > Steve Hankin
> > NOAA/PMEL, 7600 Sand Point Way NE, Seattle, WA 98115-0070
> > ph. (206) 526-6080 -- FAX (206) 526-6744

--
Steve Hankin
NOAA/PMEL, 7600 Sand Point Way NE, Seattle, WA 98115-0070
ph. (206) 526-6080 -- FAX (206) 526-6744

```
--- End Message ---