diff --git a/dbfiles/posterior/77000000001/Amax.model.bug b/dbfiles/posterior/77000000001/Amax.model.bug new file mode 100644 index 00000000000..9c3eadc45c4 --- /dev/null +++ b/dbfiles/posterior/77000000001/Amax.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:28){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + # beta.ghs[1] <- 0 + # beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dunif (0, 40)#BBB + # tau.site ~ dgamma(0.01, 0.01) + # tau.trt ~ dgamma(0.01, 0.01) + prec.y ~ dgamma(0.01, 0.01) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/SLA.model.bug b/dbfiles/posterior/77000000001/SLA.model.bug new file mode 100644 index 00000000000..41410935c3b --- /dev/null +++ b/dbfiles/posterior/77000000001/SLA.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:47){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + beta.ghs[ghs[k]] + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + beta.ghs[1] <- 0 + beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dlnorm (1.89, 2.68744961031981)#BBB + # tau.site ~ dgamma(0.01, 0.01) + # tau.trt ~ dgamma(0.01, 0.01) + prec.y ~ dgamma(0.01, 0.01) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/jagged.data.Rdata b/dbfiles/posterior/77000000001/jagged.data.Rdata new file mode 100644 index 00000000000..360a1db4122 Binary files /dev/null and b/dbfiles/posterior/77000000001/jagged.data.Rdata differ diff --git a/dbfiles/posterior/77000000001/leafC.model.bug b/dbfiles/posterior/77000000001/leafC.model.bug new file mode 100644 index 00000000000..15a0cbfe24f --- /dev/null +++ b/dbfiles/posterior/77000000001/leafC.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:12){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + # beta.ghs[1] <- 0 + # beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dnorm (50.6, 0.573921028466483)#BBB + # tau.site ~ dgamma(0.01, 0.01) + # tau.trt ~ dgamma(0.01, 0.01) + prec.y ~ dgamma(0.01, 0.01) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/leaf_respiration_rate_m2.model.bug b/dbfiles/posterior/77000000001/leaf_respiration_rate_m2.model.bug new file mode 100644 index 00000000000..df95cce1675 --- /dev/null +++ b/dbfiles/posterior/77000000001/leaf_respiration_rate_m2.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:10){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + # beta.ghs[1] <- 0 + # beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dweib (2, 0.0277777777777778)#BBB + # tau.site ~ dgamma(0.01, 0.0013) + # tau.trt ~ dgamma(0.01, 0.0013) + prec.y ~ dgamma(0.01, 0.0013) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/leaf_turnover_rate.model.bug b/dbfiles/posterior/77000000001/leaf_turnover_rate.model.bug new file mode 100644 index 00000000000..3f6bc5c8ea9 --- /dev/null +++ b/dbfiles/posterior/77000000001/leaf_turnover_rate.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:15){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + # beta.ghs[1] <- 0 + # beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dweib (1.37, 0.612617824426684)#BBB + # tau.site ~ dgamma(0.01, 0.00015) + # tau.trt ~ dgamma(0.01, 0.00015) + prec.y ~ dgamma(0.01, 0.00015) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.Amax.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.Amax.pdf new file mode 100644 index 00000000000..a2e544f8bb8 Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.Amax.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.SLA.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.SLA.pdf new file mode 100644 index 00000000000..20555ac5995 Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.SLA.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.leafC.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.leafC.pdf new file mode 100644 index 00000000000..ee0d473129b Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.leafC.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.leaf_respiration_rate_m2.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.leaf_respiration_rate_m2.pdf new file mode 100644 index 00000000000..2a88c2a38c4 Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.leaf_respiration_rate_m2.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.leaf_turnover_rate.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.leaf_turnover_rate.pdf new file mode 100644 index 00000000000..dbe2721425f Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.leaf_turnover_rate.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.root_respiration_rate.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.root_respiration_rate.pdf new file mode 100644 index 00000000000..ec349a8ecb0 Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.root_respiration_rate.pdf differ diff --git a/dbfiles/posterior/77000000001/ma.summaryplots.root_turnover_rate.pdf b/dbfiles/posterior/77000000001/ma.summaryplots.root_turnover_rate.pdf new file mode 100644 index 00000000000..d977f4197f7 Binary files /dev/null and b/dbfiles/posterior/77000000001/ma.summaryplots.root_turnover_rate.pdf differ diff --git a/dbfiles/posterior/77000000001/meta-analysis.log b/dbfiles/posterior/77000000001/meta-analysis.log new file mode 100644 index 00000000000..1c88c6a4326 --- /dev/null +++ b/dbfiles/posterior/77000000001/meta-analysis.log @@ -0,0 +1,485 @@ +Each meta-analysis will be run with: +3000 total iterations, +4 chains, +a burnin of 1500 samples, +, +thus the total number of samples will be 6000 +################################################ +------------------------------------------------ +starting meta-analysis for: + + Amax + +------------------------------------------------ +prior for Amax + (using R parameterization): +unif(0, 40) +data max: 25.69 +data min: 1.7845 +mean: 10.3 +n: 28 +stem plot of data points + + The decimal point is at the | + + 0 | 88 + 2 | 37 + 4 | 0 + 6 | 523466 + 8 | 1235556 + 10 | 0 + 12 | 55 + 14 | 0 + 16 | 6 + 18 | 3939 + 20 | + 22 | + 24 | 7 + +stem plot of obs.prec: + + The decimal point is 2 digit(s) to the right of the | + + 0 | 0000000000125 + 2 | + 4 | + 6 | 5 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 42 + Unobserved stochastic nodes: 16 + Total graph size: 118 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.o 16.838 0.17786 0.0022961 0.0024648 +sd.y 3.843 0.04736 0.0006114 0.0006498 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.o 16.491 16.720 16.840 16.958 17.185 +sd.y 3.752 3.811 3.842 3.875 3.936 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + leafC + +------------------------------------------------ +prior for leafC + (using R parameterization): +norm(50.6, 1.32) +data max: 53.7 +data min: 47.7 +mean: 50.5 +n: 12 +stem plot of data points + + The decimal point is at the | + + 46 | 7 + 48 | 349 + 50 | 55691 + 52 | 387 + +stem plot of obs.prec: + + The decimal point is 3 digit(s) to the right of the | + + 0 | 00000000002 + 0 | + 1 | + 1 | + 2 | + 2 | 5 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 24 + Unobserved stochastic nodes: 2 + Total graph size: 49 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.o 50.4789 0.18167 0.0023453 0.0024102 +sd.y 0.8932 0.04439 0.0005731 0.0006147 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.o 50.1207 50.3574 50.480 50.602 50.8393 +sd.y 0.8096 0.8628 0.892 0.923 0.9835 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + SLA + +------------------------------------------------ +prior for SLA + (using R parameterization): +lnorm(1.89, 0.61) +data max: 17.7 +data min: 2.73 +mean: 7.41 +n: 47 +stem plot of data points + + The decimal point is at the | + + 2 | 78023345555559 + 4 | 015991789 + 6 | 77889134 + 8 | 0673 + 10 | 07 + 12 | 67748 + 14 | 344 + 16 | 87 + +stem plot of obs.prec: + + The decimal point is 3 digit(s) to the right of the | + + 0 | 0000000000000000000002224 + 1 | 12 + 2 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | 6 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 75 + Unobserved stochastic nodes: 22 + Total graph size: 220 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.ghs[2] 4.902 0.19502 0.002518 0.0032047 +beta.o 5.181 0.13054 0.001685 0.0023896 +sd.y 1.074 0.01812 0.000234 0.0002411 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.ghs[2] 4.525 4.771 4.903 5.032 5.287 +beta.o 4.932 5.093 5.178 5.268 5.435 +sd.y 1.039 1.062 1.074 1.086 1.111 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + leaf_turnover_rate + +------------------------------------------------ +prior for leaf_turnover_rate + (using R parameterization): +weibull(1.37, 1.43) +data max: 0.769 +data min: 0.12625 +mean: 0.392 +n: 15 +stem plot of data points + + The decimal point is 1 digit(s) to the left of the | + + 0 | 3 + 2 | 3777928 + 4 | 12569 + 6 | 37 + +stem plot of obs.prec: + + The decimal point is 9 digit(s) to the right of the | + + 0 | 00000000000 + 0 | + 1 | + 1 | + 2 | 0 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 27 + Unobserved stochastic nodes: 5 + Total graph size: 80 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.o 0.33187 0.0049093 6.338e-05 6.670e-05 +sd.y 0.04802 0.0009105 1.175e-05 1.391e-05 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.o 0.32228 0.32853 0.33188 0.33519 0.34136 +sd.y 0.04626 0.04742 0.04803 0.04865 0.04978 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + leaf_respiration_rate_m2 + +------------------------------------------------ +prior for leaf_respiration_rate_m2 + (using R parameterization): +weibull(2, 6) +data max: 1.8 +data min: 0.583410488985368 +mean: 1.13 +n: 10 +stem plot of data points + + The decimal point is at the | + + 0 | 679 + 1 | 00134 + 1 | 58 + +stem plot of obs.prec: + + The decimal point is 3 digit(s) to the right of the | + + 0 | 000012 + 0 | + 1 | + 1 | + 2 | + 2 | 55 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 18 + Unobserved stochastic nodes: 4 + Total graph size: 58 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.o 1.410 0.02528 0.0003264 0.0003482 +sd.y 0.333 0.01082 0.0001397 0.0001500 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.o 1.3603 1.3925 1.4099 1.4269 1.460 +sd.y 0.3123 0.3256 0.3327 0.3403 0.355 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + root_turnover_rate + +------------------------------------------------ +prior for root_turnover_rate + (using R parameterization): +unif(0, 10) +data max: 0.98 +data min: 0.42 +mean: 0.597 +n: 6 +stem plot of data points + + The decimal point is 1 digit(s) to the left of the | + + 4 | 2376 + 6 | 2 + 8 | 8 + +stem plot of obs.prec: + + The decimal point is 4 digit(s) to the right of the | + + 2 | + 3 | 00000 + 4 | + 5 | + 6 | 7 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 12 + Unobserved stochastic nodes: 2 + Total graph size: 35 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.o 0.6033 0.03222 0.0004160 0.0004345 +sd.y 0.1308 0.00961 0.0001241 0.0001301 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.o 0.540 0.5816 0.6038 0.6249 0.6666 +sd.y 0.113 0.1241 0.1305 0.1370 0.1507 + +################################################ +------------------------------------------------ +starting meta-analysis for: + + root_respiration_rate + +------------------------------------------------ +prior for root_respiration_rate + (using R parameterization): +unif(0, 100) +data max: 79.8 +data min: 0.0967276868352595 +mean: 10.6 +n: 155 +stem plot of data points + + The decimal point is 1 digit(s) to the right of the | + + 0 | 000000000000111111111222222233333333333334444444444444444 + 0 | 55555555555555666666666666777777778888888899999999 + 1 | 000001111122223333444 + 1 | 55555667799 + 2 | 4 + 2 | 8 + 3 | 3 + 3 | 67 + 4 | 004 + 4 | 78 + 5 | 03 + 5 | 9 + 6 | + 6 | 9 + 7 | 0 + 7 | + 8 | 0 + +stem plot of obs.prec: + + The decimal point is 7 digit(s) to the right of the | + + 0 | 00000000000000000000000000000000000000000000000000000000000000000000+22 + 2 | + 4 | + 6 | 0 + 8 | + 10 | + 12 | + 14 | + 16 | + 18 | + 20 | + 22 | + 24 | + 26 | + 28 | + 30 | + 32 | 1 + +Compiling model graph + Resolving undeclared variables + Allocating nodes +Graph information: + Observed stochastic nodes: 259 + Unobserved stochastic nodes: 54 + Total graph size: 669 + +Initializing model + + +Iterations = 1002:4000 +Thinning interval = 2 +Number of chains = 4 +Sample size per chain = 1500 + +1. Empirical mean and standard deviation for each variable, + plus standard error of the mean: + + Mean SD Naive SE Time-series SE +beta.ghs[2] -10.798 0.070486 9.100e-04 0.0012463 +beta.o 17.794 0.049840 6.434e-04 0.0009578 +sd.y 1.042 0.001265 1.634e-05 0.0000174 + +2. Quantiles for each variable: + + 2.5% 25% 50% 75% 97.5% +beta.ghs[2] -10.935 -10.846 -10.798 -10.751 -10.661 +beta.o 17.695 17.762 17.795 17.827 17.892 +sd.y 1.039 1.041 1.042 1.043 1.044 + diff --git a/dbfiles/posterior/77000000001/post.distns.MA.Rdata b/dbfiles/posterior/77000000001/post.distns.MA.Rdata new file mode 100644 index 00000000000..283a0840c0f Binary files /dev/null and b/dbfiles/posterior/77000000001/post.distns.MA.Rdata differ diff --git a/dbfiles/posterior/77000000001/posteriors.pdf b/dbfiles/posterior/77000000001/posteriors.pdf new file mode 100644 index 00000000000..71e14178523 Binary files /dev/null and b/dbfiles/posterior/77000000001/posteriors.pdf differ diff --git a/dbfiles/posterior/77000000001/root_respiration_rate.model.bug b/dbfiles/posterior/77000000001/root_respiration_rate.model.bug new file mode 100644 index 00000000000..b509de11ef0 --- /dev/null +++ b/dbfiles/posterior/77000000001/root_respiration_rate.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:155){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + beta.ghs[ghs[k]] + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + beta.ghs[1] <- 0 + beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dunif (0, 100)#BBB + # tau.site ~ dgamma(0.01, 0.01) + # tau.trt ~ dgamma(0.01, 0.01) + prec.y ~ dgamma(0.01, 0.01) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/root_turnover_rate.model.bug b/dbfiles/posterior/77000000001/root_turnover_rate.model.bug new file mode 100644 index 00000000000..d5e476bc60f --- /dev/null +++ b/dbfiles/posterior/77000000001/root_turnover_rate.model.bug @@ -0,0 +1,28 @@ +model +{ + for (k in 1:6){ + Y[k] ~ dnorm( Z[k] , tau.y[k]) + Z[k] <- beta.o + tau.y[k] <- prec.y*n[k] + u1[k] <- n[k]/2 + u2[k] <- n[k]/(2*prec.y) + obs.prec[k] ~ dgamma(u1[k], u2[k]) + } + # beta.trt[1] <- 0 + # for ( j in 2:1){ + # beta.trt[j] ~ dnorm(0, tau.trt) + # } + # for (g in 1:1){ + # beta.site[g] ~ dnorm(0, tau.site) + # } + # beta.ghs[1] <- 0 + # beta.ghs[2] ~ dnorm(0, 0.01) + beta.o ~ dunif (0, 10)#BBB + # tau.site ~ dgamma(0.01, 0.00036) + # tau.trt ~ dgamma(0.01, 0.00036) + prec.y ~ dgamma(0.01, 0.00036) + #prec.y ~ dgamma(0.001, 0.001) + # sd.site <- 1 / sqrt(tau.site) + sd.y <- 1 / sqrt(prec.y) + # sd.trt <- 1 / sqrt(tau.trt) +} diff --git a/dbfiles/posterior/77000000001/trait.mcmc.Rdata b/dbfiles/posterior/77000000001/trait.mcmc.Rdata new file mode 100644 index 00000000000..398cc19c0e0 Binary files /dev/null and b/dbfiles/posterior/77000000001/trait.mcmc.Rdata differ diff --git a/docker-compose.ovveride.yml b/docker-compose.ovveride.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/docker-compose.yml b/docker-compose.yml index 180c5653834..30d9956645f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -206,6 +206,20 @@ services: # ---------------------------------------------------------------------- # PEcAn models, list each model you want to run below # ---------------------------------------------------------------------- + # PEcAn CTSM-FATES model runner: + ctsm-fates: + user: "${UID:-1001}:${GID:-1001}" + image: ghcr.io/noresmhub/ctsm-api:${API_VERSION:-latest} + restart: unless-stopped + networks: + - pecan + environment: + - RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F} + depends_on: + - rabbitmq + volumes: + - pecan:/data + # PEcAn basgra model runner basgra: @@ -221,6 +235,7 @@ services: volumes: - pecan:/data + # PEcAn sipnet model runner sipnet: user: "${UID:-1001}:${GID:-1001}" diff --git a/models/fates/DESCRIPTION b/models/fates/DESCRIPTION index 5eadad2b506..9ea02da6b7b 100644 --- a/models/fates/DESCRIPTION +++ b/models/fates/DESCRIPTION @@ -21,8 +21,7 @@ Imports: PEcAn.logger, PEcAn.remote, PEcAn.utils, - lubridate (>= 1.6.0), - ncdf4 (>= 1.15) + lubridate (>= 1.6.0) Suggests: testthat (>= 1.0.2) License: BSD_3_clause + file LICENSE diff --git a/models/fates/R/met2model.FATES.R b/models/fates/R/met2model.FATES.R old mode 100644 new mode 100755 index df232462351..df2c5e3c99a --- a/models/fates/R/met2model.FATES.R +++ b/models/fates/R/met2model.FATES.R @@ -16,39 +16,47 @@ ##' @param in.path location on disk where inputs are stored ##' @param in.prefix prefix of input and output files ##' @param outfolder location on disk where outputs will be stored -##' @param start_date the start date of the data to be downloaded (will only use the year part of the date) -##' @param end_date the end date of the data to be downloaded (will only use the year part of the date) +##' @param start_date the start date of the data to be downloaded +##' @param end_date the end date of the data to be downloaded ##' @param lst timezone offset to GMT in hours ##' @param overwrite should existing files be overwritten -##' @param verbose should the function be very verbosefor(year in start_year:end_year) +##' @param verbose should the function be very verbose for(year in start_year:end_year) ##' @importFrom ncdf4 ncvar_get ncdim_def ncatt_get ncvar_put -met2model.FATES <- function(in.path, in.prefix, outfolder, start_date, end_date, lst = 0, lat, lon, - overwrite = FALSE, verbose = FALSE, ...) { - +met2model.FATES <- function(in.path,in.prefix,outfolder,start_date,end_date,lst=0,lat, lon, overwrite = FALSE, verbose = FALSE, ...) { # General Structure- FATES Uses Netcdf so we need to rename vars, split files from years into months, and generate the header file # Get Met file from inpath. # Loop over years (Open nc.file,rename vars,change dimensions as needed,close/save .nc file) # close # defining temporal dimension needs to be figured out. If we configure FATES to use same tstep then we may not need to change dimensions - - - insert <- function(ncout, name, unit, data) { - var <- ncdf4::ncvar_def(name = name, units = unit, dim = dim, missval = -6999, verbose = verbose) - ncout <- ncdf4::ncvar_add(nc = ncout, v = var, verbose = verbose) - ncvar_put(nc = ncout, varid = name, vals = data) + insert <- function(ncout, name, unit, data, dim) { + var <- ncdf4::ncvar_def(name, unit, dim = dim, missval = as.numeric(1.0e36), verbose = verbose) + ncout <- ncdf4::ncvar_add(ncout, var) + ncdf4::ncvar_put(nc = ncout, varid = name, vals = data) return(invisible(ncout)) } - sm <- c(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365) * 86400 ## day of year thresholds ## Create output directory - dir.create(outfolder) + if (!file.exists(outfolder)){ + dir.create(outfolder) + } # Process start and end dates start_date <- as.POSIXlt(start_date, tz = "UTC") end_date <- as.POSIXlt(end_date, tz = "UTC") start_year <- lubridate::year(start_date) end_year <- lubridate::year(end_date) + + results <- data.frame(file = paste0(outfolder, "/"), + host = c(PEcAn.remote::fqdn()), + mimetype = c("application/x-netcdf"), + formatname = c("CLM met"), + startdate = c(start_date), + enddate = c(end_date), + dbfile.name = "", + stringsAsFactors = FALSE) + sm <- c(0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365) + difftime(start_date,"1700-01-01", units="days") ## day of year thresholds + ## Build met for (year in start_year:end_year) { @@ -60,104 +68,110 @@ met2model.FATES <- function(in.path, in.prefix, outfolder, start_date, end_date, nc <- ncdf4::nc_open(in.file) ## extract variables. These need to be read in and converted to CLM names (all units are correct) - time <- ncvar_get(nc, "time") - latitude <- ncvar_get(nc, "latitude") - longitude <- ncvar_get(nc, "longitude") - FLDS <- ncvar_get(nc, "surface_downwelling_longwave_flux_in_air") ## W/m2 - FSDS <- ncvar_get(nc, "surface_downwelling_shortwave_flux_in_air") ## W/m2 - PRECTmms <- ncvar_get(nc, "precipitation_flux") ## kg/m2/s -> mm/s (same val, diff name) - PSRF <- ncvar_get(nc, "air_pressure") ## Pa - SHUM <- ncvar_get(nc, "specific_humidity") ## g/g -> kg/kg - TBOT <- ncvar_get(nc, "air_temperature") ## K - WIND <- sqrt(ncvar_get(nc, "eastward_wind") ^ 2 + ncvar_get(nc, "northward_wind") ^ 2) ## m/s + time <- ncdf4::ncvar_get(nc, "time") + LATIXY <- ncdf4::ncvar_get(nc, "latitude") + LONGXY <- ncdf4::ncvar_get(nc, "longitude") + FLDS <- ncdf4::ncvar_get(nc, "surface_downwelling_longwave_flux_in_air") ## W/m2 + FSDS <- ncdf4::ncvar_get(nc, "surface_downwelling_shortwave_flux_in_air") ## W/m2 + PRECTmms <- ncdf4::ncvar_get(nc, "precipitation_flux") ## kg/m2/s -> mm/s (same val, diff name) + PSRF <- ncdf4::ncvar_get(nc, "air_pressure") ## Pa + QBOT <- ncdf4::ncvar_get(nc, "specific_humidity") ## g/g -> kg/kg + TBOT <- ncdf4::ncvar_get(nc, "air_temperature") ## K + WIND <- sqrt(ncdf4::ncvar_get(nc, "eastward_wind") ^ 2 + ncdf4::ncvar_get(nc, "northward_wind") ^ 2) ## m/s ## CREATE MONTHLY FILES for (mo in 1:12) { + # slice tsel <- which(time > sm[mo] & time <= sm[mo + 1]) - outfile <- file.path(outfolder, paste0(formatC(year, width = 4, flag = "0"), "-", - formatC(mo, width = 2, flag = "0"), ".nc")) - if (file.exists(outfile) & overwrite == FALSE) { - next + if (length(tsel)!=0){ + # define dim + lat.dim <- ncdf4::ncdim_def(name = "lat", units = "", vals = 1:1, create_dimvar=FALSE) + lon.dim <- ncdf4::ncdim_def(name = "lon", units = "", vals = 1:1, create_dimvar=FALSE) + time.dim <- ncdf4::ncdim_def(name = "time", units = "", vals = 1:length(time[tsel]),create_dimvar = TRUE, calendar="standard", unlim = FALSE) #left to CTSM automatically transfer + scalar.dim <- ncdf4::ncdim_def(name="scalar", units = "", vals = 1:1) + dim <- list(time.dim, lat.dim, lon.dim) + + # LATITUDE + var_lat <- ncdf4::ncvar_def(name = "LATIXY", units = "degree_north", + dim = list(lat.dim, lon.dim), missval = as.numeric(-9999)) + # LONGITUDE + var_long <- ncdf4::ncvar_def(name = "LONGXY", units = "degree_east", + dim = list(lat.dim, lon.dim), missval = as.numeric(-9999)) + # time + var_time <- ncdf4::ncvar_def(name = "time", units = "days since 1700-01-01", prec = "float", + dim = list(time.dim), missval = as.numeric(-9999)) + # EDGEE + var_E <- ncdf4::ncvar_def(name = "EDGEE", units = "degrees_east", + dim = list(scalar.dim, lat.dim, lon.dim), missval = as.numeric(-9999)) + # EDGEW edge for resolution , edge-central 0.005, # PEcAn provide range of grid? + var_W <- ncdf4::ncvar_def(name = "EDGEW", units = "degrees_west", + dim = list(scalar.dim, lat.dim, lon.dim), missval = as.numeric(-9999)) + # EDGES + var_S <- ncdf4::ncvar_def(name = "EDGES", units = "degrees_south", + dim = list(scalar.dim, lat.dim, lon.dim), missval = as.numeric(-9999)) + # EDGEN + var_N <- ncdf4::ncvar_def(name = "EDGEN", units = "degrees_north", + dim = list(scalar.dim, lat.dim, lon.dim), missval = as.numeric(-9999)) + + ## SAPERATELY CREATE FILES + put_var <- function(ncout){ + ncdf4::ncvar_put(nc = ncout, varid = "LATIXY", vals = LATIXY) #same with FATES + ncdf4::ncvar_put(nc = ncout, varid = "LONGXY", vals = LONGXY) + ncdf4::ncvar_put(nc = ncout, varid = "EDGEE", vals = LONGXY+0.005) + ncdf4::ncvar_put(nc = ncout, varid = "EDGEW", vals = LONGXY-0.005) + ncdf4::ncvar_put(nc = ncout, varid = "EDGES", vals = LATIXY-0.005) + ncdf4::ncvar_put(nc = ncout, varid = "EDGEN", vals = LATIXY+0.005) + } + ## Precipitation + outfile_prec <- file.path(outfolder, paste0("Prec", formatC(year, width = 4, flag = "0"), "-", + formatC(mo, width = 2, flag = "0"), ".nc")) + if (file.exists(outfile_prec) & overwrite == FALSE) { + next + } + ncout_prec <- ncdf4::nc_create(outfile_prec, vars = list(var_lat,var_long,var_E,var_W,var_S,var_N), verbose = verbose) + put_var(ncout_prec) + ## precipitation_flux + ncout_prec <- insert(ncout_prec, "PRECTmms", "mm/s", PRECTmms[tsel], dim) + ncdf4::nc_close(ncout_prec) + + ## Solar + outfile_slr <- file.path(outfolder, paste0("Slr", formatC(year, width = 4, flag = "0"), "-", + formatC(mo, width = 2, flag = "0"), ".nc")) + if (file.exists(outfile_slr) & overwrite == FALSE) { + next + } + ncout_slr <- ncdf4::nc_create(outfile_slr, vars = list(var_lat,var_long,var_E,var_W,var_S,var_N), verbose = verbose) + put_var(ncout_slr) + ## surface_downwelling_shortwave_flux_in_air + ncout_slr <- insert(ncout_slr, "FSDS", "W m-2", FSDS[tsel], dim) + ncdf4::nc_close(ncout_slr) + + ## Temerature and humidity + outfile_tem <- file.path(outfolder, paste0("Tem", formatC(year, width = 4, flag = "0"), "-", + formatC(mo, width = 2, flag = "0"), ".nc")) + if (file.exists(outfile_tem) & overwrite == FALSE) { + next + } + ncout_tem <- ncdf4::nc_create(outfile_tem, vars = list(var_lat,var_long,var_E,var_W,var_S,var_N), verbose = verbose) + put_var(ncout_tem) + ## surface_downwelling_longwave_flux_in_air + ncout_tem <- insert(ncout_tem, "FLDS", "W m-2", FLDS[tsel], dim) + ## air_pressure + ncout_tem <- insert(ncout_tem, "PSRF", "Pa", PSRF[tsel], dim) + ## specific_humidity + ncout_tem <- insert(ncout_tem, "QBOT", "kg/kg", QBOT[tsel], dim) + ## air_temperature + ncout_tem <- insert(ncout_tem, "TBOT", "K", TBOT[tsel], dim) + ## eastward_wind & northward_wind + ncout_tem <- insert(ncout_tem, "WIND", "m/s", WIND[tsel], dim) + ncdf4::nc_close(ncout_tem) } - lat.dim <- ncdim_def(name = "latitude", units = "", vals = 1:1, create_dimvar = FALSE) - lon.dim <- ncdim_def(name = "longitude", units = "", vals = 1:1, create_dimvar = FALSE) - time.dim <- ncdim_def(name = "time", units = "seconds", vals = time, - create_dimvar = TRUE, unlim = TRUE) - dim <- list(lat.dim, lon.dim, time.dim) ## docs say this should be time,lat,lon but get error writing unlimited first - ## http://www.cesm.ucar.edu/models/cesm1.2/clm/models/lnd/clm/doc/UsersGuide/x12979.html - - # LATITUDE - var <- ncdf4::ncvar_def(name = "latitude", units = "degree_north", - dim = list(lat.dim, lon.dim), missval = as.numeric(-9999)) - ncout <- ncdf4::nc_create(outfile, vars = var, verbose = verbose) - ncvar_put(nc = ncout, varid = "latitude", vals = latitude) - - # LONGITUDE - var <- ncdf4::ncvar_def(name = "longitude", units = "degree_east", - dim = list(lat.dim, lon.dim), missval = as.numeric(-9999)) - ncout <- ncdf4::ncvar_add(nc = ncout, v = var, verbose = verbose) - ncvar_put(nc = ncout, varid = "longitude", vals = longitude) - - ## surface_downwelling_longwave_flux_in_air - ncout <- insert(ncout, "FLDS", "W m-2", FLDS) - - ## surface_downwelling_shortwave_flux_in_air - ncout <- insert(ncout, "FSDS", "W m-2", FSDS) - - ## precipitation_flux - ncout <- insert(ncout, "PRECTmms", "mm/s", PRECTmms) - - ## air_pressure - ncout <- insert(ncout, "PSRF", "Pa", PSRF) - - ## specific_humidity - ncout <- insert(ncout, "SHUM", "kg/kg", SHUM) - - ## air_temperature - ncout <- insert(ncout, "TBOT", "K", TBOT) - - ## eastward_wind & northward_wind - ncout <- insert(ncout, "WIND", "m/s", WIND) - - ncdf4::nc_close(ncout) - - # ncvar_rename(ncfile,varid="LONGXY") - # ncvar_rename(ncfile,varid="LATIXY") - # # - # # double EDGEW(scalar) ; - # # EDGEW:long_name = "western edge in atmospheric data" ; - # # EDGEW:units = "degrees E" ; - # EDGEW = ncvar_rename(ncfile,"EDGEW","EDGEW") - # - # # double EDGEE(scalar) ; - # # EDGEE:long_name = "eastern edge in atmospheric data" ; - # # EDGEE:units = "degrees E" ; - # EDGEE = ncvar_rename(ncfile,"EDGEE","EDGEE") - # - # # double EDGES(scalar) ; - # # EDGES:long_name = "southern edge in atmospheric data" ; - # # EDGES:units = "degrees N" ; - # EDGES = ncvar_rename(ncfile,"EDGES","EDGES") - # # - # # double EDGEN(scalar) ; - # # EDGEN:long_name = "northern edge in atmospheric data" ; - # # EDGEN:units = "degrees N" ; - # EDGEN = ncvar_rename(ncfile,"EDGEN","EDGEN") } - - ncdf4::nc_close(nc) - } ## end file exists - } ### end loop over met files - + ncdf4::nc_close(nc) #PEcAn input file + } ## end input file exists + } ## end year loop over met files PEcAn.logger::logger.info("Done with met2model.FATES") - - return(data.frame(file = paste0(outfolder, "/"), - host = c(PEcAn.remote::fqdn()), - mimetype = c("application/x-netcdf"), - formatname = c("CLM met"), - startdate = c(start_date), - enddate = c(end_date), - dbfile.name = "", - stringsAsFactors = FALSE)) + return(invisible(results)) } # met2model.FATES + diff --git a/models/fates/R/model2netcdf.FATES.R b/models/fates/R/model2netcdf.FATES.R index b85cf946d38..b30a3179be7 100644 --- a/models/fates/R/model2netcdf.FATES.R +++ b/models/fates/R/model2netcdf.FATES.R @@ -10,581 +10,137 @@ ##' @name model2netcdf.FATES ##' @title Code to convert FATES netcdf output into into CF standard ##' -##' @param outdir Location of FATES model output +##' @param outdir Location of FATES model output (e.g. a path to a single ensemble output) +##' @param sitelat Latitude of the site +##' @param sitelon Longitude of the site +##' @param start_date Start time of the simulation +##' @param end_date End time of the simulation +##' @param pfts a named vector of PFT numbers where the names are PFT names ##' ##' @examples ##' \dontrun{ ##' example.output <- system.file("case.clm2.h0.2004-01-01-00000.nc",package="PEcAn.FATES") -##' model2netcdf.FATES(outdir="~/") +##' model2netcdf.FATES(outdir="~/",sitelat, sitelon, start_date, end_date, pfts) ##' } -##' -##' @export ##' ##' @author Michael Dietze, Shawn Serbin -model2netcdf.FATES <- function(outdir) { +## modified Yucong Hu 10/07/24 +##' +##' @export - # E.g. var_update("AR","AutoResp","kgC m-2 s-1", "Autotrophic Respiration") - # currently only works for xyt variables, need to expand to work for cohort-level outputs, - # age bins, soils, etc - var_update <- function(out,oldname,newname,newunits=NULL,long_name=NULL){ - if (oldname %in% ncin_names) { - ## define variable - oldunits <- ncdf4::ncatt_get(ncin,oldname,"units")$value - if (oldunits=="gC/m^2/s") oldunits <- "gC m-2 s-1" - if (oldname=="TLAI" && oldunits=="none") oldunits <- "m2 m-2" - if(is.null(newunits)) newunits = oldunits - newvar <- ncdf4::ncvar_def(name = newname, units = newunits, longname=long_name, dim = xyt) - - ## convert data - dat <- ncdf4::ncvar_get(ncin,oldname) - dat.new <- PEcAn.utils::misc.convert(dat,oldunits,newunits) - - ## prep for writing - if(is.null(out)) { - out <- list(var <- list(),dat <- list()) - out$var[[1]] <- newvar - out$dat[[1]] <- dat.new - } else { - i <- length(out$var) + 1 - out$var[[i]] <- newvar - out$dat[[i]] <- dat.new - } +model2netcdf.FATES <- function(outdir, sitelat, sitelon, start_date, end_date, pfts) { + ## matched_var could be updated further to take in only oldnames users need. + matched_var <- list(c("FATES_GPP_PF","GPP","kgC m-2 s-1","Gross Primary Productivity"), + c("NEE","NEE","kgC m-2 s-1", "Net Ecosystem Exchange of carbon, includes fire and hrv_xsmrpool"), + c("TLAI","LAI","m2 m-2","Total projected leaf area index"), + c("ER","TotalResp","kgC m-2 s-1","Total Respiration"), + c("AR","AutoResp","kgC m-2 s-1","Autotrophic respiration (MR + GR)"), + c("HR","HeteroResp","kgC m-2 s-1","Total heterotrophic respiration"), + c("SR","SoilResp","kgC m-2 s-1","Total soil respiration (HR + root resp)"), + c("Qle","Evap","Evap","kgC m-2 s-1","Total evaporation"), + c("QVEGT","Transp","kg m-2 s-1","Canopy transpiration")) + + var_update <- function(out,oldname,newname,nc_month,nc_month_names,newunits=NULL,long_name=NULL){ + if (oldname %in% nc_month_names) { + + ## define units of variables + oldunits <- ncdf4::ncatt_get(nc_month,oldname,"units")$value + if (oldunits=="gC/m^2/s") oldunits <- "gC m-2 s-1" + if (oldname=="TLAI") oldunits <- "m2 m-2" # delete old unit ='none' + if (is.null(newunits)) newunits = oldunits + + ## check pft dimensions + d_name <- c() + for (i in (nc_month$var[[oldname]]$dim)){ + d_name <- append(d_name, i$name) + } + if (any(grepl('pft',d_name))){ + dimension <- xypt # include fates_levpft + }else{ + dimension <- xyt + } # only xyt + + ## transpose dimensions into (,t) + if (d_name[length(d_name)]=='time'){ + dat_0 <- ncdf4::ncvar_get(nc_month,oldname) # time at the tail of dims + dat.new <- PEcAn.utils::misc.convert(dat_0,oldunits,newunits) # convert data units + newvar <- ncdf4::ncvar_def(name = newname, units = newunits, longname=long_name, dim = dimension) + ## Adding target variables into out + if(is.null(out)) { + out <- list(var <- list(),dat <- list(), dimm<-list()) + out$var[[1]] <- newvar + out$dat[[1]] <- dat.new + out$dimm[[1]]<- length(dimension) } else { - ## correct way to "skip" and output variables that may be missing in the HLM-FATES output? - PEcAn.logger::logger.info(paste0("HLM-FATES variable: ", oldname," not present. Skipping conversion")) + i <- length(out$var) + 1 + out$var[[i]] <- newvar + out$dat[[i]] <- dat.new + out$dimm[[i]]<- length(dimension) } - return(out) - } + } + return(out) + } - ## Get files and years - files <- dir(outdir, "*clm2.h0.*.nc", full.names = TRUE) # currently specific to clm2.h0 files - file.dates <- as.Date(sub(".nc", "", sub(".*clm2.h0.", "", files))) - years <- lubridate::year(file.dates) - init_year <- unique(years)[1] + ## Get files and years + files <- dir(outdir, "*clm2.h0.*.nc", full.names = TRUE) # currently specific to clm2.h0 files + file.dates <- lubridate::parse_date_time(sub(".nc", "", sub(".*clm2.h0.", "", files)),"%y-%m", tz='UTC') + years <- lubridate::year(file.dates) - ## Loop over years - for (year in unique(years)) { - ysel <- which(years == year) ## subselect files for selected year - if (length(ysel) > 1) { - PEcAn.logger::logger.warn("PEcAn.FATES::model2netcdf.FATES does not currently support multiple files per year") - } + ## Loop over years + for (year in start_year:end_year) { + ysel <- which(year == years) + fname <- files[ysel[1]] # FATES filename + oname <- file.path(dirname(fname), paste0(year, ".nc")) # Pecan filename + out <- NULL + for (month in ysel){ + month_file <- files[ysel[month]] + nc_month <- ncdf4::nc_open(month_file) # read monthly output file of FATES model + nc_month_names <- names(nc_month$var) - fname <- files[ysel[1]] - oname <- file.path(dirname(fname), paste0(year, ".nc")) - PEcAn.logger::logger.info(paste("model2netcdf.FATES - Converting:", fname, "to", oname)) - ncin <- ncdf4::nc_open(fname, write = TRUE) - ncin_names <- names(ncin$var) # get netCDF variable names in HLM-FATES output + ## Create time bounds to populate time_bounds variable iteratively + var_bound <- ncdf4::ncvar_get(nc_month, "time_bounds") # start,end day of month - - ## FATES time is in multiple columns, create 'time' - mcdate <- ncdf4::ncvar_get(ncin, "mcdate") # current date (YYYYMMDD) - if (length(mcdate)==1) { - ## do we need to bother converting outputs where FATES provides only a single timepoint for a date? - ## usually happens when the model starts/finishes at the end/start of a new year - PEcAn.logger::logger.debug("*** Skipping conversion for output with only a single timepoint ***") - next - } - cal_dates <- as.Date(as.character(mcdate),format="%Y%m%d") # in standard YYYY-MM-DD format - julian_dates <- lubridate::yday(cal_dates) # current year DOY values - day <- ncdf4::ncvar_get(ncin, "mdcur") # current day (from base day) - sec <- ncdf4::ncvar_get(ncin, "mscur") # current seconds of current day - nstep <- ncdf4::ncvar_get(ncin, "nstep") # model time step - time <- day + sec / 86400 # fractional time since base date (typically first day of full model simulation) - iter_per_day <- length(unique(sec)) # how many outputs per day (e.g. 1, 24, 48) - timesteps <- utils::head(seq(0, 1, by = 1 / iter_per_day), -1) # time of day fraction - current_year_tvals <- (julian_dates-1 + timesteps) # fractional DOY of current year - nt <- length(time) # output length - nc_time <- ncin$dim$time$vals # days since "start_date" - - # !! Is this a useful/reasonable check? That is that our calculated time - # matches FATES internal time var. - if (length(time)!=length(nc_time)) { - PEcAn.logger::logger.severe("Time dimension mismatch in output, simulation error?") - } - - ## Create time bounds to populate time_bounds variable - bounds <- array(data = NA, dim = c(length(time), 2)) - bounds[, 1] <- time - bounds[, 2] <- bounds[, 1] + (1 / iter_per_day) - bounds <- round(bounds, 4) # create time bounds for each timestep in t, t+1; t+1, t+2... format - - #******************** Declare netCDF dimensions ********************# - nc_var <- list() - sitelat <- ncdf4::ncvar_get(ncin,"lat") - sitelon <- ncdf4::ncvar_get(ncin,"lon") - ## time variable based on internal calc, nc$dim$time is the FATES output time - t <- ncdf4::ncdim_def(name = "time", units = paste0("days since ", init_year, "-01-01 00:00:00"), - vals = as.vector(time), calendar = "noleap", unlim = TRUE) + ## define dimensions + t <- ncdf4::ncdim_def(name = "time", units = paste0("days since ", unique(years)[1], "-01-01 00:00:00"), + vals = as.double(1.0:1.0), calendar = "noleap", unlim = TRUE) time_interval <- ncdf4::ncdim_def(name = "hist_interval", - longname = "history time interval endpoint dimensions", - vals = 1:2, units = "") - lat <- ncdf4::ncdim_def("lat", "degrees_north", vals = as.numeric(sitelat), longname = "coordinate_latitude") - lon <- ncdf4::ncdim_def("lon", "degrees_east", vals = as.numeric(sitelon), longname = "coordinate_longitude") - xyt <- list(lon, lat, t) - - ### build netCDF data - ## !! TODO: ADD MORE OUTPUTS HERE - out <- NULL - out <- var_update(out,"AR","AutoResp","kgC m-2 s-1","Autotrophic Respiration") - out <- var_update(out,"HR","HeteroResp","kgC m-2 s-1","Heterotrophic Respiration") - out <- var_update(out,"GPP","GPP","kgC m-2 s-1","Gross Primary Productivity") - out <- var_update(out,"NPP","NPP","kgC m-2 s-1","Net Primary Productivity") - out <- var_update(out,"NEP","NEE","kgC m-2 s-1", "Net Ecosystem Exchange") - out <- var_update(out,"FLDS","LWdown","W m-2","Surface incident longwave radiation") - out <- var_update(out,"FSDS","SWdown","W m-2","Surface incident shortwave radiation") - out <- var_update(out,"TBOT","Tair","K","Near surface air temperature") # not certain these are equivelent yet - out <- var_update(out,"QBOT","Qair","kg kg-1","Near surface specific humidity") # not certain these are equivelent yet - out <- var_update(out,"RH","RH","%","Relative Humidity") - out <- var_update(out,"WIND","Wind","m s-1","Near surface module of the wind") # not certain these are equivelent yet - out <- var_update(out,"EFLX_LH_TOT","Qle","W m-2","Latent heat") - out <- var_update(out,"QVEGT","Transp","mm s-1","Total Transpiration") ## equiv to std of kg m-2 s but don't trust udunits to get right - out <- var_update(out,"ED_balive","TotLivBiom","kgC m-2","Total living biomass") - out <- var_update(out,"ED_biomass","AbvGrndWood","kgC m-2","Above ground woody biomass") # not actually correct, need to update - out <- var_update(out,"AGB","AGB","kgC m-2","Total aboveground biomass") # not actually correct, need to update - out <- var_update(out,"ED_bleaf","leaf_carbon_content","kgC m-2","Leaf Carbon Content") - out <- var_update(out,"TLAI","LAI","m2 m-2","Leaf Area Index") - out <- var_update(out,"TSOI_10CM","SoilTemp","K","Average Layer Soil Temperature at 10cm") + longname = "history time interval endpoint dimensions",vals = 1:2, units = "") + lat <- ncdf4::ncdim_def("lat", "degrees_north", vals = as.double(1.0:1.0), longname = "coordinate_latitude") + lon <- ncdf4::ncdim_def("lon", "degrees_east", vals = as.double(1.0:1.0), longname = "coordinate_longitude") + pft <- ncdf4::ncdim_def('pft', '', vals=1:12, longname = "FATES pft number") + xyt <- list(lon, lat, t) + xypt <- list(lon, lat, pft, t) - ## put in time_bounds before writing out new nc file - length(out$var) + ## write monthly files with start(1,1,i) + for (name_param in matched_var){ + out <- var_update(out,name_param[1],name_param[2],name_param[3],name_param[4],nc_month,nc_month_names) # convert monthly fates output into one variable + } out$var[[length(out$var) + 1]] <- ncdf4::ncvar_def(name="time_bounds", units='', - longname = "history time interval endpoints", - dim=list(time_interval,time = t), - prec = "double") - out$dat[[length(out$dat) + 1]] <- c(rbind(bounds[, 1], bounds[, 2])) - - ## close input nc file - try(ncdf4::nc_close(ncin)) - - ## write netCDF data - ncout <- ncdf4::nc_create(oname,out$var) - ncdf4::ncatt_put(ncout, "time", "bounds", "time_bounds", prec=NA) - for (i in seq_along(out$var)) { - ncdf4::ncvar_put(ncout, out$var[[i]], out$dat[[i]]) + longname = "history time interval endpoints", dim=list(time_interval,t), prec = "double") + out$dat[[length(out$dat) + 1]] <- c(rbind(var_bound[1], var_bound[2])) #start, end days of the year + out$dimm[[length(out$dimm) + 1]] <- 2 + if(month==ysel[1]){ + ncout <- ncdf4::nc_create(oname,out$var) # create yearly nc file + # HYC: define var time, lon, lat, and put var lon, lat + time_var <- ncdf4::ncvar_def(name = "time", units = paste0("days since ", unique(years)[1], "-01-01 00:00:00"),longname = "time", dim = list(t), prec = "double") + lat_var <- ncdf4::ncvar_def(name = "lat", units = "degrees_north", longname = "coordinate_latitude", dim=list(lat), prec = "double") + lon_var <- ncdf4::ncvar_def(name = "lon", units = "degrees_east", longname = "coordinate_longitude", dim=list(lon), prec = "double") + ncdf4::ncvar_put(ncout, lat_var, sitelat, start=c(1)) + ncdf4::ncvar_put(ncout, lon_var, sitelon, start=c(1)) } - - ## extract variable and long names to VAR file for PEcAn vis - utils::write.table(sapply(ncout$var, function(x) { x$longname }), - file = paste0(oname, ".var"), - col.names = FALSE, - row.names = TRUE, - quote = FALSE) - - try(ncdf4::nc_close(ncout)) - + # put time + ncdf4::ncvar_put(ncout, time_var, mean(var_bound), start=c(month), count=c(1)) + for (i in seq_along(out$var)) { + if(out$dimm[[i]]==4){ # xypt + ncdf4::ncvar_put(ncout, out$var[[i]], out$dat[[i]], start=c(1,1,1,month), count=c(1,1,12,1)) + }else if (out$dimm[[i]]==3) { # xyt + ncdf4::ncvar_put(ncout, out$var[[i]], out$dat[[i]], start=c(1,1,month)) + }else{ # time_bounds + ncdf4::ncvar_put(ncout, out$var[[i]], out$dat[[i]], start=c(1,month)) + } + } # write monthly converted variable into PEcAn output + } + try(ncdf4::nc_close(ncout)) } # end of year for loop } # model2netcdf.FATES - -### !!! NOTES -### extract variables. These need to be read in and converted to PEcAN standard - -# levgrnd:long_name = "coordinate soil levels" ; -# levlak:long_name = "coordinate lake levels" ; -# levdcmp:long_name = "coordinate soil levels" ; -# mcdate:long_name = "current date (YYYYMMDD)" ; -# mcsec:long_name = "current seconds of current date" ; -# mdcur:long_name = "current day (from base day)" ; -# mscur:long_name = "current seconds of current day" ; -# nstep:long_name = "time step" ; -# lon:long_name = "coordinate longitude" ; -# lat:long_name = "coordinate latitude" ; -# area:long_name = "grid cell areas" ; -# topo:long_name = "grid cell topography" ; -# landfrac:long_name = "land fraction" ; -# landmask:long_name = "land/ocean mask (0.=ocean and 1.=land)" ; -# pftmask:long_name = "pft real/fake mask (0.=fake and 1.=real)" ; -# ZSOI:long_name = "soil depth" ; -# DZSOI:long_name = "soil thickness" ; -# WATSAT:long_name = "saturated soil water content (porosity)" ; -# SUCSAT:long_name = "saturated soil matric potential" ; -# BSW:long_name = "slope of soil water retention curve" ; -# HKSAT:long_name = "saturated hydraulic conductivity" ; -# ZLAKE:long_name = "lake layer node depth" ; -# DZLAKE:long_name = "lake layer thickness" ; -# ACTUAL_IMMOB:long_name = "actual N immobilization" ; -# AGNPP:long_name = "aboveground NPP" ; -# ALT:long_name = "current active layer thickness" ; -# ALTMAX:long_name = "maximum annual active layer thickness" ; -# ALTMAX_LASTYEAR:long_name = "maximum prior year active layer thickness" ; -# AR:long_name = "autotrophic respiration (MR + GR)" ; -# BAF_CROP:long_name = "fractional area burned for crop" ; -# BAF_PEATF:long_name = "fractional area burned in peatland" ; -# BCDEP:long_name = "total BC deposition (dry+wet) from atmosphere" ; -# BGNPP:long_name = "belowground NPP" ; -# BUILDHEAT:long_name = "heat flux from urban building interior to walls and roof" ; -# COL_CTRUNC:long_name = "column-level sink for C truncation" ; -# COL_FIRE_CLOSS:long_name = "total column-level fire C loss for non-peat fires outside land-type converted region" ; -# COL_FIRE_NLOSS:long_name = "total column-level fire N loss" ; -# COL_NTRUNC:long_name = "column-level sink for N truncation" ; -# CPOOL:long_name = "temporary photosynthate C pool" ; -# CWDC:long_name = "CWD C" ; -# CWDC_HR:long_name = "coarse woody debris C heterotrophic respiration" ; -# CWDC_LOSS:long_name = "coarse woody debris C loss" ; -# CWDC_TO_LITR2C:long_name = "decomp. of coarse woody debris C to litter 2 C" ; -# CWDC_TO_LITR3C:long_name = "decomp. of coarse woody debris C to litter 3 C" ; -# CWDN:long_name = "CWD N" ; -# CWDN_TO_LITR2N:long_name = "decomp. of coarse woody debris N to litter 2 N" ; -# CWDN_TO_LITR3N:long_name = "decomp. of coarse woody debris N to litter 3 N" ; -# DEADCROOTC:long_name = "dead coarse root C" ; -# DEADCROOTN:long_name = "dead coarse root N" ; -# DEADSTEMC:long_name = "dead stem C" ; -# DEADSTEMN:long_name = "dead stem N" ; -# DENIT:long_name = "total rate of denitrification" ; -# DISPVEGC:long_name = "displayed veg carbon, excluding storage and cpool" -# DISPVEGN:long_name = "displayed vegetation nitrogen" ; -# DSTDEP:long_name = "total dust deposition (dry+wet) from atmosphere" ; -# DSTFLXT:long_name = "total surface dust emission" ; -# DWT_CLOSS:long_name = "total carbon loss from land cover conversion" ; -# DWT_CONV_CFLUX:long_name = "conversion C flux (immediate loss to atm)" ; -# DWT_CONV_NFLUX:long_name = "conversion N flux (immediate loss to atm)" ; -# DWT_NLOSS:long_name = "total nitrogen loss from landcover conversion" ; -# DWT_PROD100C_GAIN:long_name = "landcover change-driven addition to 100-yr wood product pool" ; -# DWT_PROD100N_GAIN:long_name = "addition to 100-yr wood product pool" ; -# DWT_PROD10C_GAIN:long_name = "landcover change-driven addition to 10-yr wood product pool" ; -# DWT_PROD10N_GAIN:long_name = "addition to 10-yr wood product pool" ; -# DWT_SEEDC_TO_DEADSTEM:long_name = "seed source to patch-level deadstem" ; -# DWT_SEEDC_TO_LEAF:long_name = "seed source to patch-level leaf" ; -# DWT_SEEDN_TO_DEADSTEM:long_name = "seed source to PFT-level deadstem" ; -# DWT_SEEDN_TO_LEAF:long_name = "seed source to PFT-level leaf" ; -# EFLX_DYNBAL:long_name = "dynamic land cover change conversion energy flux" ; -# EFLX_GRND_LAKE:long_name = "net heat flux into lake/snow surface, excluding light transmission" ; -# EFLX_LH_TOT:long_name = "total latent heat flux [+ to atm]" ; -# EFLX_LH_TOT_R:long_name = "Rural total evaporation" ; -# EFLX_LH_TOT_U:long_name = "Urban total evaporation" ; -# ELAI:long_name = "exposed one-sided leaf area index" ; -# ER:long_name = "total ecosystem respiration, autotrophic + heterotrophic" ; -# ERRH2O:long_name = "total water conservation error" ; -# ERRH2OSNO:long_name = "imbalance in snow depth (liquid water)" ; -# ERRSEB:long_name = "surface energy conservation error" ; -# ERRSOI:long_name = "soil/lake energy conservation error" ; -# ERRSOL:long_name = "solar radiation conservation error" ; -# ESAI:long_name = "exposed one-sided stem area index" ; -# FAREA_BURNED:long_name = "timestep fractional area burned" ; -# FCEV:long_name = "canopy evaporation" ; -# FCOV:long_name = "fractional impermeable area" ; -# FCTR:long_name = "canopy transpiration" ; -# FGEV:long_name = "ground evaporation" ; -# FGR:long_name = "heat flux into soil/snow including snow melt and lake / snow light transmission" ; -# FGR12:long_name = "heat flux between soil layers 1 and 2" ; -# FGR_R:long_name = "Rural heat flux into soil/snow including snow melt and snow light transmission" ; -# FGR_U:long_name = "Urban heat flux into soil/snow including snow melt" ; -# FH2OSFC:long_name = "fraction of ground covered by surface water" ; -# FIRA:long_name = "net infrared (longwave) radiation" ; -# FIRA_R:long_name = "Rural net infrared (longwave) radiation" ; -# FIRA_U:long_name = "Urban net infrared (longwave) radiation" ; -# FIRE:long_name = "emitted infrared (longwave) radiation" ; -# FIRE_R:long_name = "Rural emitted infrared (longwave) radiation" ; -# FIRE_U:long_name = "Urban emitted infrared (longwave) radiation" ; -# FLDS:long_name = "atmospheric longwave radiation" ; -# FPG:long_name = "fraction of potential gpp" ; -# FPI:long_name = "fraction of potential immobilization" ; -# FPSN:long_name = "photosynthesis" ; -# FPSN_WC:long_name = "Rubisco-limited photosynthesis" ; -# FPSN_WJ:long_name = "RuBP-limited photosynthesis" ; -# FPSN_WP:long_name = "Product-limited photosynthesis" ; -# FROOTC:long_name = "fine root C" ; -# FROOTC_ALLOC:long_name = "fine root C allocation" ; -# FROOTC_LOSS:long_name = "fine root C loss" ; -# FROOTN:long_name = "fine root N" ; -# FSA:long_name = "absorbed solar radiation" ; -# FSAT:long_name = "fractional area with water table at surface" ; -# FSA_R:long_name = "Rural absorbed solar radiation" ; -# FSA_U:long_name = "Urban absorbed solar radiation" ; -# FSDS:long_name = "atmospheric incident solar radiation" ; -# FSDSND:long_name = "direct nir incident solar radiation" ; -# FSDSNDLN:long_name = "direct nir incident solar radiation at local noon" ; -# FSDSNI:long_name = "diffuse nir incident solar radiation" ; -# FSDSVD:long_name = "direct vis incident solar radiation" ; -# FSDSVDLN:long_name = "direct vis incident solar radiation at local noon" ; -# FSDSVI:long_name = "diffuse vis incident solar radiation" ; -# FSDSVILN:long_name = "diffuse vis incident solar radiation at local noon" ; -# FSH:long_name = "sensible heat" ; -# FSH_G:long_name = "sensible heat from ground" ; -# FSH_NODYNLNDUSE:long_name = "sensible heat not including correction for land use change" ; -# FSH_R:long_name = "Rural sensible heat" ; -# FSH_U:long_name = "Urban sensible heat" ; -# FSH_V:long_name = "sensible heat from veg" ; -# FSM:long_name = "snow melt heat flux" ; -# FSM_R:long_name = "Rural snow melt heat flux" ; -# FSM_U:long_name = "Urban snow melt heat flux" ; -# FSNO:long_name = "fraction of ground covered by snow" ; -# FSNO_EFF:long_name = "effective fraction of ground covered by snow" ; -# FSR:long_name = "reflected solar radiation" ; -# FSRND:long_name = "direct nir reflected solar radiation" ; -# FSRNDLN:long_name = "direct nir reflected solar radiation at local noon" ; -# FSRNI:long_name = "diffuse nir reflected solar radiation" ; -# FSRVD:long_name = "direct vis reflected solar radiation" ; -# FSRVDLN:long_name = "direct vis reflected solar radiation at local noon" ; -# FSRVI:long_name = "diffuse vis reflected solar radiation" ; -# FUELC:long_name = "fuel load" ; -# GC_HEAT1:long_name = "initial gridcell total heat content" ; -# GC_ICE1:long_name = "initial gridcell total ice content" ; -# GC_LIQ1:long_name = "initial gridcell total liq content" ; -# GPP:long_name = "gross primary production" ; -# GR:long_name = "total growth respiration" ; -# GROSS_NMIN:long_name = "gross rate of N mineralization" ; -# H2OCAN:long_name = "intercepted water" ; -# H2OSFC:long_name = "surface water depth" ; -# H2OSNO:long_name = "snow depth (liquid water)" ; -# H2OSNO_TOP:long_name = "mass of snow in top snow layer" ; -# HC:long_name = "heat content of soil/snow/lake" ; -# HCSOI:long_name = "soil heat content" ; -# HEAT_FROM_AC:long_name = "sensible heat flux put into canyon due to heat removed from air conditioning" ; -# HR:long_name = "total heterotrophic respiration" ; -# HTOP:long_name = "canopy top" ; -# LAISHA:long_name = "shaded projected leaf area index" ; -# LAISUN:long_name = "sunlit projected leaf area index" ; -# LAKEICEFRAC:long_name = "lake layer ice mass fraction" ; -# LAKEICETHICK:long_name = "thickness of lake ice (including physical expansion on freezing)" ; -# LAND_UPTAKE:long_name = "NEE minus LAND_USE_FLUX, negative for update" ; -# LAND_USE_FLUX:long_name = "total C emitted from land cover conversion and wood product pools" ; -# LEAFC:long_name = "leaf C" ; -# LEAFC_ALLOC:long_name = "leaf C allocation" ; -# LEAFC_LOSS:long_name = "leaf C loss" ; -# LEAFN:long_name = "leaf N" ; -# LEAF_MR:long_name = "leaf maintenance respiration" ; -# LFC2:long_name = "conversion area fraction of BET and BDT that burned" ; -# LF_CONV_CFLUX:long_name = "conversion carbon due to BET and BDT area decreasing" ; -# LITFALL:long_name = "litterfall (leaves and fine roots)" ; -# LITHR:long_name = "litter heterotrophic respiration" ; -# LITR1C:long_name = "LITR1 C" ; -# LITR1C_TO_SOIL1C:long_name = "decomp. of litter 1 C to soil 1 C" ; -# LITR1N:long_name = "LITR1 N" ; -# LITR1N_TNDNCY_VERT_TRANS:long_name = "litter 1 N tendency due to vertical transport" ; -# LITR1N_TO_SOIL1N:long_name = "decomp. of litter 1 N to soil 1 N" ; -# LITR1_HR:long_name = "Het. Resp. from litter 1" ; -# LITR2C:long_name = "LITR2 C" ; -# LITR2C_TO_SOIL2C:long_name = "decomp. of litter 2 C to soil 2 C" ; -# LITR2N:long_name = "LITR2 N" ; -# LITR2N_TNDNCY_VERT_TRANS:long_name = "litter 2 N tendency due to vertical transport" ; -# LITR2N_TO_SOIL2N:long_name = "decomp. of litter 2 N to soil 2 N" ; -# LITR2_HR:long_name = "Het. Resp. from litter 2" ; -# LITR3C:long_name = "LITR3 C" ; -# LITR3C_TO_SOIL3C:long_name = "decomp. of litter 3 C to soil 3 C" ; -# LITR3N:long_name = "LITR3 N" ; -# LITR3N_TNDNCY_VERT_TRANS:long_name = "litter 3 N tendency due to vertical transport" ; -# LITR3N_TO_SOIL3N:long_name = "decomp. of litter 3 N to soil 3 N" ; -# LITR3_HR:long_name = "Het. Resp. from litter 3" ; -# LITTERC:long_name = "litter C" ; -# LITTERC_HR:long_name = "litter C heterotrophic respiration" ; -# LITTERC_LOSS:long_name = "litter C loss" ; -# LIVECROOTC:long_name = "live coarse root C" ; -# LIVECROOTN:long_name = "live coarse root N" ; -# LIVESTEMC:long_name = "live stem C" ; -# LIVESTEMN:long_name = "live stem N" ; -# MEG_acetaldehyde:long_name = "MEGAN flux" ; -# MEG_acetic_acid:long_name = "MEGAN flux" ; -# MEG_acetone:long_name = "MEGAN flux" ; -# MEG_carene_3:long_name = "MEGAN flux" ; -# MEG_ethanol:long_name = "MEGAN flux" ; -# MEG_formaldehyde:long_name = "MEGAN flux" ; -# MEG_isoprene:long_name = "MEGAN flux" ; -# MEG_methanol:long_name = "MEGAN flux" ; -# MEG_pinene_a:long_name = "MEGAN flux" ; -# MEG_thujene_a:long_name = "MEGAN flux" ; -# MR:long_name = "maintenance respiration" ; -# M_LITR1C_TO_LEACHING:long_name = "litter 1 C leaching loss" ; -# M_LITR2C_TO_LEACHING:long_name = "litter 2 C leaching loss" ; -# M_LITR3C_TO_LEACHING:long_name = "litter 3 C leaching loss" ; -# M_SOIL1C_TO_LEACHING:long_name = "soil 1 C leaching loss" ; -# M_SOIL2C_TO_LEACHING:long_name = "soil 2 C leaching loss" ; -# M_SOIL3C_TO_LEACHING:long_name = "soil 3 C leaching loss" ; -# M_SOIL4C_TO_LEACHING:long_name = "soil 4 C leaching loss" ; -# NBP:long_name = "net biome production, includes fire, landuse, and harvest flux, positive for sink" ; -# NDEPLOY:long_name = "total N deployed in new growth" ; -# NDEP_TO_SMINN:long_name = "atmospheric N deposition to soil mineral N" ; -# NEE:long_name = "net ecosystem exchange of carbon, includes fire, landuse, harvest, and hrv_xsmrpool flux, positive for source" ; -# NEP:long_name = "net ecosystem production, excludes fire, landuse, and harvest flux, positive for sink" ; -# NET_NMIN:long_name = "net rate of N mineralization" ; -# NFIRE:long_name = "fire counts valid only in Reg.C" ; -# NFIX_TO_SMINN:long_name = "symbiotic/asymbiotic N fixation to soil mineral N" ; -# NPP:long_name = "net primary production" ; -# OCDEP:long_name = "total OC deposition (dry+wet) from atmosphere" ; -# O_SCALAR:long_name = "fraction by which decomposition is reduced due to anoxia" ; -# PARVEGLN:long_name = "absorbed par by vegetation at local noon" ; -# PBOT:long_name = "atmospheric pressure" ; -# PCO2:long_name = "atmospheric partial pressure of CO2" ; -# PCT_LANDUNIT:long_name = "% of each landunit on grid cell" ; -# PCT_NAT_PFT:long_name = "% of each PFT on the natural vegetation (i.e., soil) landunit" ; -# PFT_CTRUNC:long_name = "patch-level sink for C truncation" ; -# PFT_FIRE_CLOSS:long_name = "total patch-level fire C loss for non-peat fires outside land-type converted region" ; -# PFT_FIRE_NLOSS:long_name = "total pft-level fire N loss" ; -# PFT_NTRUNC:long_name = "pft-level sink for N truncation" ; -# PLANT_NDEMAND:long_name = "N flux required to support initial GPP" ; -# POTENTIAL_IMMOB:long_name = "potential N immobilization" ; -# PROD100C:long_name = "100-yr wood product C" ; -# PROD100C_LOSS:long_name = "loss from 100-yr wood product pool" ; -# PROD100N:long_name = "100-yr wood product N" ; -# PROD100N_LOSS:long_name = "loss from 100-yr wood product pool" ; -# PROD10C:long_name = "10-yr wood product C" ; -# PROD10C_LOSS:long_name = "loss from 10-yr wood product pool" ; -# PROD10N:long_name = "10-yr wood product N" ; -# PROD10N_LOSS:long_name = "loss from 10-yr wood product pool" ; -# PRODUCT_CLOSS:long_name = "total carbon loss from wood product pools" ; -# PRODUCT_NLOSS:long_name = "total N loss from wood product pools" ; -# PSNSHA:long_name = "shaded leaf photosynthesis" ; -# PSNSHADE_TO_CPOOL:long_name = "C fixation from shaded canopy" ; -# PSNSUN:long_name = "sunlit leaf photosynthesis" ; -# PSNSUN_TO_CPOOL:long_name = "C fixation from sunlit canopy" ; -# Q2M:long_name = "2m specific humidity" ; -# QBOT:long_name = "atmospheric specific humidity" ; -# QDRAI:long_name = "sub-surface drainage" ; -# QDRAI_PERCH:long_name = "perched wt drainage" ; -# QDRAI_XS:long_name = "saturation excess drainage" ; -# QDRIP:long_name = "throughfall" ; -# QFLOOD:long_name = "runoff from river flooding" ; -# QFLX_ICE_DYNBAL:long_name = "ice dynamic land cover change conversion runoff flux" ; -# QFLX_LIQ_DYNBAL:long_name = "liq dynamic land cover change conversion runoff flux" ; -# QH2OSFC:long_name = "surface water runoff" ; -# QINFL:long_name = "infiltration" ; -# QINTR:long_name = "interception" ; -# QIRRIG:long_name = "water added through irrigation" ; -# QOVER:long_name = "surface runoff" ; -# QRGWL:long_name = "surface runoff at glaciers (liquid only), wetlands, lakes" ; -# QRUNOFF:long_name = "total liquid runoff (does not include QSNWCPICE)" ; -# QRUNOFF_NODYNLNDUSE:long_name = "total liquid runoff (does not include QSNWCPICE) not including correction for land use change" ; -# QRUNOFF_R:long_name = "Rural total runoff" ; -# QRUNOFF_U:long_name = "Urban total runoff" ; -# QSNOMELT:long_name = "snow melt" ; -# QSNWCPICE:long_name = "excess snowfall due to snow capping" ; -# QSNWCPICE_NODYNLNDUSE:long_name = "excess snowfall due to snow capping not including correction for land use change" ; -# QSOIL:long_name = "Ground evaporation (soil/snow evaporation + soil/snow sublimation - dew)" ; -# QVEGE:long_name = "canopy evaporation" ; -# QVEGT:long_name = "canopy transpiration" ; -# RAIN:long_name = "atmospheric rain" ; -# RETRANSN:long_name = "plant pool of retranslocated N" ; -# RETRANSN_TO_NPOOL:long_name = "deployment of retranslocated N" ; -# RH2M:long_name = "2m relative humidity" ; -# RH2M_R:long_name = "Rural 2m specific humidity" ; -# RH2M_U:long_name = "Urban 2m relative humidity" ; -# RR:long_name = "root respiration (fine root MR + total root GR)" ; -# RSCANOPY:long_name = "canopy resistance" ; -# SABG:long_name = "solar rad absorbed by ground" ; -# SABG_PEN:long_name = "Rural solar rad penetrating top soil or snow layer" ; -# SABV:long_name = "solar rad absorbed by veg" ; -# SEEDC:long_name = "pool for seeding new Patches" ; -# SEEDN:long_name = "pool for seeding new PFTs" ; -# SMINN:long_name = "soil mineral N" ; -# SMINN_LEACHED:long_name = "soil mineral N pool loss to leaching" ; -# SMINN_TO_DENIT_L1S1:long_name = "denitrification for decomp. of litter 1to SOIL1" ; -# SMINN_TO_DENIT_L2S2:long_name = "denitrification for decomp. of litter 2to SOIL2" ; -# SMINN_TO_DENIT_L3S3:long_name = "denitrification for decomp. of litter 3to SOIL3" ; -# SMINN_TO_DENIT_S1S2:long_name = "denitrification for decomp. of soil 1to SOIL2" ; -# SMINN_TO_DENIT_S2S3:long_name = "denitrification for decomp. of soil 2to SOIL3" ; -# SMINN_TO_DENIT_S3S4:long_name = "denitrification for decomp. of soil 3to SOIL4" ; -# SMINN_TO_DENIT_S4:long_name = "denitrification for decomp. of soil 4to atmosphe" ; -# SMINN_TO_NPOOL:long_name = "deployment of soil mineral N uptake" ; -# SMINN_TO_PLANT:long_name = "plant uptake of soil mineral N" ; -# SMINN_TO_SOIL1N_L1:long_name = "mineral N flux for decomp. of LITR1to SOIL1" ; -# SMINN_TO_SOIL2N_L2:long_name = "mineral N flux for decomp. of LITR2to SOIL2" ; -# SMINN_TO_SOIL2N_S1:long_name = "mineral N flux for decomp. of SOIL1to SOIL2" ; -# SMINN_TO_SOIL3N_L3:long_name = "mineral N flux for decomp. of LITR3to SOIL3" ; -# SMINN_TO_SOIL3N_S2:long_name = "mineral N flux for decomp. of SOIL2to SOIL3" ; -# SMINN_TO_SOIL4N_S3:long_name = "mineral N flux for decomp. of SOIL3to SOIL4" ; -# SNOBCMCL:long_name = "mass of BC in snow column" ; -# SNOBCMSL:long_name = "mass of BC in top snow layer" ; -# SNODSTMCL:long_name = "mass of dust in snow column" ; -# SNODSTMSL:long_name = "mass of dust in top snow layer" ; -# SNOINTABS:long_name = "Percent of incoming solar absorbed by lower snow layers" ; -# SNOOCMCL:long_name = "mass of OC in snow column" ; -# SNOOCMSL:long_name = "mass of OC in top snow layer" ; -# SNOW:long_name = "atmospheric snow" ; -# SNOWDP:long_name = "gridcell mean snow height" ; -# SNOWICE:long_name = "snow ice" ; -# SNOWLIQ:long_name = "snow liquid water" ; -# SNOW_DEPTH:long_name = "snow height of snow covered area" ; -# SNOW_SINKS:long_name = "snow sinks (liquid water)" ; -# SNOW_SOURCES:long_name = "snow sources (liquid water)" ; -# SOIL1C:long_name = "SOIL1 C" ; -# SOIL1C_TO_SOIL2C:long_name = "decomp. of soil 1 C to soil 2 C" ; -# SOIL1N:long_name = "SOIL1 N" ; -# SOIL1N_TNDNCY_VERT_TRANS:long_name = "soil 1 N tendency due to vertical transport" ; -# SOIL1N_TO_SOIL2N:long_name = "decomp. of soil 1 N to soil 2 N" ; -# SOIL1_HR:long_name = "Het. Resp. from soil 1" ; -# SOIL2C:long_name = "SOIL2 C" ; -# SOIL2C_TO_SOIL3C:long_name = "decomp. of soil 2 C to soil 3 C" ; -# SOIL2N:long_name = "SOIL2 N" ; -# SOIL2N_TNDNCY_VERT_TRANS:long_name = "soil 2 N tendency due to vertical transport" ; -# SOIL2N_TO_SOIL3N:long_name = "decomp. of soil 2 N to soil 3 N" ; -# SOIL2_HR:long_name = "Het. Resp. from soil 2" ; -# SOIL3C:long_name = "SOIL3 C" ; -# SOIL3C_TO_SOIL4C:long_name = "decomp. of soil 3 C to soil 4 C" ; -# SOIL3N:long_name = "SOIL3 N" ; -# SOIL3N_TNDNCY_VERT_TRANS:long_name = "soil 3 N tendency due to vertical transport" ; -# SOIL3N_TO_SOIL4N:long_name = "decomp. of soil 3 N to soil 4 N" ; -# SOIL3_HR:long_name = "Het. Resp. from soil 3" ; -# SOIL4C:long_name = "SOIL4 C" ; -# SOIL4N:long_name = "SOIL4 N" ; -# SOIL4N_TNDNCY_VERT_TRANS:long_name = "soil 4 N tendency due to vertical transport" ; -# SOIL4N_TO_SMINN:long_name = "mineral N flux for decomp. of SOIL4" ; -# SOIL4_HR:long_name = "Het. Resp. from soil 4" ; -# SOILC:long_name = "soil C" ; -# SOILC_HR:long_name = "soil C heterotrophic respiration" ; -# SOILC_LOSS:long_name = "soil C loss" ; -# SOILPSI:long_name = "soil water potential in each soil layer" ; -# SOMC_FIRE:long_name = "C loss due to peat burning" ; -# SOMHR:long_name = "soil organic matter heterotrophic respiration" ; -# SOM_C_LEACHED:long_name = "total flux of C from SOM pools due to leaching" ; -# SR:long_name = "total soil respiration (HR + root resp)" ; -# STORVEGC:long_name = "stored vegetation carbon, excluding cpool" ; -# STORVEGN:long_name = "stored vegetation nitrogen" ; -# SUPPLEMENT_TO_SMINN:long_name = "supplemental N supply" ; -# SoilAlpha:long_name = "factor limiting ground evap" ; -# SoilAlpha_U:long_name = "urban factor limiting ground evap" ; -# TAUX:long_name = "zonal surface stress" ; -# TAUY:long_name = "meridional surface stress" ; -# TBOT:long_name = "atmospheric air temperature" ; -# TBUILD:long_name = "internal urban building temperature" ; -# TG:long_name = "ground temperature" ; -# TG_R:long_name = "Rural ground temperature" ; -# TG_U:long_name = "Urban ground temperature" ; -# TH2OSFC:long_name = "surface water temperature" ; -# THBOT:long_name = "atmospheric air potential temperature" ; -# TKE1:long_name = "top lake level eddy thermal conductivity" ; -# TLAI:long_name = "total projected leaf area index" ; -# TLAKE:long_name = "lake temperature" ; -# TOTCOLC:long_name = "total column carbon, incl veg and cpool" ; -# TOTCOLN:long_name = "total column-level N" ; -# TOTECOSYSC:long_name = "total ecosystem carbon, incl veg but excl cpool" ; -# TOTECOSYSN:long_name = "total ecosystem N" ; -# TOTLITC:long_name = "total litter carbon" ; -# TOTLITN:long_name = "total litter N" ; -# TOTPFTC:long_name = "total patch-level carbon, including cpool" ; -# TOTPFTN:long_name = "total PFT-level nitrogen" ; -# TOTPRODC:long_name = "total wood product C" ; -# TOTPRODN:long_name = "total wood product N" ; -# TOTSOMC:long_name = "total soil organic matter carbon" ; -# TOTSOMN:long_name = "total soil organic matter N" ; -# TOTVEGC:long_name = "total vegetation carbon, excluding cpool" ; -# TOTVEGN:long_name = "total vegetation nitrogen" ; -# TREFMNAV:long_name = "daily minimum of average 2-m temperature" ; -# TREFMNAV_R:long_name = "Rural daily minimum of average 2-m temperature" ; -# TREFMNAV_U:long_name = "Urban daily minimum of average 2-m temperature" ; -# TREFMXAV:long_name = "daily maximum of average 2-m temperature" ; -# TREFMXAV_R:long_name = "Rural daily maximum of average 2-m temperature" ; -# TREFMXAV_U:long_name = "Urban daily maximum of average 2-m temperature" ; -# TSA:long_name = "2m air temperature" ; -# TSAI:long_name = "total projected stem area index" ; -# TSA_R:long_name = "Rural 2m air temperature" ; -# TSA_U:long_name = "Urban 2m air temperature" ; -# TSOI_10CM:long_name = "soil temperature in top 10cm of soil" ; -# TV:long_name = "vegetation temperature" ; -# TWS:long_name = "total water storage" ; -# T_SCALAR:long_name = "temperature inhibition of decomposition" ; -# U10:long_name = "10-m wind" ; -# URBAN_AC:long_name = "urban air conditioning flux" ; -# URBAN_HEAT:long_name = "urban heating flux" ; -# VOCFLXT:long_name = "total VOC flux into atmosphere" ; -# VOLR:long_name = "river channel water storage" ; -# WASTEHEAT:long_name = "sensible heat flux from heating/cooling sources of urban waste heat" ; -# WF:long_name = "soil water as frac. of whc for top 0.05 m" ; -# WIND:long_name = "atmospheric wind velocity magnitude" ; -# WOODC:long_name = "wood C" ; -# WOODC_ALLOC:long_name = "wood C eallocation" ; -# WOODC_LOSS:long_name = "wood C loss" ; -# WOOD_HARVESTC:long_name = "wood harvest carbon (to product pools)" ; -# WOOD_HARVESTN:long_name = "wood harvest N (to product pools)" ; -# W_SCALAR:long_name = "Moisture (dryness) inhibition of decomposition" -## ==================================================================================================# -## EOF diff --git a/models/fates/inst/template.job b/models/fates/inst/template.job index 724b268d194..5aaaedfb593 100644 --- a/models/fates/inst/template.job +++ b/models/fates/inst/template.job @@ -32,9 +32,9 @@ echo "Res: @RES@ " echo "Compset: @COMPSET@ " echo "Machine: @MACHINE@ " echo "Compiler: @COMPILER@ " -echo "Project_name: @PROJECT@ " +echo "Project_name: @PROJECT@ " ## delete? echo "--------------------------" -./create_newcase --case @CASEDIR@ --res @RES@ --compset @COMPSET@ --mach @MACHINE@ --compiler @COMPILER@ --project @PROJECT@ --run-unsupported +./create_newcase --case @CASEDIR@ --res @RES@ --compset @COMPSET@ --mach @MACHINE@ --compiler @COMPILER@ --project @PROJECT@ --driver nuopc --run-unsupported cd "@RUNDIR@" @@ -80,8 +80,27 @@ echo "*** Modify XMLs ***" ./xmlchange --file env_run.xml --id LND_DOMAIN_FILE --val 'domain.lnd.@SITE_NAME@.nc' ./xmlchange --file env_run.xml --id LND_DOMAIN_PATH --val '@INDIR@/share/domains/domain.clm/' ./xmlchange --file env_run.xml --id CLM_USRDAT_NAME --val '@SITE_NAME@' -## END REFCASE - +## END REFCASE +## NEW_xmlchange"---------------" +./xmlchange CLM_USRDAT_DIR=/ctsm-api/resources/data/SOD1 + +./xmlchange PTS_LON=26.6385 + +./xmlchange PTS_LAT=67.3623 + +./xmlchange MPILIB=mpich # need rebuild + +./xmlchange RUN_STARTDATE="2014-01-01" + +./xmlchange STOP_OPTION="ndays" + +./xmlchange STOP_N="365" + +./xmlchange DATM_YR_START="2014" + +./xmlchange DATM_YR_END="2014" +## "--------------------------" + ## ENV_BUILD update configurations ./xmlchange --file env_build.xml --id CIME_OUTPUT_ROOT --val @CASEDIR@ ./xmlchange --file env_build.xml --id EXEROOT --val @CASEDIR@/bld # temporary fix diff --git a/models/fates/man/met2model.FATES.Rd b/models/fates/man/met2model.FATES.Rd index 3899e5360ea..9ad044a42a4 100644 --- a/models/fates/man/met2model.FATES.Rd +++ b/models/fates/man/met2model.FATES.Rd @@ -25,15 +25,15 @@ met2model.FATES( \item{outfolder}{location on disk where outputs will be stored} -\item{start_date}{the start date of the data to be downloaded (will only use the year part of the date)} +\item{start_date}{the start date of the data to be downloaded} -\item{end_date}{the end date of the data to be downloaded (will only use the year part of the date)} +\item{end_date}{the end date of the data to be downloaded} \item{lst}{timezone offset to GMT in hours} \item{overwrite}{should existing files be overwritten} -\item{verbose}{should the function be very verbosefor(year in start_year:end_year)} +\item{verbose}{should the function be very verbose for(year in start_year:end_year)} } \description{ met2model wrapper for FATES diff --git a/models/fates/man/model2netcdf.FATES.Rd b/models/fates/man/model2netcdf.FATES.Rd index b1338622936..215322e869d 100644 --- a/models/fates/man/model2netcdf.FATES.Rd +++ b/models/fates/man/model2netcdf.FATES.Rd @@ -4,10 +4,20 @@ \alias{model2netcdf.FATES} \title{Code to convert FATES netcdf output into into CF standard} \usage{ -model2netcdf.FATES(outdir) +model2netcdf.FATES(outdir, sitelat, sitelon, start_date, end_date, pfts) } \arguments{ -\item{outdir}{Location of FATES model output} +\item{outdir}{Location of FATES model output (e.g. a path to a single ensemble output)} + +\item{sitelat}{Latitude of the site} + +\item{sitelon}{Longitude of the site} + +\item{start_date}{Start time of the simulation} + +\item{end_date}{End time of the simulation} + +\item{pfts}{a named vector of PFT numbers where the names are PFT names} } \description{ Code to convert FATES netcdf output into into CF standard @@ -16,7 +26,7 @@ Code to convert FATES netcdf output into into CF standard \dontrun{ example.output <- system.file("case.clm2.h0.2004-01-01-00000.nc",package="PEcAn.FATES") -model2netcdf.FATES(outdir="~/") +model2netcdf.FATES(outdir="~/",sitelat, sitelon, start_date, end_date, pfts) } }