Skip to content

Commit

Permalink
update IGBP006 parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Sep 22, 2023
1 parent 1b80545 commit 685090c
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 13 deletions.
15 changes: 8 additions & 7 deletions R/PML.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' surface for each time step (16-day).
#'
#' This algorithm fits to high resolution data data in GEE.
#'
#'
#' @param data A data.frame with the columns of
#' - `Prcp` : Precipitation, mm
#' - `Tavg` : daily average temperature, deg C
Expand Down Expand Up @@ -30,7 +30,7 @@
#' - `rou_a` :
#' - `gama` :
#' - `epsilon` :
#'
#'
#' @param par PML_V2 parameters (see Zhang 2019 for details).
#' - `hc` : canopy height (m)
#' - `Alpha` : initial photochemical efficiency, 0.02-0.08
Expand All @@ -49,7 +49,7 @@
#' @param ratio land cover ratio
#' @param return.Es Because `fval_soil` need moving average in temporal. We can't
#' get it directly if the `data` is Spatial pixels.
#' @param IGBPname IGBPname
#' @param IGBPcode IGBP006 code
#' @param scale one of c("site", "regional").
#' @param ... ignored
#'
Expand All @@ -74,8 +74,8 @@
#'
#' @export
PML <- function(
data, par = NULL, CO2 = NULL, IGBPname = NULL, ratio = 1, ...,
scale = c("site", "regional"), V2 = TRUE, return.Es = TRUE)
data, par = NULL, CO2 = NULL, IGBPcode = NULL, ratio = 1, ...,
scale = c("site", "regional"), V2 = TRUE, return.Es = TRUE)
{
scale <- match.arg(scale)
# 380, 475, 570# umol mol-1,475; #data$CO2
Expand All @@ -88,8 +88,9 @@ PML <- function(
kA <- 0.7 # extinction coefficient
LAIref <- 5 # par[10); # 1-5

ind <- match(IGBPname, options_param$IGBPname) # index of options_param

# ind <- match(IGBPname, options_param$IGBPname) # index of options_param
ind = IGBPcode

if (is.null(par)) {
Alpha <- options_param$Alpha[ind] # initial photochemical efficiency, 0.02-0.08
Thelta <- options_param$Thelta[ind] #
Expand Down
7 changes: 4 additions & 3 deletions R/model_calib.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#' @inheritParams PML
#' @inheritParams rtop::sceua
#'
#' @param IGBPcode (optional) If `hc_raw` specified in `par`, `IGBPcode` can be ignored.
#' @param IGBPcode (optional) [IGBP_006] code. If `hc_raw` specified in `par`, `IGBPcode` can be ignored.
#' Otherwise, `IGBPcode` should be provided.
#'
#'
#' @importFrom rtop sceua
#' @export
PML_calib <- function(data, IGBPcode = 1, of_gof = NSE, ..., verbose = TRUE, maxn = 1e3) {
Expand All @@ -29,7 +29,7 @@ PML_calib <- function(data, IGBPcode = 1, of_gof = NSE, ..., verbose = TRUE, max
# par = sceua(PML_goal, par0, lb, ub, iprint = ifelse(verbose, 0, -1), maxn = maxn,
# data = data, IGBPcode = IGBPcode, of_gof = of_gof)$par
par <- set_names(par, parnames)
par["hc"] <- options_param$hc_raw[IGBPcode + 1]
par["hc"] <- options_param$hc_raw[IGBPcode]

gof <- PML_goal(par, data, detailed = TRUE, of_gof = NSE)
cat(str(gof))
Expand Down Expand Up @@ -109,6 +109,7 @@ PML_gof <- function(dat, of_gof = NSE, detailed = TRUE) {
#' @import crayon
PML_goal <- function(par, data, IGBPcode = NULL, ..., of_gof = NSE, detailed = FALSE) {
dat <- PML_predict(data, par, IGBPcode = IGBPcode)

# smaller, better
PML_gof(dat, of_gof = of_gof, detailed = detailed)
}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ You can install the development version of `PMLV2` like so:

``` r
remotes::install_github("gee-hydro/PMLV2")

pak::pkg_install(c("phenofit"))
pak::pkg_install(c("rpkgs/rfluxnet", "rpkgs/nctools"))
```

## Example
Expand Down
10 changes: 10 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>TODO</h1>


- [x] 1. 原本默认是`IGBP05`的参数类型,现在修正到`IGBP06`,由于前者已经淘汰。

- [ ] 2. 参数率定考虑依然保持在R语言。但如果Julia能够胜任的话,则弃用R语言。

- [ ] 3. R语言不适合做全球计算,栅格计算改为Julia语言。

- [ ] 4. 数据预处理,保留使用R语言。dataframe数据处理,R语言最成熟。
Binary file added data/IGBP_006.rda
Binary file not shown.
Binary file added data/options_param_IGBP05.rda
Binary file not shown.
Binary file added data/options_param_IGBP06.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions man/PML.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/PML_calib.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 685090c

Please sign in to comment.