A vector of residuals in a single grid cell must be normalized for the fldgen algorithm to work properly. This function takes a matrix of residuals (each grid cell is a column, T or P), calculates the quantiles of each residual, and maps to the corresponding value in a normal distribution.

normalize.resids(inputresids, empiricalcdf, len = NULL)

Arguments

inputresids

Matrix of the original, input residuals for each grid cell (columns)

empiricalcdf

List of the empirical cdf functions for each grid cell.

len

Maximum length of the time series to read. If the data read is longer, it will be trimmed. (Default: read entire time series, regardless of length.)

Details

The output will be a list with four fields:

inputresids

Matrix of the original, input residuals for each grid cell.

empiricalcdf

List of the empirical cdf functions for each grid cell.

quants

Matrix of the quantiles of each input residual.

rn

Matrix of the new, normally distributed residuals.

Conventionally, we refer to the output list as quantilemapping. Notably, any other function with a quantilemapping argument is expecting one of these structures.