Skip to contents

Subset each SIPNET input file and write a new file containing values >= start.time and < end.time (note: end time is not inclusive)

Usage

split_inputs.SIPNET(
  start.time,
  stop.time,
  inputs,
  overwrite = FALSE,
  outpath = NULL,
  time_resolution = c("row", "day"),
  allow_varying_timesteps = TRUE
)

Arguments

start.time

Start date or datetime for splitting

stop.time

End date or datetime for splitting

inputs

Named inputs list as provided by PEcAn settings. Must have structure like: list(met = list(path = "path/to/sipnet.clim"), events = list(path = "path/to/events.in"), ...)

overwrite

if TRUE, overwrite existing target file (Default FALSE)

outpath

if specified, write output to a new directory. Default NULL writes back to the directory being read

time_resolution

One of "row", "day". Should the split happen at the closest row to the end time or align with a time unit? See details

allow_varying_timesteps

logical: Accept files where not all rows have the same duration? Disallowing can be substantially faster.

Value

Modified inputs list with all path entries replaced with new paths (suitable for inserting back into settings$run$inputs).

Details

NOTE that sipnet met files contain dates and times, while sipnet event files contain only dates. Comparing a datetime to a date will coerce the date to midnight UTC.

Efficiency

Splitting met files goes faster by far when all the inputs are known to have a uniform timestep, fixed number of characters per line, and all splits are at day boundaries. Setting time_resolution = "days" and allow_varying_timesteps = FALSE opts in to a fast code path that finds the wanted lines of the file by computing byte offsets and therefore avoids needing to read every row of the input file. For small subsets of large files this can be several times faster.

If the input has variable line length but constant timesteps (as determined by checking the first 10 lines; see the n_head argument of subset_met_lines()), the fast path is taken but is not as fast: it must scan from the beginning to count line separators, but still skips the tail of the file after stop.time is reached.

Author

Alexey Shiklomanov