Skip to content

Commit

Permalink
Extract months and years from time series.
Browse files Browse the repository at this point in the history
In order to provide obs for the biascorrection
  • Loading branch information
Yuanchao-Xu committed Sep 9, 2015
1 parent 889589a commit a626a94
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 184 deletions.
68 changes: 34 additions & 34 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
# For every column, it's biascorrected respectively.
frc_data <- lapply(2:n, function(x) biasCorrect_core(frc[, x], hindcast[, x], obs[, 2], method = method,
scaleType = scaleType, preci = preci))
frc_data <- do.call('cbind', frc_data)
} else stop('Wrong TS input, check your TS dimension.')
} else if (input == 'hyfo') {
print('Under development...')
}
names <- colnames(frc)
frc <- data.frame(frc[, 1], frc_data)
colnames(frc) <- names
return(frc)
}
# this is only used to calculate the value column,
biasCorrect_core <- function(frc, hindcast, obs, method = 'delta', scaleType = 'multi', preci = FALSE){
# default is the simplest method in biascorrection, just do simple addition and subtraction.
if (method == 'delta') {
# comes from downscaleR biascorrection method
frcMean <- mean(obs[, 2], na.rm = TRUE)
hindcastMean <- mean(hindcast[, 2], na.rm = TRUE)
frc <- obs - hindcastMean + frcMean
} else if (method == 'scaling') {
obsMean <- mean(obs, na.rm = TRUE)
hindcastMean <- mean(hindcast, na.rm = TRUE)
if (scaleType == 'multi') {
frc <- frc / hindcastMean * obsMean
} else if (scaleType == 'add') {
frc <- frc - hindcastMean + obsMean
}
} else if (method == 'eqm') {
# To be added, right now too complicated and not so much use.
}
return(frc)
}
aaa <- biasCorrect(frc, hindcast, obs)
debug(biasCorrect)
aaa <- biasCorrect(frc, hindcast, obs)
Expand Down Expand Up @@ -510,3 +476,37 @@ a <- getFrcEnsem(nc)
a1 <- getFrcEnsem(tgridData)
a <- getFrcEnsem(nc, cell = c(6,2))
b <- getFrcEnsem(nc, coord = c(-1.4, 43.2))
devtools::install_github('Yuanchao-Xu/hyfo')
devtools::install_github('Yuanchao-Xu/hyfo')
library(hyfo)
?biasCorrect
?layer
?structure
structure(1:6, dim = 2:3)
a <- structure(1:6, dim = 2:3)
attr(a)
attrs(a)
attributes(a)
a <- structure(1:6, dim = 2:3, dimnames(dalkf,dafda))
a <- structure(1:6, dim = 2:3, dimnames(1,2))
a <- structure(1:6, dim = 2:3, dimnames(1))
a <- structure(1:6, dim = 2:3, dimnames = 1: 3)
a <- structure(1:6, dim = 2:3, dimnames = c('dafa', 'dafda'))
?UseMethod()
devtools::document()
devtools::check()
devtools::document()
devtools::check()
devtools::document()
devtools::check()
devtools::document()
devtools::check()
devtools::document()
devtools::build()
install.packages("~/hyfo_1.1.8.tar.gz", repos = NULL, type = "source")
devtools::document()
devtools::check()
devtools::build()
install.packages("~/hyfo_1.1.9.tar.gz", repos = NULL, type = "source")
devtools::document()
devtools::check()
2 changes: 1 addition & 1 deletion .Rproj.user/132DF987/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab" : 0
"activeTab" : 2
}
2 changes: 1 addition & 1 deletion .Rproj.user/132DF987/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"TabSet1" : 0,
"TabSet2" : 3
"TabSet2" : 0
}
18 changes: 0 additions & 18 deletions .Rproj.user/132DF987/sdb/per/t/51993C6D

This file was deleted.

18 changes: 0 additions & 18 deletions .Rproj.user/132DF987/sdb/per/t/579C533F

This file was deleted.

17 changes: 0 additions & 17 deletions .Rproj.user/132DF987/sdb/per/t/606BD0E

This file was deleted.

17 changes: 0 additions & 17 deletions .Rproj.user/132DF987/sdb/per/t/9038F880

This file was deleted.

0 comments on commit a626a94

Please sign in to comment.