Skip to content

Commit

Permalink
version 0.2.1 released (#9)
Browse files Browse the repository at this point in the history
* shinyapp: GPPobs and NDVI3g work
* unify examples and rename PhenoExtract to get_pheno
* add examples
* tidy getRealDate
* update plot_input function
* rename season_3y to season_mov
* rm parameter I_optimFUN in optim_pheno
* version 0.2.1 released
* finished gee_Whittaker evaluation
  • Loading branch information
kongdd authored Mar 13, 2019
1 parent e4bee13 commit 56b9434
Show file tree
Hide file tree
Showing 126 changed files with 1,651 additions and 3,310 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
^cran-comments\.md$
^Dockerfile$
^update 20181028/$
^README\.Rmd$
^README\.Rmd$
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ src-i386/
src-x64/
inst/doc
temp/
# test/
test/

# Office document
notebook
*.csv
*.xlsx
*.docx
*.pdf

# TIMESAT file
*.set
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: phenofit
Type: Package
Title: Extract Remote Sensing Vegetation Phenology
Version: 0.1.9
Version: 0.2.1
Authors@R: c(
person("Dongdong", "Kong", role = c("aut", "cre"), email = "kongdd.sysu@gmail.com"),
person("Yongqiang", "Zhang", role = c("aut"), email = "yongqiang.zhang2014@gmail.com"),
person("Mingzhong", "Xiao", role = c("aut"), email = "xmingzh@mail2.sysu.edu.cn"),
person("Yongqiang", "Zhang", role = c("aut"), email = "yongqiang.zhang2014@gmail.com"),
person("Xihui", "Gu", role = c("aut"), email = "guxh@cug.edu.cn"),
person("Jianjian", "Cui", role = c("aut"), email = "cuijj6@mail2.sysu.edu.cn"))
Description:
Expand Down Expand Up @@ -36,6 +36,5 @@ Imports: Rcpp,
Suggests: knitr,
rmarkdown,
testthat
VignetteBuilder: knitr
URL: https://github.com/kongdd/phenofit
BugReports: https://github.com/kongdd/phenofit/issues
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ RUN wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION
EXPOSE 3838

RUN installGithub.r kongdd/Ipaper \
&& R -e "devtools::install_github('kongdd/phenofit', ref='debug-whittaker')" \
&& R -e "devtools::install_github('kongdd/phenofit', ref='dev')" \
&& rm -rf /tmp/downloaded_packages/
# kongdd/phenofit \
14 changes: 9 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@ export(FitDL.Gu)
export(FitDL.Klos)
export(FitDL.Zhang)
export(GOF)
export(GOF_fFITs)
export(I_optim)
export(I_optimx)
export(Logistic)
export(PhenoDeriv)
export(PhenoExtract)
export(PhenoExtract.fFITs)
export(PhenoGu)
export(PhenoKl)
export(PhenoTrs)
export(R2_sign)
export(add_HeadTail)
export(add_dn)
export(backval)
export(check_fit)
export(check_input)
export(check_ylu)
export(contain)
export(curvature)
export(curvefit)
Expand All @@ -47,10 +44,14 @@ export(findpeaks)
export(fprintf)
export(getBits)
export(getRealDate)
export(get_GOF)
export(get_GOF.fFITs)
export(get_fitting)
export(get_fitting.fFITs)
export(get_param)
export(get_param.fFITs)
export(get_pheno)
export(get_pheno.fFITs)
export(ifelse2)
export(init_lambda)
export(init_param)
Expand All @@ -77,7 +78,7 @@ export(reorder_name)
export(rm_empty)
export(runningId)
export(season)
export(season_3y)
export(season_mov)
export(skewness)
export(tidyFitPheno)
export(tidy_MOD13.gee)
Expand Down Expand Up @@ -114,6 +115,9 @@ importFrom(dplyr,left_join)
importFrom(dplyr,nth)
importFrom(grDevices,cairo_pdf)
importFrom(grDevices,dev.off)
importFrom(grid,grid.draw)
importFrom(grid,pushViewport)
importFrom(grid,viewport)
importFrom(gridExtra,arrangeGrob)
importFrom(lubridate,day)
importFrom(lubridate,ddays)
Expand Down
55 changes: 37 additions & 18 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# phenofit 0.2.1 (2019-03-11)

* fix point shape error of `plot_input`
* make_legend supports 4 quality categories (MOD13A1) and 6 quality categories (MOD09A1) now.
* wWHIT only adjusts time series of growing season.


# phenofit 0.2.1 (2019-02-18)

* release in CRAN


# phenofit 0.1.8 (2019-01-06)

* `shiny` app `phenofit` released.
* add `QC_flag` to the output of `check_input`.


# phenofit 0.1.7 (2018-10-29)
* Add V-curve optimization in `season_mov` for Whittaker's parameter lambda.
* Remove `check_ylu` and `upper envelope` in `wWHIT`.
* Update `v-curve`.

# phenofit 0.1.6 (2018-10-26)

* Melt parameters (i.e. `nptperyear` and `south`) into `INPUT`. `check_input`,
`season`, `season_mov` and `curvefits` are impacted.
* Add `adj.param` parameter to `season`, which determine whether to automatically
adjust roughn curve fitting parameters.


# phenofit 0.1.5 (2018-09-19)

* shiny app `check_season` online now.
* `season` can export rough curve fitting result, even no peaks or trough found.


# phenofit 0.1.3 (2018-07-25)

* fix `Init_param`
Expand All @@ -11,21 +48,3 @@
strategy.
* `doubleLog.zhang` is still not as stable as others.
* `wTSM_cpp` iter parameter is ignored now.

# phenofit 0.1.5 (2018-09-19)

* shiny app `check_season` online now.
* `season` can export rough curve fitting result, even no peaks or trough found.

# phenofit 0.1.6 (2018-10-26)

* Melt parameters (i.e. `nptperyear` and `south`) into `INPUT`. `check_input`,
`season`, `season_3y` and `curvefits` are impacted.
* Add `adj.param` parameter to `season`, which determine whether to automatically
adjust roughn curve fitting parameters.

# phenofit 0.1.7 (2018-10-29)

* Add V-curve optimization in `season_3y` for Whittaker's parameter lambda.
* Remove `check_fit` and `upper envelope` in `wWHIT`.
* Update `v-curve`.
93 changes: 1 addition & 92 deletions R/S3_fFITs.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NULL
#' plot curve fitting VI, gradient (first order difference D1), hessian (D2),
#' curvature (k) and the change rate of curvature(der.k)
#'
#' @inheritParams PhenoExtract
#' @inheritParams get_pheno
#' @param x Fine curve fitting object \code{\link{fFITs}} returned by
#' \code{\link{curvefit}}.
#' @param ... ignored.
Expand Down Expand Up @@ -109,94 +109,3 @@ plot.fFITs <- function(x, method, ...){
# diff <- der1 - der1_diff
# der <- data.frame(der1_diff, der1 = der1, diff = diff)
}


#' GOF_fFITs
#'
#' Good-of-fitting (GOF) to fine curve fitting results.
#'
#' @param fFITs \code{fFITs} object returned by \code{\link{curvefit}}.
#'
#' @return
#' \describe{
#' \item{meth}{The name of fine curve fitting method}
#' \item{RMSE}{Root Mean Square Error}
#' \item{NSE}{Nash-Sutcliffe model efficiency coefficient}
#' \item{R}{Pearson-Correlation}
#' \item{pvalue}{pvalue of \code{R}}
#' \item{n}{The number of observations}
#' }
#'
#' @references
#' [1]. https://en.wikipedia.org/wiki/Nash-Sutcliffe_model_efficiency_coefficient \cr
#' [2]. https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
#'
#' @seealso \code{\link{curvefit}}
#'
#' @examples
#' library(phenofit)
#' # simulate vegetation time-series
#' fFUN = doubleLog.Beck
#' par = c(
#' mn = 0.1,
#' mx = 0.7,
#' sos = 50,
#' rsp = 0.1,
#' eos = 250,
#' rau = 0.1)
#' t <- seq(1, 365, 8)
#' tout <- seq(1, 365, 1)
#' y <- fFUN(par, t)
#'
#' methods <- c("AG", "Beck", "Elmore", "Gu", "Zhang") # "Klos" too slow
#' fFITs <- curvefit(y, t, tout, methods)
#'
#' GOF_fFITs(fFITs)
#' @export
GOF_fFITs <- function(fFITs){
methods <- names(fFITs$fFIT)
nmeth <- length(methods)

t <- fFITs$data$t
tout <- fFITs$tout
ti <- intersect(t, tout)
I_org <- match(ti, t)
I_sim <- match(ti, tout)

Y_obs <- fFITs$data$y[I_org]
# Y_sim <- map(x$fFIT, ~last(.$fits))

# The following script assume that tout in every method is equal length.
# calculate statistic for every meth
info <- ldply(fFITs$fFIT, function(fFIT){
Y_sim <- last(fFIT$zs)[I_sim]
I <- which(!(is.na(Y_obs) | is.na(Y_sim)))

# n_obs <- length(Y_obs)
Y_sim2 <- Y_sim[I]
Y_obs2 <- Y_obs[I]

R <- NA
pvalue <- NA
n <- length(I)

if (n < 2) return(c(RMSE = NA, NSE = NA, R = R, pvalue = pvalue, n = n))

tryCatch({
cor.obj <- cor.test(Y_obs, Y_sim, use = "complete.obs")
R <- cor.obj$estimate[[1]]
pvalue <- cor.obj$p.value
}, error = function(e){
message(sprintf('[statistic] %s', e$message))
})

RMSE <- sqrt(sum((Y_obs - Y_sim)^2)/n)
NSE <- 1 - sum((Y_sim - Y_obs)^2) / sum((Y_obs - mean(Y_obs))^2)

c(RMSE = RMSE, NSE = NSE, R = R, pvalue = pvalue, n = n)
}, .id = "meth")
info
}

# GOFs_fFITs <- function(fit){
# }
12 changes: 6 additions & 6 deletions R/add_HeadTail.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#' (image date) column which are (\code{Date} variable).
#' @inheritParams check_input
#' @inheritParams season
#'
#' @param trs If nmissing < trs*nptperyear (little missing), this year is
#'
#' @param trs If nmissing < trs*nptperyear (little missing), this year is
#' include to extract phenology; if \code{FALSE}, this year is excluded.
#'
#' @note \code{date} is image date; \code{t} is compositing date.
Expand All @@ -17,17 +17,17 @@
#' @examples
#' library(phenofit)
#' data("MOD13A1")
#'
#'
#' dt <- tidy_MOD13.gee(MOD13A1$dt)
#' st <- MOD13A1$st
#'
#'
#' sitename <- dt$site[1]
#' d <- dt[site == sitename, ] # get the first site data
#' sp <- st[site == sitename, ] # station point
#'
#'
#' nptperyear = 23
#' dnew <- add_HeadTail(d, nptperyear = nptperyear) # add one year in head and tail
#'
#'
#' @export
add_HeadTail <- function(d, south = FALSE, nptperyear, trs = 0.45){
if (missing(nptperyear)){
Expand Down
Loading

0 comments on commit 56b9434

Please sign in to comment.