Write SIPNET events.in files from a PEcAn events.json
Source:R/write.events.SIPNET.R
write.events.SIPNET.RdReads a single PEcAn events.json containing one or more site objects and
writes one SIPNET events.in file per site. Events are translated according to SIPNET's events.in specification.
The writer expects inputs to already match the PEcAn MVP schema v0.1.0 naming and units where applicable.
Details
Supported
event_typevalues:tillage,planting,fertilization,irrigation,harvest.Units translated from PEcAn standard_vars to SIPNET events.in specification:
kg/m^2tog/m^2; irrigationamount_mmtocm.Planting allocation uses fixed internal parameters. Future work should use the same values that are written to
sipnet.parms(e.g. after integrating this intowrite.configs.SIPNET)
Examples
# Example with two events for a single site
tmp <- withr::local_tempfile(fileext = ".json")
site <- list(
site_id = "EX1",
events = list(
list(event_type = "tillage", date = "2022-02-04", tillage_eff_0to1 = 0.2),
list(event_type = "planting", date = "2022-02-19", leaf_c_kg_m2 = 0.01)
)
)
jsonlite::write_json(list(site), tmp, auto_unbox = TRUE)
outdir <- withr::local_tempdir()
files <- write.events.SIPNET(tmp, outdir)
files
#> [1] "/tmp/RtmpuYfSMa/file3228e947601/events-EX1.in"