Title: | Verify the Scale, Anisotropy and Direction of Weather Forecasts |
---|---|
Description: | Implementation of the wavelet-based spatial verification method of Buschow and Friederichs "SAD: Verifying the Scale, Anisotropy and Direction of precipitation forecasts" (2020, submitted to QJRMS). Forecasts and Observations are transformed by a decimated or redundant dual-tree complex wavelet transform to analyze the spatial scale, degree of anisotropy and preferred direction in each field. These structural attributes are compared by a series of scores. An experimental algorithm for the correction of these errors is included as well. |
Authors: | Sebastian Buschow [aut, cre]
|
Maintainer: | Sebastian Buschow <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2025-02-13 05:12:52 UTC |
Source: | https://github.com/cran/sad |
Determine the set of pareto optimal forecasts in a matrix of scores
getpareto(scores)
getpareto(scores)
scores |
a matrix of negatively oriented scores where the rows correspond to different forecasts and the columns denote different scores. |
The Pareto set contains all those forecasts for which no other forecast is better in every respect. In this function, we assume that all scores are negatively oriented, "better" therefore means lower values.
a vector of indices indicating all members of the pareto set.
This function becomes very memory hungry if you have more than 1000 forecasts, be careful.
Earth Mover's Distance between two histograms, given as vectors
hemd(h1, h2, mids = NULL)
hemd(h1, h2, mids = NULL)
h1 , h2
|
vectors of non-negtaive numbers representing two histograms |
mids |
the bin mids corresponding to the histograms. Can also be given via the names of |
the value of the EMD
remove small values, apply log-transform, smooth borders, handle boundary conditions
prepare_sad(x, xmin = 0.1, log = TRUE, rsm = 0, Nx = NULL, Ny = NULL, boundaries = "pad")
prepare_sad(x, xmin = 0.1, log = TRUE, rsm = 0, Nx = NULL, Ny = NULL, boundaries = "pad")
x |
a list of 2 or more 2D matrices with equal sizes and no missing or inifinite values, as required by |
xmin |
values smaller than |
log |
logical, do you want to log-transfrom the data? (recommended for precipitation) |
rsm |
number of pixels which are linearly smoothed at the edge |
Nx |
size to which the data is extended in x-direction |
Ny |
size to which the data is extended in y-direction |
boundaries |
how to handle the boundary conditions, either "pad", "mirror" or "periodic" |
the positions within the extended field where the original field resides are output as attributes "px", "py" of the result. The other input parameters are saved as attributes of the result as well.
an object of class sadforecast
which has been prepared in the desired way.
data( rrain ) ra <- list( rrain[2,4,,], rrain[3,9,,] ) ra <- prepare_sad( ra, rsm=0, Nx=256, boundaries="mirror", log=FALSE ) plot(ra)
data( rrain ) ra <- list( rrain[2,4,,], rrain[3,9,,] ) ra <- prepare_sad( ra, rsm=0, Nx=256, boundaries="mirror", log=FALSE ) plot(ra)
eight shades of blue used in plot.sadforecast
raincols
raincols
An object of class character
of length 8.
Randomly simulated synthetic rain fields with Matern covariances
data(rrain)
data(rrain)
A 4x10x128x128
matrix
These fields were used in Buschow et al. (2019) <doi:10.5194/gmd-12-3401-2019>. The first array corresponds to the four model configurations from that paper (different roughness nu and scale sc), the second dimension contains ten realizations for each model.
simulated using the 'RandomFields' package, code available at <10.5281/zenodo.3257511>
data(rrain)
data(rrain)
use the inverse 'dtcwt' to correct errors in scale, anisotropy and direction
sadcorrect(x, xmin = 0.1, log = TRUE, rsm = 0, Nx = NULL, Ny = NULL, J = NULL, boundaries = "pad", direction = TRUE)
sadcorrect(x, xmin = 0.1, log = TRUE, rsm = 0, Nx = NULL, Ny = NULL, J = NULL, boundaries = "pad", direction = TRUE)
x |
a list of equally sized matrices, the first element is assumed to be the observation |
xmin |
values smaller than |
log |
logical, do you want to log-transfrom the data? (recommended for precipitation) |
rsm |
number of pixels which are linearly smoothed at the edge |
Nx |
size to which the data is extended in x-direction, has to be a whole power of 2 |
Ny |
size to which the data is extended in y-direction, has to be a whole power of 2 |
J |
largest scale considered |
boundaries |
how to handle the boundary conditions, either "pad", "mirror" or "periodic" |
direction |
if |
The algorithm performs the following steps:
remove values below xmin
if log=TRUE
log-transform all fields
set all fields to zero mean, unit variance
apply dtcwt
to all fields
loop over forecasts and scales. If direction=TRUE
loop over the six directions. Multiply forecast energy at each location by the ratio of total observed energy to total forecast energy at that scale (and possibly direction)
apply idtcwt
to all forecasts
reset means and variance of the forecasts to their original values
if log=TRUE
invert the log-transform
return the list of corrected fields
an object of class sadforecast
data(rrain) ra <- as.sadforecast( list( rrain[2,1,,], rrain[3,1,,], rrain[3,2,,], rrain[3,3,,] ) ) ra_c <- sadcorrect( ra, rsm=10 ) plot(ra_c)
data(rrain) ra <- as.sadforecast( list( rrain[2,1,,], rrain[3,1,,], rrain[3,2,,], rrain[3,3,,] ) ) ra_c <- sadcorrect( ra, rsm=10 ) plot(ra_c)
check that a list of forecasts fulfills all requirements to be verified by our method
as.sadforecast(x) ## S3 method for class 'sadforecast' plot(x, mfrow = NULL, col = NULL, ...)
as.sadforecast(x) ## S3 method for class 'sadforecast' plot(x, mfrow = NULL, col = NULL, ...)
x |
a list of 2 or more 2D matrices with equal sizes and no missing or inifinite values |
mfrow |
vector with the number of rows and columns you would like in the plot |
col |
color scale for the plot |
... |
further arguments passed to |
as.sadforecast
does nothing except check that everything is as it should be, add the attributes that can be changed by prepare_sad
and provide a method for quick plots of the data.
an object of class sadforecast
data( rrain ) ra <- list( rrain[1,1,,], rrain[4,5,,], rrain[2,7,,] ) ra <- as.sadforecast(ra) plot(ra)
data( rrain ) ra <- list( rrain[1,1,,], rrain[4,5,,], rrain[2,7,,] ) ra <- as.sadforecast(ra) plot(ra)
verify the scale, anisotropy and direction of a number of forecasts
sadverif(x, dec = TRUE, xmin = 0.1, log = TRUE, a = 1, nbr = 33, rsm = 0, Nx = NULL, Ny = NULL, J = NULL, boundaries = "pad", return_specs = FALSE) ## S3 method for class 'sadverif' plot(x, ...) ## S3 method for class 'sadverif' summary(object, ...)
sadverif(x, dec = TRUE, xmin = 0.1, log = TRUE, a = 1, nbr = 33, rsm = 0, Nx = NULL, Ny = NULL, J = NULL, boundaries = "pad", return_specs = FALSE) ## S3 method for class 'sadverif' plot(x, ...) ## S3 method for class 'sadverif' summary(object, ...)
x |
a list of equally sized matrices, the first element is assumed to be the observation |
dec |
logical, do you want to use the decimated transform |
xmin |
values smaller than |
log |
logical, do you want to log-transfrom the data? (recommended for precipitation) |
a |
relative weight of directional errors compared to scale errors in |
nbr |
number of breaks for the scale histograms, has no effect if |
rsm |
number of pixels which are linearly smoothed at the edge |
Nx |
size to which the data is extended in x-direction |
Ny |
size to which the data is extended in y-direction |
J |
largest scale considered |
boundaries |
how to handle the boundary conditions, either "pad", "mirror" or "periodic" |
return_specs |
if |
... |
further arguments, currently ignored. |
object |
object of class sadverif |
each element of x is transformed via dtcwt
from the 'dualtrees' package. Scores and centres based on the mean spectra are calculated. If dec=FALSE
, scale histograms and the corresponding score hemd
are calcualted as well.
an object of class sadverif
, containing the following elements
a dataframe containing the parameters that were originally passed to dtverif
a matrix cotaining the anisotropy rho
, angle phi
and central scale z
derived from the mean spectra. Rain area and sum are included as well.
a matrix containing the differences in centre components, the direction/anisotropy score dxy
, the emd between direction-averaged spectra (semd
) and the emd between the directional spectra (semdd
). If dec=FALSE
, the emd between the scale histograms, hemd, is included as well.
the time the calculation took in seconds
if there is more than one forecast, the ensemble scores SpEn and (if available), hemd are computed as well, treating all forecasts as members of the ensemble to be verified.
Selesnick, I.W., R.G. Baraniuk, and N.C. Kingsbury (2005) <doi:10.1109/MSP.2005.1550194> Buschow et al. (2019) <doi:10.5194/gmd-12-3401-2019> Buschow and Friederichs (2020) <doi:10.5194/ascmo-6-13-2020>
oldpar <- par(no.readonly=TRUE) on.exit(par(oldpar)) data(rrain) ra <- as.sadforecast( list( rrain[1,1,,], rrain[1,2,,], rrain[2,1,,], rrain[3,1,,] ) ) plot(ra) verif <- sadverif( ra, log=FALSE, xmin=0 ) summary(verif) par( mfrow=c(2,2) ) plot( verif )
oldpar <- par(no.readonly=TRUE) on.exit(par(oldpar)) data(rrain) ra <- as.sadforecast( list( rrain[1,1,,], rrain[1,2,,], rrain[2,1,,], rrain[3,1,,] ) ) plot(ra) verif <- sadverif( ra, log=FALSE, xmin=0 ) summary(verif) par( mfrow=c(2,2) ) plot( verif )
earth mover's distance between dual-tree wavelet spectra
semd(dt1, dt2, a = 1, dir = TRUE)
semd(dt1, dt2, a = 1, dir = TRUE)
dt1 , dt2
|
forecast and observed spectrum |
a |
ratio between scale- and directional component |
dir |
whether or not to include direction information |
a single value, the emd. If dir=FALSE
, the value is signed, indicating the direction of the scale error.