View source: R/deseason.VALUE.R
deseason.VALUE | R Documentation |
Remove seasonal cycle from a VALUE dataset (possibly using a moving average filter for daily datasets)
deseason.VALUE(
valueObj,
window.width = 31,
max.na.prop = 0.25,
monthly = FALSE,
monthly.clim.fun = "mean",
...
)
valueObj |
Any VALUE object (as returned either by |
window.width |
Integer number indicating the width, in days, of the window used for moving average computation of the reference daily climatology. Default to 31 days. See details. |
max.na.prop |
Maximum allowed proportion of missing data (Default to 0.25). See details |
monthly |
Logical flag indicating whether the input data is monthly ( |
monthly.clim.fun |
Optional. Name of the function used to compute the monthly climatology (default to |
... |
Further optional arguments passed to |
A (circular) moving average daily climatology can be automatically calculated for each data series, considering a user-defined window width centered around lag 0. An additional argument allows to specify the maximum number of missing values allowed, being ommited from the analysis those data series above the threshold.
For daily datasets, the daily climatology (i.e., one value per (julian) day of the year) is subtracted from each daily value in the time series. This daily climatlogical value can be calculated using a moving average window as described above. FOr monthly datatasets, the monthly climatological mean is computed and subtrated to each monthly record. In this case, the moving wndow average is not applied. A global attribute "deseason" is included and assigned a value of TRUE, to indicate that the dataset consist of anomalies. An additional attribute "deseason::window.width" is appended to the output indicating the window width (in days) used, when applicable.
A VALUE object same as input but with seasonal cycles removed.
Although the function is insentitive to the input season, it is recommended to perform seasonal cycle removal on
the annual series, rather than in particular seasons. Seasonal slices can be selected afterwards using subsetVALUE
.
J. Bedia
## Not run:
obs.file <- file.path(find.package("VALUE"),"example_datasets","VALUE_ECA_86_v2.zip")
# Load 1 station (Innsbruck) as example:
stationObj <- loadValueStations(obs.file, var = "tmin", stationID = "000013", years = 1991:1993)
# Test different window sizes:
widths <- c(31,45,60)
out <- lapply(widths, function(x) deseason.VALUE(stationObj, window.width = x))
dates <- as.Date(stationObj$Dates$start)
plot(dates, stationObj$Data, ty = 'l', ylab = "tmin (degC)")
for (i in 1:length(widths)) {
lines(dates,out[[i]]$Data,col = i + 1)
}
legend("bottomright", legend = widths, lty = 1, col = (1:3)+1, title = "window.width")
# Monthly aggregation:
mon <- aggregateVALUE(stationObj, aggr.m = list(FUN = "mean", na.rm = TRUE))
# Compute anomalies w.r.t. the monthly means:
anom <- deseason.VALUE(mon, monthly = TRUE, monthly.clim.fun = "mean", na.rm = TRUE)
plot(mon$Data, ty = 'b')
lines(anom$Data[1,,], col = "red", ty = "b")
legend("topright",
legend = c("monthly tmin", "monthly tmin anomalies"),
lty = 1, col = c("black","red"))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.