pf_access_particles_unique | R Documentation |
Given a list of particle histories (or a list of file paths), this function accesses the unique particles (cells) sampled by a particle filtering (PF) algorithm (pf
).
pf_access_particles_unique(
history,
use_memory_safe = FALSE,
cl = NULL,
varlist = NULL
)
history |
A |
use_memory_safe |
If |
cl , varlist |
(optional) Parallelisation options implemented if (a) particle histories are contained in memory or (b) particle histories are supplied as a list of file paths with |
The function returns a vector of the unique particles sampled by the PF algorithm.
Edward Lavender
pf
implements particle filtering.
#### Example (1): Access unique particles when 'history' exists in memory
# Access unique particles from a pf_archive object
pf_access_particles_unique(dat_dcpf_histories)
# Access unique particles from a list of particle histories
pf_access_particles_unique(dat_dcpf_histories$history)
# Supply a cluster to speed up the algorithm (for very large lists)
pf_access_particles_unique(dat_dcpf_histories$history,
cl = parallel::makeCluster(2L)
)
#### Example (2): Access unique particles when 'history' is a list of file paths
## Write example particle histories to file (to load)
root <- paste0(tempdir(), "/pf/")
dir.create(root)
pf_args <- dat_dcpf_histories$args
pf_args$calc_distance_euclid_fast <- TRUE
pf_args$write_history <- list(file = root)
out_pf <- do.call(pf, pf_args)
## Access particle histories using default options (use_memory_safe = FALSE)
# Access particle histories via pf_access_history_files()
pf_access_particles_unique(pf_access_history_files(root, use_list = TRUE))
# Supply a cluster to speed up the algorithm (for very large lists)
pf_access_particles_unique(pf_access_history_files(root, use_list = TRUE),
cl = parallel::makeCluster(2L)
)
## Access particle histories using the 'memory_safe' option
# For large lists, this is likely to be slower
# ... but it may be the only option in some cases.
pf_access_particles_unique(pf_access_history_files(root, use_list = TRUE),
use_memory_safe = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.