kalmanFilter.index

Specify climate indices to calculate from the posterior of a Kalman Filter


Syntax



Description

obj = obj.index(…)

Calculates a climate index from a posterior climate field for each member of a posterior ensemble. Returns the full posterior for the calculated index, without needing to save the (often very large) full posterior of the entire climate field.

A common motivation for data assimilation is to reconstruct a climate index of some sort, and having the full posterior of the climate index is useful for quantifying reconstruction uncertainty. Often, climate indices are calculated using values across a large spatial field. In order to calculate the full posterior of such climate indices, data values are needed for the full posterior of the associated spatial field. However, this present a problem, because the full posteriors of spatial fields are often too large for computer memory. This method allows you to circumvent these memory issues by calculating a climate index from the posterior fields, saving the full posterior for the climate index, and then discarding the large posterior field.

obj = obj.index(name, type, …)

Calculates an index when the Kalman filter is run. The first input is an identifying name that the filter should use for the index. You can specify multiple indices that should be calculated, so long as they use different names. When using the kalmanFilter.run method, the output struct will hold the posterior for the index in a field named: index_<name>

The second input indicates the type of calculation that should be used to compute the index. All subsequent inputs will depend on the type of calculation being used. The syntaxes for different types of calculations are detailed below.

names = obj.index

Returns the names of the indices that will be calculated from the posterior when the Kalman filter is run.

obj = obj.index(name, ‘delete’)

Deletes the index with the specified name from the Kalman Filter object. These indices will no longer be calculated when the Kalman filter is run.

obj = obj.index(name, ‘mean’, …)
obj = obj.index(…, ‘rows’, rows)
obj = obj.index(…, ‘weights’, weights)
obj = obj.index(…, ‘nanflag’, nanOption)

Calculates the index using a mean over state vector elements. Use the “rows” flag to only implement the mean over specific state vector rows. If you do not provide the “rows” flag, takes a mean over all the elements in the state vector. Use the “weights” flag to implement a weighted mean over the selected state vector elements. If you do not provide the “weights” flag, implements an unweighted mean. Use the “nanflag” flag to indicate how to treat NaN values in the state vector when taking a mean. If you do not specify the “nanflag” flag, includes NaN elements in the mean.


Input Arguments

name

string scalar
An identifying name for the calculated index. The name must be a valid Matlab variable name. It must start with a letter, and can only contain letters, numbers, and underscores.

type

string scalar
Indicates the type of calculation to use to compute the climate index.

[‘mean’]: Implements a mean over state vector elements in each posterior ensemble member.

rows

logical vector [nState] | vector linear indices [nRows]
Indicates which state vector rows to use in the weighted mean. If a logical vector, must have one element per state vector row. If not set, selects every row in the state vector.

weights

numeric vector [nRows]
The weights to use for a weighted mean of the selected state vector elements. Must have one element per state vector row used in the mean. If you provided a “rows” input, the order of weights must match the order of input rows. Otherwise, the order of weights should match the order of elements in the state vector.

nanOption

string scalar | scalar logical
Indicates how to treat NaN elements in a state vector when taking a mean.

[“omitnan”|false]: Omits NaN values when taking means

[“includenan”|true (default)]: Includes NaN values when taking means


Output Arguments

obj

scalar kalmanFilter object
The object with updated posterior index calculations.

names

string vector
The names of the indices that will be calculated when the Kalman filter is run.