[Thread Prev][Thread Next][Index]

Re: [ferret_users] Interpolation 2D issue



Sorry for the repeat messages but I realized I made an error in my last response.

For filling over blanks before smoothing, use FNR (nearest neighbor), not FLN (linear interpolation) as I had originally written. You would NOT want to fill linearly across a gap where the values could be different on the two sides. That could lead to the smoothing operation being contaminated by values from a different region entirely. However, it might be reasonable to use FNR which would simply extend the nearby coastal value over land. Following FNR, the smoothing operation would place successively more weight on the coastal value as you got closer to the edge, which might be desirable.

Since Ferret makes it so easy to try these various techniques, it would be well worth trying them all out before settling on a final choice.

BK


On Mar 11, 2011, at 11:34 AM, William S. Kessler wrote:

Another approach is the first fill (FLN) your field by extending the endpoints (think carefully and test what this will do in a 2-d field across, say, a peninsula or island). Then you can apply SBX or SPZ or whatever, then blank the result where the original field is blank.

But, as always, do not do this blindly. Any of these choices imply certain assumptions about what is really going on at the edges.

BK

On Mar 11, 2011, at 10:30 AM, William S. Kessler wrote:

That is a statistics problem without a unique answer. It is a matter of estimating the N-member smoothed value where fewer than N members are known. Assumptions must be made.

One way to do this in Ferret is SCAT2GRIDGAUSS, which is simply a weighted average that will compute values according to chosen distance scales XSCALE, YSCALE and CUTOFF. If you are starting with gridded data and want to keep the same grid, take the existing gridpoints as XPTS,YPTS; it will then be a smoothing operator that extends to (or past) the edges.

Another is to use SBX or SPZ with sequentially increasing length:

! First define smoothed fields of varying length:
let sm3 = original_data[x=@sbx:3]
let sm5 = original_data[x=@sbx:5]
let sm7 = original_data[x=@sbx:7]

! Now use each one where it exists:
let smootha = if sm7 then sm7 else sm5
let smoothb = if smootha then smootha else sm3
let smooth = if smoothb then smoothb else original_data

One advantage of an approach like this is that it reduces the smoothing scale at the boundaries. That will often be appropriate for a coastal ocean, where the scales are typically smaller at the coastal margins. SCAT2GRIDGAUSS, on the other hand, will apply the same smoothing everywhere.

Billy K

On 11 Mar 2011, at 8:48 AM, Szymon Roziewski wrote:

Hi Ferreters,
I am wandering if there exists any functions which do almost the same as SBX and SHN but on the boundary where there are not sufficient number of neighbours they just take the neighbouring sites only at the interior direction where the neighbours exist.
They could really help me.

kind regards,
Szymon Roziewski

2011/3/11 Szymon Roziewski <szymon.roziewski@xxxxxxxxx>
Yes, I found it.
But when I was searching through the manual pdf I had to overlook it.
Thank you.

2011/3/11 Martin Schmidt <martin.schmidt@xxxxxxxxxxxxxxxxx>

Please go to the ferret web site, documentation, open the index, click "m" and scroll down
to "missing function"

Best,
martin
Szymon Roziewski wrote:
Hi Martin,
It looks very nice.
I have to try out this but I don't really know what the function missing does. I had a look at manual and searched ferret site but there's no anything about this function.

Kind regards,
Szymon Roziewski

2011/3/9 Ansley Manke <Ansley.B.Manke@xxxxxxxx <mailto:Ansley.B.Manke@xxxxxxxx >>


 Hi -
 We had noticed recently that documentation for fill_xy was missing
 from the manual. Your email here gives a nice example that we can
 use there.

 Ansley


 On 3/9/2011 7:16 AM, Martin Schmidt wrote:

     Hi,
     you are right, the documentation did not find its way into the
     manual. It is easy anyway. The mask needs to be
     1 where filling is allowed and zero otherwise. Please try the
     following

     yes? use coads_climatology
     yes? let mask=missing(sst/sst,1)
     yes? shade/l=1 mask
     yes? shade/l=1 fill_xy(sst,mask,5)
     Filling is allowed

     !Now missings at land
     yes? let mask=sst/sst
     yes? shade/l=1 mask
     yes? shade/l=1 fill_xy(sst,mask,5)
     Nothing is filled.

     And now:
     yes? let mask= if y[gy=sst] gt 0 then missing(sst/sst,1) else
     sst/sst
     yes? shade/l=1 fill_xy(sst,mask,5)

     Now filling happens in the northern hemisphere.

     Hope this helps,
     Martin

     Szymon Roziewski wrote:

         Dear Martin / Ferreters,
         I have problem with using fill_xy function. I saw some
         examples and read sth in the ferret archives but I still
         stuck.
         I try to explain my issue.
         This is reading an ice field and putting into a lndseaf. I
         also quote the grid definition.

DEFINE AXIS/X=-5.666666667:5.25:0.083333333/unit=degree xlon
         DEFINE AXIS/Y=-2.0:10.0:0.083333333/unit=degree ylat
         DEFINE GRID/x=xlon/y=ylat grid_xlon_xlat
file/skip=1/format=(80f1.0/52f1.0)/columns=132/ grid=grid_xlon_xlat/var=lndseaf
         ICE.DAT

         Then I interpolate the lndseaf onto a fine grid.

DEFINE AXIS/X=-5.666666667:5.25:0.010416667/unit=degree xfine
         DEFINE AXIS/Y=-2.0:10.0:0.010416667/unit=degree yfine !1/8
         DEFINE GRID/x=xfine/y=yfine grid_xfine_yfine
         let ice_regridded lndseaf[gxy=grid_xfine_yfine]

         What I did next was make the mask.

         let mask = ice_regridded/ice_regridded

         And I used the mask with fill_xy as the following

         let ice_ext = fill_xy(ice_regridded,mask,5)

         But It didn't change anything. I tried out using different
         values of third argument of fill_xy. However, I didn't
         improve at all.
         So, I think either I was using fill_xy badly or I
         misunderstood something.

         I also tried out FLN function as follows

         let ext = ice_regridded[x=@FLN:50,y=@FLN:50]

         But this resulted with no changes to the ice_regridded as
         well.
         I attach ICE.DAT to make it more real.

         Kind regards,
         Szymon Roziewski



         2011/3/9 Martin Schmidt <martin.schmidt@xxxxxxxxxxxxxxxxx
         <mailto:martin.schmidt@xxxxxxxxxxxxxxxxx>
         <mailto:martin.schmidt@xxxxxxxxxxxxxxxxx
         <mailto:martin.schmidt@xxxxxxxxxxxxxxxxx>>>

            Dear Szymon,

            you may use fill_xy(data, mask, 2) before you filter
         data. This
            extrapolates the data smoothly into land by two points
         and the
            filter @SBX and @SHN
            can do something reasonable near land too. Applying
         your land mask
            later removes remaining extrapolated points.

            Greetings,
            Martin

            Szymon Roziewski wrote:

                Dear Ferreters,

                I have an ice field that is a matrix filled by 0 or
         1. Because
                of weak resolution I need it to be interpolated on
         a finer grid.
                I tried out two approaches.
                The first, I interpolated with using @SBX and @SHN
         functions.
                Basically, I got neat result except to the boundary
         where I
                got a lack of data. Because this functions don't
         have data to
                interpolate and ending up with 0 value.
                As the second I used scat2gridgauss_xy function
         which gave me
                smoother result but near the boundary I got the ice
         that
                should not to be. I think that this function is do
         smooth the
                data sometimes to much.

                Have any of you had something similar with it?
                Maybe there are some good ferret functions to
         interpolate ice
                field which is 0 or 1.

                I attach two graphics for better explanation.

                Kind regards,
                Szymon Roziewski





         --             Z wyrazami szacunku,
         Szymon Roziewski





--
Z wyrazami szacunku,
Szymon Roziewski




--
Z wyrazami szacunku,
Szymon Roziewski



--
Z wyrazami szacunku,
Szymon Roziewski

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
William S. Kessler
NOAA / Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115 USA

william.s.kessler@xxxxxxxx
Tel: 206-526-6221
Fax: 206-526-6744
Web: http://www.pmel.noaa.gov/people/kessler





[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement