A vector of normally distributed residuals in a single grid cell, likely generated during the field generation step of this package, must be mapped back to the original distribution of ESM residuals for the generated fields to have any meaning. The original distribution of ESM residuals (T or P) is empirically characterized by the vector of residuals in the grid cell. fldgen algorithm to work properly. This function takes a matrix of normally distributed residuals (each grid cell is a column, T or P), calculates the quantiles of the normal distribution of each residual, and maps to the corresponding value in the original, empirically characterized distribution of residuals.

unnormalize.resids(empiricalquant, rn, len = NULL)

Arguments

empiricalquant

List of the empirical quantile functions for each grid cell.

rn

Matrix of the input, randomized, normally distributed residuals

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:

empiricalquant

List of the empirical quantile functions for each grid cell.

rn

Matrix of the input, randomized, normally distributed residuals.

rnew

Matrix of the new residuals, sampled from the original distribution of residuals according to the quantiles of the input normally distributed random residuals.

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