Skip to main content
  • Home
  • Documentation
  • FAQ
  • Downloads
  • Support
  • Current Release Notes
  • Ferret Users Guide
    • Users Guide Index
    • Commands Reference
    • 1. Introduction
    • 2. Data Set Basics
    • 3. Variables & Expressions
    • 4. Grids & Regions
    • 5. Animations & Gif Images
    • 6. Customizing Plots
    • 7. Handling String Data Symbols
    • 8. Working with Special Data Sets
    • 9. Computing Environment
    • 10. Converting to NetCDF
    • 11. Writing External Functions
    • Glossary
    • Appendix A: Functions
    • Appendix B: PPLUS Guide
    • Appendix C: Ferret-Specific PPLUS Enhancements
  • Previous Release Notes
  • Tutorials and Demos
    • Ferret Tour
    • DSG files: Discrete Sampling Geometries Demo
    • Ferret sorting demo
    • Fast Fourier Transforms demo
    • Empirical Orthogonal Functions demo
    • Ferret objective analysis demo
    • Ferret Palette Demo
    • Map projections
    • Ferret polygon vector demo
    • Ferret Graticules demo
    • Ferret Polytube Demo
    • Ferret Polymark Demo
    • Ferret Constant-Array demo
    • Ferret land_detail demo
    • COADS Tour
    • Levitus Tour
    • Use OPeNDAP
    • Ferret binary read demo
  • PyFerret
    • PyFerret Downloads and Install ../../faq/ferret-faqs.html
    • What is PyFerret?
    • Why use PyFerret?
    • PyFerret for the Ferret user
    • PyFerret command syntax: quick-start notes
    • PyFerret for the Python user
    • Graphics in PyFerret ?
    • New Ferret functionality
    • PyFerret Python functions and constants
    • PyFerret Python objects and methods
    • Ferret external functions in Python
    • Ferret Fortran external functions
    • PyFerret metadata-and-data dictionaries
  • OPeNDAP
    • OPeNDAP usage in Ferret
    • Use OPeNDAP Demo
    • Test OPeNDAP

FILL_XY

FILL_XY (A, B, C) Fills missing values with average nearest neighbor values in X and Y

 

Arguments:

DATA

variable to fill in X and Y

 

 

MASK

Fill only where MASK=1

 

 

N

number of fill-passes through the data

 

Result Axes:

X

Inherited from DATA

 

Y

Inherited from DATA

 

Z

Inherited from DATA

 

T

Inherited from DATA

This function was contributed by Martin Schmidt.

FILL_XY(data, mask,n) is a low order 2-dimensional fill utility. Data points with missing values are filled by equal weight averaging over all valid pointsof the 8 neighbors. The procedure is repeated n-times, each step starts with the result of the previous step. FILL_XY is especially useful for smooth extrapolation.

Applications can be found when mapping coarse grid ocean data to a finer grid. This is often needed for example to generate initial fields of ocean models from climatological data sets. Interpolation may fail for grid points of the destination grid with positions between an ocean point and a land point on the coarse grid. Applying FILL_XY to extrapolate ocean values into land before the data are mapped to the fine grid helps to avoid undefined values on the destination grid.

Example: generate a field with climatological SST, at the grid of etopo5 by interpolation from the coads climatology dataset:

use coads_climatology
use etopo5
 
! Choose a region to see the effect 
! (here Western Europe)
 
set region/x=-10:30/y=40:70
 
! View SST on its original grid
 
shade/l=1/d=1 sst
go land_detail thick " " light_blue
FILL_XY example, plot 1. The original coarse grid

 

! Define a land mask for the fine destination grid
 
let mask_fine= if rose[d=2] lt 0 then 1 else 1/0
shade/l=1/d=1 sst[g=rose[d=2]]*mask_fine
go land_detail thick " " light_blue
 
! Note that there remain large areas with missing 
! data in the ocean, for instance in the Baltic Sea 
! and the Mediterranean.
FILL_XY example, plot 2. The variable regridded to a finer grid

 

! Extrapolate the source data beyond the sea 
! before regridding to the fine grid of etopo5. 
! mask_fill is "1" everywhere.
 
let mask_fill=missing(sst/sst,1)
let sst_fill= fill_xy(sst,mask_fill,2)
 
! Now all ocean points at the fine grid are defined.
 
shade/l=1/d=1 sst_fill[g=rose[d=2]]*mask_fine
 
go land_detail thick " " light_blue
FILL_XY example, plot 3. The variable regridded and points filled with fill_xy