Skip to content

Commit 53f1a22

Browse files
committed
Sipnet uses lowercase colnames
1 parent 52f9183 commit 53f1a22

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

models/sipnet/R/model2netcdf.SIPNET.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ model2netcdf.SIPNET <- function(outdir, sitelat, sitelon, start_date, end_date,
150150
)
151151

152152

153-
if (!("LAI" %in% colnames(sipnet_output))) {
153+
if (!("lai" %in% colnames(sipnet_output))) {
154154
# When LAI not reported, calculate it from leaf C and leaf specific weight,
155155
# with the latter read from the parameter file.
156156
# Note the hardcoded + undocumented assumption that ../run/sipnet.param
@@ -163,7 +163,7 @@ model2netcdf.SIPNET <- function(outdir, sitelat, sitelon, start_date, end_date,
163163
"sipnet.param"), stringsAsFactors = FALSE)
164164
leafCSpWt <- param[param[, 1] == "leafCSpWt", 2]
165165
SLA <- 1000 / leafCSpWt # m2 leaf / kg C
166-
sipnet_output$LAI = sipnet_output$plantLeafC * SLA
166+
sipnet_output$lai = sipnet_output$plantLeafC * SLA
167167
}
168168

169169
### Loop over years in SIPNET output to create separate netCDF outputs
@@ -213,7 +213,7 @@ model2netcdf.SIPNET <- function(outdir, sitelat, sitelon, start_date, end_date,
213213
"litter_carbon_content" = sub.sipnet.output$litter,
214214
"fine_root_carbon_content" = sub.sipnet.output$fineRootC,
215215
"coarse_root_carbon_content" = sub.sipnet.output$coarseRootC,
216-
"LAI" = sub.sipnet.output$LAI,
216+
"LAI" = sub.sipnet.output$lai,
217217
"TotLivBiom" = sub.sipnet.output$plantWoodC + sub.sipnet.output$plantLeafC +
218218
sub.sipnet.output$coarseRootC + sub.sipnet.output$fineRootC,
219219
"TotSoilCarb" = sub.sipnet.output$soil + sub.sipnet.output$litter,

models/sipnet/tests/testthat/test-model2netcdf.SIPNET.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ test_that("LAI taken from leafCSpWt if not present in output", {
304304
expect_equal(as.vector(ncdf4::ncvar_get(nc1, "LAI")), c(1, 10))
305305

306306
# Now with LAI specified => uses it as-is
307-
dat$LAI = c(2, 3)
307+
# (note the colname is lowercase in Sipnet output)
308+
dat$lai = c(2, 3)
308309
paths <- setup_sipnet_test(dat, notes_line = NULL)
309310
nc2 <- ncdf4::nc_open(file.path(paths$outdir, "2002.nc"))
310311
on.exit(ncdf4::nc_close(nc2), add = TRUE)

0 commit comments

Comments
 (0)