Title: | Wavelet-Based Quantile Mapping for Postprocessing Numerical Weather Predictions |
---|---|
Description: | The wavelet-based quantile mapping (WQM) technique is designed to correct biases in spatio-temporal precipitation forecasts across multiple time scales. The WQM method effectively enhances forecast accuracy by generating an ensemble of precipitation forecasts that account for uncertainties in the prediction process. For a comprehensive overview of the methodologies employed in this package, please refer to Jiang, Z., and Johnson, F. (2023) <doi:10.1029/2022EF003350>. The package relies on two packages for continuous wavelet transforms: 'WaveletComp', which can be installed automatically, and 'wmtsa', which is optional and available from the CRAN archive <https://cran.r-project.org/src/contrib/Archive/wmtsa/>. Users need to manually install 'wmtsa' from this archive if they prefer to use 'wmtsa' based decomposition. |
Authors: | Ze Jiang [aut, cre] , Fiona Johnson [aut] |
Maintainer: | Ze Jiang <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.4 |
Built: | 2024-12-11 06:46:14 UTC |
Source: | CRAN |
CWT based quantile mapping
bc_cwt( data, subset, variable, theta = 0.1, QM = c("MBC", "MRS", "QDM"), number_sim = 5, wavelet = "morlet", dt = 1, dj = 1, method = "M2", block = 3, seed = NULL, PR.cal = FALSE, do.plot = FALSE, ... )
bc_cwt( data, subset, variable, theta = 0.1, QM = c("MBC", "MRS", "QDM"), number_sim = 5, wavelet = "morlet", dt = 1, dj = 1, method = "M2", block = 3, seed = NULL, PR.cal = FALSE, do.plot = FALSE, ... )
data |
a list of input dataset |
subset |
a index of number denoting the subset for calibration |
variable |
a character string denoting the type of variable. |
theta |
threshold of rainfall. |
QM |
a character string denoting the qm method used. |
number_sim |
The total number of realizations. |
wavelet |
a character string denoting the wavelet filter to use in calculating the CWT. |
dt |
sampling resolution in the time domain. |
dj |
sampling resolution in the frequency domain. |
method |
Shuffling method, M1: non-shuffling and M2: shuffling. M2 by default. |
block |
Block size. |
seed |
Seed for shuffling process. |
PR.cal |
Logical value for phase randomization of calibration. |
do.plot |
Logical value for ploting. |
... |
Additional arguments for QDM. |
a list of post-processed data
Function: Total number of decomposition levels
fun_cwt_J(n, dt, dj)
fun_cwt_J(n, dt, dj)
n |
sample size. |
dt |
sampling resolution in the time domain. |
dj |
sampling resolution in the frequency domain. |
the total number of decomposition levels.
Inverse of continuous wavelet transform
fun_icwt(x.wave, dt, dj, flag.wav = "WaveletComp", scale = NULL)
fun_icwt(x.wave, dt, dj, flag.wav = "WaveletComp", scale = NULL)
x.wave |
input complex matrix. |
dt |
sampling resolution in the time domain. |
dj |
sampling resolution in the frequency domain. |
flag.wav |
String for two different CWT packages. |
scale |
Wavelet scales. |
reconstructed time series
fun_stoch_sim_wave in PRSim, Brunner and Furrer, 2020.
set.seed(100) dt<-1 dj<-1/8 flag.wav <- switch(2, "wmtsa", "WaveletComp") n <- 100 x <- rnorm(n) x.wave <- t(WaveletComp::WaveletTransform(x=x)$Wave) rec <- fun_icwt(x.wave, dt, dj, flag.wav) x.wt <- WaveletComp::analyze.wavelet(data.frame(x=x),"x",dt=dt,dj=dj) rec_orig <- WaveletComp::reconstruct(x.wt,only.sig = FALSE, plot.rec = FALSE)$series$x.r ### compare to original series op <- par(mfrow = c(1, 1), mar=c(3,3,1,1), mgp=c(1, 0.5, 0)) plot(1:n, x, type="l", lwd=5, xlab=NA, ylab=NA) lines(1:n, rec, col="red",lwd=3) lines(1:n, rec_orig, col="blue", lwd=1) legend("topright",legend=c("Raw","Inverse","Inverse_orig"), lwd=c(5,3,1),bg="transparent",bty = "n", col=c("black","red","blue"),horiz=TRUE) par(op)
set.seed(100) dt<-1 dj<-1/8 flag.wav <- switch(2, "wmtsa", "WaveletComp") n <- 100 x <- rnorm(n) x.wave <- t(WaveletComp::WaveletTransform(x=x)$Wave) rec <- fun_icwt(x.wave, dt, dj, flag.wav) x.wt <- WaveletComp::analyze.wavelet(data.frame(x=x),"x",dt=dt,dj=dj) rec_orig <- WaveletComp::reconstruct(x.wt,only.sig = FALSE, plot.rec = FALSE)$series$x.r ### compare to original series op <- par(mfrow = c(1, 1), mar=c(3,3,1,1), mgp=c(1, 0.5, 0)) plot(1:n, x, type="l", lwd=5, xlab=NA, ylab=NA) lines(1:n, rec, col="red",lwd=3) lines(1:n, rec_orig, col="blue", lwd=1) legend("topright",legend=c("Raw","Inverse","Inverse_orig"), lwd=c(5,3,1),bg="transparent",bty = "n", col=c("black","red","blue"),horiz=TRUE) par(op)
Inverse Fourier transform
fun_ifft(x, do.plot = FALSE)
fun_ifft(x, do.plot = FALSE)
x |
input time series. |
do.plot |
Logical value of plot. |
reconstruction time series
fun_stoch_sim in PRSim, Brunner and Furrer, 2020.
x <- rnorm(100) x.new <- fun_ifft(x, do.plot=TRUE)
x <- rnorm(100) x.new <- fun_ifft(x, do.plot=TRUE)
A dataset containing 160 stations including observation and raw forecasts.
data(NWP.rain)
data(NWP.rain)
Phase randomization and shuffling
prsim( modulus, phases, noise_mat, method = c("M1", "M2")[2], size = 3, seed = NULL )
prsim( modulus, phases, noise_mat, method = c("M1", "M2")[2], size = 3, seed = NULL )
modulus |
Modulus of complex values. |
phases |
Argument of complex values. |
noise_mat |
Complex matrix from random time series. |
method |
Shuffling method, M1: non-shuffling and M2: shuffling. M2 by default. |
size |
Block size. |
seed |
Seed for shuffling process. |
A new complex matrix
Verification Rank and Histogram
RankHist(forecasts, observations, do.plot = FALSE)
RankHist(forecasts, observations, do.plot = FALSE)
forecasts |
A matrix of ensemble forecasts, in which the rows corresponds to locations and times and the columns correspond to the individual ensemble members. |
observations |
A vector of observations corresponding to the locations and times of the forecasts. |
do.plot |
Logical value of plot. |
A vector giving the rank of verifying observations relative to the corresponding ensemble forecasts. The verification rank historgram is plotted.
ensembleBMA::verifRankHist
A dataset containing 2 stations including observation and raw forecasts.
data(sample)
data(sample)