Convert PEcAn standard event parquet files to events.json
Source:R/event_parquet_to_json.R
event_parquet_to_json.RdWrites ensembles of PEcan events stored in parquet format to valid PEcAn events.json files, based on a manifest table specification.
Usage
event_parquet_to_json(
event_paths,
events_ensemble_manifest,
site_ids = NULL,
start_date = NULL,
end_date = NULL,
parquet_dir = NULL,
pecan_events_version = "0.1.2"
)Arguments
- event_paths
(character) Named character vector of paths to PEcAn standard event parquet files. Names correspond to event types; e.g., `c(leafon = "/path/to/leaf_on.parquet")`. If not names are provided, they are deduced from the file name (stripping the `.parquet` extension). Folders containing parquet files are also supported.
- events_ensemble_manifest
`data.frame` that maps PEcAn ensemble IDs and events.json paths onto ensembles of each event type. (See Details).
- site_ids
(character) Optional vector of `site_id` values for filtering.
- start_date
(Date or POSIXct) Optional start date for filtering events
- end_date
(Date or POSIXct) Optional end date for filtering events.
- parquet_dir
Alternative way to pass `event_paths` by just specifying a directory of PEcAn standard event files. Each file or folder must be named `<event_type>.parquet` (e.g., `irrigation.parquet/`, `leafon.parquet`).
- pecan_events_version
(character) Version of the PEcAn events.json standard to write to `events.json`. Default = 0.1.2.
Value
Nested tibble containing event data. `events.json` files are created for each ensemble member as a side effect.
Details
Similar to the overall PEcAn ensemble structure, the `events_ensemble_manifest` is a data frame that maps PEcAn ensemble IDs onto ensembles of each individual event. The data frame must have the following columns:
- `ensemble_id` (character) — PEcAn ensemble ID (used by PEcAn ensemble code) - `json_path` (character) — Path to the events.json file that will be written for this ensemble. - One column per event type (e.g., `irrigation`, `planting`, `harvest`, etc.), with values (character) corresponding to values in the `event_member_id` column in the corresponding files. The special value `"_NO_EVENT_ENSEMBLE"` means that the parquet data for that event does not have an `event_member_id` column (i.e., there is no ensemble analysis for that event type).