Skip to contents

Reads 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.

Usage

write.events.SIPNET(events_json, outdir)

Arguments

events_json

character. Path to an events.json file containing an array of site objects with site_id, optional pft, and events.

outdir

character. Output directory where per-site events-<site>.in files are written.

Value

Invisibly, a vector of files written.

Details

  • Supported event_type values: tillage, planting, fertilization, irrigation, harvest.

  • Units translated from PEcAn standard_vars to SIPNET events.in specification: kg/m^2 to g/m^2; irrigation amount_mm to cm.

  • Planting allocation uses fixed internal parameters. Future work should use the same values that are written to sipnet.parms (e.g. after integrating this into write.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"