Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Jan 22, 2015
1 parent c5d9ffb commit 3feca93
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 2 additions & 0 deletions R/biasCorrection.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#' Ignored if the dataset has no members.
#' @param pr.threshold The minimum value that is considered as a non-zero precipitation. Ignored for
#' \code{varcode} values different from \code{"pr"}. Default to 1 (assuming mm).
#' @param window Numeric value specifying the time window width used to calibrate. The window is centered on the target day.
#' Default to \code{NULL}, which considers the whole period available.
#'
#' @details
#'
Expand Down
12 changes: 7 additions & 5 deletions R/isimip.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#'
#' @template templateObsPredSim
#' @param threshold The minimum value that is considered as a non-occurrence (e.g. precipitation). Default to 1.
#' @param type Type of bias correction approach, either multiplicative (e.g. precipitation, \code{type = "multiplicative"})
#' or additive (e.g. temperature, \code{type = "additive"}, the default).
#' @details
#'
#' The methods available are qqmap, delta, unbiasing, scaling and Piani (only precipitation).
Expand Down Expand Up @@ -60,7 +62,7 @@
#' par(mfrow = c(1,1))
#' }

isimip <- function (obs, pred, sim, threshold = 1, type = "additive") {
isimip <- function (obs, pred, sim, threshold = 1, type = c("additive", "multiplicative")) {
datesObs <- as.POSIXct(obs$Dates$start, tz="GMT", format="%Y-%m-%d %H:%M:%S")
datesObs<-cut(datesObs, "month")
yearList<-unlist(strsplit(as.character(datesObs), "[-]"))
Expand Down Expand Up @@ -1184,10 +1186,10 @@ isimip <- function (obs, pred, sim, threshold = 1, type = "additive") {
}
}

case {'uas';'vas';'ua';'va';'eastward wind component';'northward wind component'},
if isempty(Ws),error('Wind speed is necessary for the correction of the eastward and northward wind component');end
wsC=isimip(Ws.O,Ws.P,Ws.F,'variable','windspeed','datesobs',datesObs,'datesfor',datesFor);
indC=find(~isnan(Ws.F) & Ws.F>0);F(indC)=(F(indC).*wsC(indC))./Ws.F(indC);
# case {'uas';'vas';'ua';'va';'eastward wind component';'northward wind component'},
# if isempty(Ws),error('Wind speed is necessary for the correction of the eastward and northward wind component');end
# wsC=isimip(Ws.O,Ws.P,Ws.F,'variable','windspeed','datesobs',datesObs,'datesfor',datesFor);
# indC=find(~isnan(Ws.F) & Ws.F>0);F(indC)=(F(indC).*wsC(indC))./Ws.F(indC);

attr(sim$Data, "correction") <- "ISI-MIP"
return(sim)
Expand Down
8 changes: 6 additions & 2 deletions man/biasCorrection.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
\title{Bias correction methods}
\usage{
biasCorrection(obs, pred, sim, method = c("qqmap", "delta", "scaling",
"unbiasing", "piani"), pr.threshold = 1, multi.member = TRUE)
"unbiasing", "piani"), pr.threshold = 1, multi.member = TRUE,
window = NULL)
}
\arguments{
\item{obs}{A field or station data containing the observed climate data for the training period}
Expand All @@ -20,10 +21,13 @@ the same variable as \code{obs}, in the case of model calibration (bias correcti
\code{"scaling"}, \code{"unbiasing"} and \code{"piani"}. See details.}

\item{pr.threshold}{The minimum value that is considered as a non-zero precipitation. Ignored for
\code{varcode} values different from \code{"pr"}. Default to 1 (assuming mm).}
\code{varcode} values different from \code{"pr"}. Default to 1 (assuming mm).}

\item{multi.member}{Should members be adjusted sepparately (TRUE, default), or jointly (FALSE)?.
Ignored if the dataset has no members.}

\item{window}{Numeric value specifying the time window width used to calibrate. The window is centered on the target day.
Default to \code{NULL}, which considers the whole period available.}
}
\value{
A calibrated object of the same spatio-temporal extent of the input field
Expand Down
2 changes: 1 addition & 1 deletion man/calibrateProj.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\title{Bias correction methods}
\usage{
calibrateProj(obs, pred, sim, method = c("qqmap", "delta", "scaling",
"unbiasing", "piani"), varcode = c("tas", "hurs", "pr", "wss"),
"unbiasing", "piani"), varcode = c("tas", "hurs", "tp", "pr", "wss"),
pr.threshold = 1)
}
\arguments{
Expand Down
11 changes: 7 additions & 4 deletions man/isimip.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
\alias{isimip}
\title{Bias correction ISI-MIP method}
\usage{
isimip(obs, pred, sim, pr.threshold = 1)
isimip(obs, pred, sim, threshold = 1, type = c("additive",
"multiplicative"))
}
\arguments{
\item{obs}{A field or station data containing the observed climate data for the training period}
Expand All @@ -15,8 +16,10 @@ the same variable as \code{obs}, in the case of model calibration (bias correcti

\item{sim}{A field containing the simulated climate for the variables used in \code{pred}, but considering the test period.}

\item{pr.threshold}{The minimum value that is considered as a non-zero precipitation. Ignored for
\code{varcode} values different from \code{"pr"}. Default to 1 (assuming mm).}
\item{threshold}{The minimum value that is considered as a non-occurrence (e.g. precipitation). Default to 1.}

\item{type}{Type of bias correction approach, either multiplicative (e.g. precipitation, \code{type = "multiplicative"})
or additive (e.g. temperature, \code{type = "additive"}, the default).}
}
\value{
A calibrated object of the same spatio-temporal extent of the input field
Expand Down Expand Up @@ -61,7 +64,7 @@ sim <- loadGridData(ncep.data.dir, var = "tp", lonLim = c(-12,10), latLim = c(33
# Interpolate the observations onto the model's grid. We use the method "nearest" and the getGrid function to ensure spatial consistency:
obs <- interpGridData(obs, new.grid = getGrid(prd), method = "nearest")
# Apply the bias correction method:
simBC <- isimip (obs, prd, sim, pr.threshold = 1) # ISI-MIP Method
simBC <- isimip (obs, prd, sim, threshold = 1) # ISI-MIP Method
par(mfrow = c(1,2))
plotMeanField(sim)
plotMeanField(simBC)
Expand Down

0 comments on commit 3feca93

Please sign in to comment.