-
Notifications
You must be signed in to change notification settings - Fork 307
Update NEE and LE gap-fill functions #3883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Amedieus
wants to merge
18
commits into
PecanProject:develop
Choose a base branch
from
Amedieus:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
77f3c93
Upload NEE and LE gap-fill functions
6198171
make roxygen files fot gap-filling scripts
2dce279
commit rosxygen files for read_site_ids
dd53678
update description
7c5a76b
update Rd
5e0c31e
Fix NSE notes in xgb_gapfill
42d8f0c
put packages into Suggests
ae1390a
Merge branch 'develop' into develop
Amedieus c660cfd
Merge branch 'PecanProject:develop' into develop
Amedieus ad314c5
Merge branch 'develop' into develop
Amedieus b6bdea5
data prep for downscaling and bcm code
3de4e1e
Merge branch 'develop' of https://github.com/Amedieus/PEcAn into develop
ea206ad
Merge branch 'PecanProject:develop' into develop
Amedieus a8b9dc9
Update modules/data.land/R/SIPNET_flux_gapfill.R
Amedieus 706252a
upload the revised version to repo
5367eb8
multi chain MCMC config & fix NEE unit
14b4ff4
update bf byproduct
8e2c97d
monthly sipnet available
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| # loading libraries | ||
| library(dplyr) | ||
| library(xts) | ||
| library(PEcAn.all) | ||
| library(purrr) | ||
| library(furrr) | ||
| library(lubridate) | ||
| library(nimble) | ||
| library(ncdf4) | ||
| library(PEcAnAssimSequential) | ||
| library(dplyr) | ||
| library(sp) | ||
| library(raster) | ||
| library(zoo) | ||
| library(ggplot2) | ||
| library(mnormt) | ||
| library(sjmisc) | ||
| library(stringr) | ||
| library(doParallel) | ||
| library(doSNOW) | ||
| library(data.table) | ||
| library(Kendall) | ||
| library(lgarch) | ||
| library(parallel) | ||
| library(foreach) | ||
| library(terra) | ||
| setwd("/projectnb/dietzelab/guYANG/pecan/") | ||
| ## read settings xml file. | ||
| load("/projectnb/dietzelab/guYANG/pecan/pecan.Rdata") | ||
|
|
||
| ### PEcAn Settings | ||
| # settings_dir <- "/projectnb/dietzelab/guYANG/pecan/output/pecan_flux.xml" | ||
| # settings <- PEcAn.settings::read.settings(settings_dir) | ||
|
|
||
| # Change dir name and settings | ||
| settings$outdir <- "/projectnb/dietzelab/guYANG/pecan/output/5obs_monthly/" | ||
| settings$rundir <- file.path(settings$outdir, "run") | ||
| settings$modeloutdir <- file.path(settings$outdir, "out") | ||
| settings$host$rundir <- file.path(settings$outdir, "run") | ||
| settings$host$outdir <- file.path(settings$outdir, "out") | ||
| settings$host$folder <- file.path(settings$outdir, "out") | ||
| settings$ensemble$size <- 25 | ||
| settings$state.data.assimilation$adjustment <- "FALSE" | ||
| settings$host$prerun <- "module load R/4.4.0" | ||
| ###### Change Q type | ||
| settings$state.data.assimilation$q.type <- "vector" | ||
| settings$state.data.assimilation$aqq.Init <- "1" | ||
| settings$state.data.assimilation$bqq.Init <- "1" | ||
| ## Fix the multi output in one timestep bug | ||
| settings$model$jobtemplate <- "/projectnb/dietzelab/guYANG/pecan/runners/test7/sipnet_template.job" | ||
|
|
||
| # Load the selected sites | ||
| load("/projectnb/dietzelab/guYANG/pecan/runners/wishart_sda/sda_idx.Rdata") | ||
| all_ids <- vapply(settings, \(s) as.character(s$run$site$id), "") | ||
| # Sub settings for this run | ||
| settings <- settings[all_ids %in% keep_ids] | ||
| settings <- PEcAn.settings::as.MultiSettings(settings) | ||
|
|
||
| # setup the batch job settings. | ||
| general.job <- list(cores = 28, folder.num = 80) | ||
| batch.settings = structure(list( | ||
| general.job = general.job, | ||
| qsub.cmd = "qsub -l h_rt=24:00:00 -l mem_per_core=4G -l buyin -pe omp @CORES@ -V -N @NAME@ -o @STDOUT@ -e @STDERR@ -S /bin/bash" | ||
| )) | ||
| settings$state.data.assimilation$batch.settings <- batch.settings | ||
|
|
||
| # update settings with the actual PFTs. | ||
| settings <- PEcAn.settings::prepare.settings(settings) | ||
|
|
||
| # load obs | ||
| # load("/projectnb/dietzelab/guYANG/pecan/runners/test10/obs.mean.RData") | ||
| # load("/projectnb/dietzelab/guYANG/pecan/runners/test10/obs.cov.RData") | ||
|
|
||
| load("/projectnb/dietzelab/guYANG/pecan/output/obs/Rdata/obs.mean.monthly.noSM.Rdata") | ||
| load("/projectnb/dietzelab/guYANG/pecan/output/obs/Rdata/obs.cov.monthly.noSM.Rdata") | ||
|
|
||
| sub_obs <- function(L, keep) setNames(lapply(L, \(l) l[names(l) %in% keep]), names(L)) | ||
| obs.mean <- sub_obs(obs.mean, keep_ids) | ||
| obs.cov <- sub_obs(obs.cov, keep_ids) | ||
|
|
||
| # replace zero observations and variances with small numbers. | ||
| for (i in 1:length(obs.mean)) { | ||
| if(is.null(obs.mean[[i]][[1]])){ | ||
| next | ||
| } | ||
| for (j in 1:length(obs.mean[[i]])) { | ||
| if (length(obs.mean[[i]][[j]])==0) { | ||
| next | ||
| } | ||
| obs.mean[[i]][[j]][which(obs.mean[[i]][[j]]==0)] <- 0.01 | ||
| if(length(obs.cov[[i]][[j]]) > 1){ | ||
| diag(obs.cov[[i]][[j]])[which(diag(obs.cov[[i]][[j]]<=0.1))] <- 0.1 | ||
| }else{ | ||
| if(obs.cov[[i]][[j]] <= 0.1){ | ||
| obs.cov[[i]][[j]] <- 0.1 | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (length(obs.cov[[i]][[j]]) > 1) { | ||
| d <- diag(obs.cov[[i]][[j]]) | ||
| d[d <= 0.1] <- 0.1 | ||
| diag(obs.cov[[i]][[j]]) <- d | ||
| } | ||
|
|
||
| # load PFT parameter file. | ||
| # samples_src <- "/projectnb/dietzelab/guYANG/pecan/cali_samples.Rdata" | ||
| samples_src <- "/projectnb/dietzelab/dongchen/anchorSites/NA_runs/SDA_8k_site/samples.Rdata" | ||
| samples_dst <- file.path(settings$outdir, "samples.Rdata") | ||
| dir.create(settings$outdir, recursive = TRUE, showWarnings = FALSE) | ||
| if (!file.exists(samples_dst)) file.copy(samples_src, samples_dst, overwrite = TRUE) | ||
|
|
||
| control = list( | ||
| TimeseriesPlot = FALSE, | ||
| OutlierDetection = FALSE, | ||
| send_email = NULL, | ||
| keepNC = TRUE, | ||
| forceRun = TRUE, | ||
| run_parallel = FALSE, | ||
| MCMC.args = list( | ||
| niter = 200000, | ||
| nburnin = 100000, | ||
| nthin = 5, | ||
| nchain = 3 | ||
| ), | ||
| merge_nc = FALSE, | ||
| execution = "qsub_parallel" # or "qsub" / "local" | ||
| ) | ||
|
|
||
| res <- PEcAnAssimSequential:::sda.enkf_local( | ||
| settings = settings, | ||
| obs.mean = obs.mean, | ||
| obs.cov = obs.cov, | ||
| Q = NULL, | ||
| pre_enkf_params = NULL, | ||
| ensemble.samples = NULL, | ||
| control = list( | ||
| TimeseriesPlot = FALSE, | ||
| OutlierDetection = FALSE, | ||
| send_email = NULL, | ||
| keepNC = TRUE, | ||
| forceRun = TRUE, | ||
| run_parallel = FALSE, | ||
| MCMC.args = list( | ||
| niter = 200000, | ||
| nburnin = 100000, | ||
| nthin = 5, | ||
| nchain = 3 | ||
| ), | ||
| merge_nc = FALSE, | ||
| execution = "qsub_parallel" # or "qsub" / "local" | ||
| ) | ||
| ) | ||
|
|
||
| #### qsub | ||
| # PEcAnAssimSequential:::qsub_sda( | ||
| # settings = settings, | ||
| # obs.mean = obs.mean, | ||
| # obs.cov = obs.cov, | ||
| # Q = NULL, | ||
| # pre_enkf_params = NULL, | ||
| # ensemble.samples = NULL, | ||
| # outdir = "/projectnb/dietzelab/guYANG/pecan/output/qsub", | ||
| # control = control | ||
| # ) | ||
|
|
||
| # job_lines <- c( | ||
| # "#!/bin/bash", | ||
| # "module load R/4.4.0", | ||
| # "Rscript /projectnb/dietzelab/guYANG/pecan/pecan/local/sda_runner.R" | ||
| # ) | ||
| # writeLines(job_lines, "/projectnb/dietzelab/guYANG/pecan/output/log/sda_runner_1.sh") | ||
|
|
||
| # qsub -l h_rt=10:00:00 \ | ||
| # -l buyin \ | ||
| # -l mem_per_core=8G \ | ||
| # -pe omp 28 \ | ||
| # -V \ | ||
| # -N sda_runner_1 \ | ||
| # -o /projectnb/dietzelab/guYANG/pecan/output/log/sda_runner_1.out \ | ||
| # -e /projectnb/dietzelab/guYANG/pecan/output/log/sda_runner_1.err \ | ||
| # -M yanggu@bu.edu \ | ||
| # -m abe \ | ||
| # -S /bin/bash \ | ||
| # /projectnb/dietzelab/guYANG/pecan/output/log/sda_runner_1.sh | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a new high-level folder called "local" without group discussion or a clear definition for what should go in such a folder. I'd recommend
git mving this to the SDA inst/ folder for now.d