Extract the first planting date of each crop cycle
Source:R/events_to_crop_cycle_starts.R
events_to_crop_cycle_starts.RdReads 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.
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.
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