Changelog
Source:NEWS.md
xyt 0.1.0
First release. xyt lifts the extract(<read function>, <data.frame>) machinery out of raadtools, rewrites it against terra, and gives it a test suite that runs with no data behind it.
- New
extract_xyt(read, xyt, ...)extracts values from a raster time series at points that each carry their own date-time. The series is described by a reader function rather than held in memory, so only the slices some point needs are read, and each of those is read exactly once, in catalogue order, whatever order the rows arrive in. - The reader contract is two calls:
read(returnfiles = TRUE, ...)returns a catalogue data.frame with adatecolumn, andread(date, inputfiles = files, ...)returns a single-layer SpatRaster. raadtools readers satisfy it unchanged. - New
xyt_reader_check()runs those calls in the orderextract_xyt()will make them and reports PASS/FAIL for each step of the contract. - New
xyt_source(slice, catalogue)builds a reader from two ordinary functions, so thereturnfilesswitch never has to be written by hand. A catalogue given as a function is called once, on first use, and reused for the life of the source. Sources have aprint()method. -
extract_xyt(files = )accepts a pre-built catalogue, in which case thereturnfilescall is never made and the reader only has to read slices. - New
synthetic_reader()andsynthetic_value()provide a series with no files behind it, with a closed-form value at any (x, y, t), so tests and examples run anywhere terra is installed. -
when = c("nearest", "previous")makes the time-matching rule explicit. raadtools documentedctstime = FALSEas nearest-in-time but implemented it withfindInterval(), i.e. the previous slice."nearest"is the default and matches the documentation;"previous"reproduces the raadtools numbers. -
ctstime = TRUEinterpolates linearly between the two slices that bracket each point;method = "bilinear"interpolates in space as well. -
factaggregates each slice before extraction, andcrssets the coordinate system the input points are in (default"EPSG:4326"); points are projected to the raster’s CRS as needed. - Points beyond the collection in time return
NAwith a warning rather than stopping the call.tolerancesets how far is too far, defaulting to 1.5 times the spacing of the series. -
...is passed to the reader only. In raadtools it also went toextract(), which was the source of thexylim argument ignoredandinputfiles argument ignoredwarnings. Extraction is controlled by named arguments. - Character times are parsed one element at a time, so a track mixing whole days and date-times no longer has its times of day silently dropped by
as.POSIXct()picking one format from the first element. - Slice reads can run in parallel on mirai daemons. If
mirai::daemons()are running,extract_xyt()uses them without being told to;maptakes any function of(X, FUN), somap = lapplyforces serial reads and any other mapper can be dropped in. Newxyt_map_mirai()is the mapper used. The first slice is always read in the calling session, so it supplies the target CRS for every other task and a failing reader fails once rather than once per daemon. - When mori is installed and daemons are running, the catalogue is placed in shared memory with
mori::share()rather than serialised into every task (about 2.7 MB down to 284 bytes per task on a 16,000-row OISST catalogue, roughly halving wall time on six daemons).share = TRUEinsists,share = FALSErefuses, and with no mori installed nothing changes. - No S4. raadtools registered this as a method on raster’s
extractgeneric, which welded it to raster;extract_xyt()is a plain function with terra as the only hard dependency. mirai, mori and testthat are in Suggests. -
dev/bench-mirai.Rbenchmarks serial against daemon reads for a given collection and reports the serialised size of the catalogue payload.