grid2dloess: LOESS smooth for tag PDT data

View source: R/grid2dloess.r

grid2dloessR Documentation

LOESS smooth for tag PDT data

Description

2-dimensional loess gridder. The smoothed value at each grid point is found from a weighted least-squares regression of the points within +/- SPAN_X and SPAN_Y of the grid point to a quadratic surface.

Usage

grid2dloess(data, xgrid, ygrid, span_x, span_y, xgrid_est = NULL,
  ygrid_est = NULL, flagout = TRUE)

Arguments

data

is a row vector array of the data to be smoothed. Missing value flag is NaN.

xgrid

is x locations of DATA. This must be the same size as DATA array.

ygrid

is y locations of DATA. This must be the same size as DATA array.

span_x, span_y

is filter half-power points (each a scalar). The larger the number, the more smoothing is performed. For the tricubic weighting function used here, the smoothing is approximately equivalent to using a running average of length equal to ~0.6*SPAN_X. However, the spectral characteristics of this smoother are usually much more desirable. The filter cutoff frequencies are approximately (1/SPAN_X, 1/SPAN_Y).

xgrid_est, ygrid_est

are column and row vectors, respectivly, where smoothed estimates are desired. The estimate grid can be irregular and non-monotonic. Any points in XGRID_EST and YGRID_EST outside of the range of XGRID and YGRID, respectively, will have SM_DATA=NaN.

flagout

is logical indicating whether you want to output FLAG as described below

Value

sm_data is a 2-dimensional array with LENGTH(XGRID_EST) columns and LENGTH(YGRID_EST) rows with the smoothed DATA.

flag is an array the same size as SM_DATA that is set to 1 when the smoothed estimate is outside the range of the data within +/- SPAN_X of that grid point and 0 otherwise. When the smoothed estimate is out of range, the estimate will be included in the output SM_DATA. This will typically occur near the edges of the DATA series or when SPAN_X only encompasses a small number of grid points in XGRID. While the smoothed estimate is usually only marginally out-of-range in these cases, care should be used when considering these points because the smoothed estimate may not be very good at that particular point. If there are many such points, consider using a larger SPAN_X (smoothing over more points).

Note

Translated to R by Camrin Braun, April 2014. Written by Peter Gaube in MatLab, December 8, 2009. Based on smooth2d_loess.m by Larry O'Neill, September 25, 2007


camrinbraun/tags2etuff documentation built on Feb. 24, 2025, 1:36 a.m.