Skip to contents

Reads a (JSON) management events file and finds the planting events at which the site changes from from one crop to another, ignoring repeat plantings of the same crop. These are the dates when single-PFT models will need to restart to update their crop parameterization.

Usage

events_to_crop_cycle_starts(event_json)

Arguments

event_json

path to an `events.json` file

Value

data frame with columns `site_id`, `date`, `crop`, with one row per detected crop cycle.

Details

Requires each planting event to specify a `crop_code` attribute, and reports a crop cycle change every time the crop code changes. Note that crop codes are not required to match your model's PFT names, so deciding how (or whether) to change parameterization on these dates is up to the model operator.

Also note that only _changes_ in crop code are detected: If the event file contains no planting events the result has zero rows, and any crop present before the first observed planting event (say from initial conditions) is not reported.

Author

Chris Black

Examples

evts <- system.file(
  "events_fixtures/events_site1_site2.json",
  package = "PEcAn.data.land"
)
events_to_crop_cycle_starts(evts)
#>   site_id       date crop_code
#> 1      S2 2022-03-01     maize