laboratory in oceanography: data and methods gridding and ... · • write down the general...

25
Sundermeyer MAR 550 Spring 2020 1 Laboratory in Oceanography: Data and Methods MAR550, Spring 2020 Miles A. Sundermeyer Gridding and Interpolation

Upload: others

Post on 29-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 1

Laboratory in Oceanography:

Data and Methods

MAR550, Spring 2020

Miles A. Sundermeyer

Gridding and Interpolation

Page 2: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 2

The Problem: Certain analyses require regularly sampled series with equally space measurements in space or time. Yet, frequently we have gaps in our data, or else inherently irregular data.

Gridding and Interpolation Filling Gaps

Page 3: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 3

Gridding and Interpolation Filling Gaps (cont’d)

• Equipment failure

• Weather conditions (ship, satellite)

• Editing out errors

• Inherent sampling limitations (cannot be everywhere all the time)

• Use of historical data, which often had different goals (e.g., analyzing

the mean state of the ocean)

• Geographic distribution (moorings, buoys, ships) of monitoring stations

is usually not uniformly spaced

• Resolving smaller dynamics

Page 4: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 4

Gridding and Interpolation Basic Interpolation Theory

Example: Linear Interpolation

Fit a straight line between pairs of sequential data points, choosing interpolated

values at the appropriate positions along the fitted line.

Page 5: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 5

Gridding and Interpolation Basic Interpolation Theory (cont’d)

Example: Linear Interpolation

𝑦 𝑥 = 𝑦 𝑥1 +𝑥 − 𝑥1𝑥2 − 𝑥1

𝑦 𝑥2 − 𝑦 𝑥1

Assume x is distance, x1 = 3 km, x2 = 6 km, wish to evaluate y(x) at x = 4.5 km.

Assume y = y(x), with observations y(x1) = 22, y(x2) = 12. What is y @ x=4.5?

Linear Interpolation = straight line = first order polynomial

Page 6: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 6

Polynomial interpolation more generally used to interpolate between more than

two points simultaneously.

Examples:

• Through 3 points we can find a unique polynomial of what order?

• Through 10 points we can find a unique polynomial of what order ?

• Methods to look for are Vandermonde, Lagrange and Newton.

• f(x) = a0 + a1x1 + a2x2 + … + amxm

• All coefficients, an, influence all of x. Can determine m by trial and error.

Check by comparing the residuals.

Gridding and Interpolation Polynomial Interpolation

Page 7: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 7

Vandermonde Matrix

Consider data with underlying function:

p(x) = 3.2 x7 - 4.1 x4 + 9.2 x2 + 1.2 (i.e., order 7 polynomial)

Suppose we have 3 (x, y) point pairs: (2, 5), (3, 6), (7, 4)

and we want to fit a quadratic polynomial through these points.

General form is p(x) = c1 x2 + c2 x + c3

Thus, if we were to simply evaluate p(x) at these 3 points, we get 3 equations:

p(2) = c1 4 + c2 2 + c3 = 5 p(3) = c1 9 + c2 3 + c3 = 6 p(7) = c1 49 + c2 7 + c3 = 4

Gridding and Interpolation Polynomial Interpolation (cont’d)

Page 8: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 8

Vandermonde Matrix (cont’d)

This, however, is a system of equations.

To solve:

• Write down the general polynomial of degree n - 1

• Evaluate the polynomial at the points x1, ..., xn

• Solve the resulting system of linear equations.

Rather than performing all of these operations, can simply write down the problem in the form:

y = Vc

where y is the vector of y values, c is the vector of coefficients (‘x’), and V is the Vandermonde matrix. (e.g., see Matlab function “vander.m”)

Gridding and Interpolation Polynomial Interpolation (cont’d)

Page 9: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 9

Gridding and Interpolation Polynomial Interpolation (cont’d)

Page 10: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 10

• Piecewise polynomial, helps avoid the Runge phenomenon.

• Is applied to a series of segments of the data record rather the entire series

• Alternatively …

• Spline functions can overcome some discontinuities or sharp corners, where

the segments join.

• Good for fitting non-analytical distributions

• No advantage to polynomial interpolation when applied to either well-behaved

functions or dense data

Gridding and Interpolation (Cubic) Spline Interpolation

Page 11: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 11

Approximate the interpolation function y(x) over the interval [a,b] by dividing [a,b]

into sub-intervals with continuity at the joints:

a = x0 < x1 < x2 … < xN = b

For each sub-interval y(x) is a polynomial of order N or smaller.

• At each “joint”, y(x) and its N-1 derivatives are continuous.

• N=3: cubic spline, most common.

Consider data (xi,yi) i=1...N, y'(x), y''(x) exist for all x, and y'''(x) is const. for all x.

At all joints:

• The spline function fi(xi) is continuous

• Its slope y'(x) is continuous

• Its curvature y''(x) is continuous

• Because y'''(x) = const => y''(x) is also linear.

Gridding and Interpolation (Cubic) Spline Interpolation

Page 12: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 12

Gridding and Interpolation (Cubic) Spline Interpolation (cont’d)

Hint: To ensure positivity, can first log-transform the data, perform the

interpolation, and then convert back by exponentiation to the original space.

Page 13: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 13

FFT Interpolation

• Original vector, x, is transformed to Fourier domain using fft, and then

transformed back with more points.

• How? Matlab transforms to the Fourier domain, pads the spectrum with

zeros, and then transforms the function back with more points.

Gridding and Interpolation FFT Interpolation (cont’d)

Page 14: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 14

Often do not have evenly spaced

observations - need to grid

unevenly spaced data (e.g.,

imagesc, pcolor, surf all need

equally spaced data.)

Example: Fratantoni & Pickart (2007)

• Plot 5o squares spatial coverage

increases towards lower latitudes

• Mix of historical data and different

instruments (XBT vs MBT)

• Seasonality in data coverage

• Historical Observations often along

meridians or parallel to longitudes

• Main goal was to find the “mean

state of the ocean”

Gridding and Interpolation 2-D Gridding and Interpolation

•F

rata

nto

ni &

Pic

ka

rt, 2

00

7

Page 15: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 15

Numerical models – various ways of interpolating / assimilating data

Direct Insertion:

• Model predictions are replaced with available observations

• Assumption: Perfect observations, imperfect model

• Model dynamics spread information to nearby gridpoints

• To avoid ‘shock’, blending uses a weighted average

“Nudging” or Newtonian Damping

• Model is forced over several time steps towards the observation:

𝑑𝑎

𝑑𝑡= 𝐹 𝑎, 𝑡 + 𝐺 𝑡 𝑤𝑖

𝑁

𝑎𝑖 − 𝑎

• F(a,t) is model forcing, G(t) is nudging coeff., wi is analysis weight, ai is

observed value, a is interpolated model value

Gridding and Interpolation 2-D Gridding and Interpolation

Page 16: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 16

Optimal Interpolation (a.k.a., Objective mapping, Objective analysis, BLUE

(Best Linear Unbiased Estimator) or Gauss-Markov smoothing)

• Models are imperfect. Errors include:

– initial conditions

– imperfect parameterization

– inaccurate forcing

– …

• Observations are imperfect. Errors include:

– instrument errors

– sampling errors

– measurement noise

– …

Gridding and Interpolation Optimal Interpolation

Page 17: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 17

Optimal Interpolation (a.k.a., Objective mapping, Objective analysis, BLUE

(Best Linear Unbiased Estimator) or Gauss-Markov smoothing) (cont’d)

• Compared to direct insertion / nudging:

– model adjustment only at grid point of observation vs. all points within

de-correlation distance of the observation

– OI estimates fields at any location through linear combination of

available data

– Weights are such that expected error of estimate is minimized and

estimate itself unbiased

– natural covariance length and time scales of data and true field enter

into the computation of linear weights.

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 18: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 18

• r,s - locations where the observations are made

• x - locations where to interpolate to

• x - lag distance from x

• q - true or target value (for defining auto-correlation/-covariance function)

• Assume 𝜃 𝑥 = 0

• Define covariance function, F(x)

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 19: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 19

• The observations are:

• Assume measurement errors are not correlated with observed values

• Assume measurement error is uncorrelated with itself

• E is the error variance.

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 20: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 20

• Per two slides ago, have covariance matrix of observations (can compute this):

• To estimate the true value, qx, from (imperfect) observations:

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 21: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 21

• Ars and Cxr are constant for given observation and interpolation points!

• The error in the estimation is:

Which can be used to construct error maps in the estimation (derivation follows)

• Cxx is the natural variation without data present

• The second term shows data influence

• a are weights still to be determined:

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 22: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 22

• The error variance of the estimation:

• If we minimize this error variance we get the previous equation:

> or = to 0

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 23: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 23

Example: 1D example of Gaussian and top hat with random noise

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 24: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 24

Example: Dye mapping during Coastal Mixing & Optics Experiment (CMO)

Gridding and Interpolation Optimal Interpolation (cont’d)

Page 25: Laboratory in Oceanography: Data and Methods Gridding and ... · • Write down the general polynomial of degree n - 1 • Evaluate the polynomial at the points x 1, ..., x n •

Sundermeyer

MAR 550

Spring 2020 25

Gridding and Interpolation Useful Tidbits

Useful Tidbits:

• interp, interp2, interp3 - 1-,2-, and 3-D interpolation

• spline toolbox - more spline tools for other splines but cubic

(limited licenses at SMAST)

• delauny - triangulation by finding “natural” neighbors

• voronoi - 2-d fitting via polygons

• trimesh - for plotting mesh with triangles

• dsearch - point search for use with Delauny triangulation

• tsearch - triangle indexing for use w/ Delauny triangulation

Some References:

• Data Analysis Methods in Physical Oceanography by W.J. Emery and R.E.

Thomson, 1993.

• Bretherton, F. P., R. E. Davis, and C. B. Fandry, 1976: A technique for

objective analysis and design of oceanographic experiments applied to

MODE-73. Deep Sea Res., 23, 559-582.