amadeus is an R package for accessing and analyzing large-scale, publicly available environmental data (atmospheric, meteorological, climate, emissions, pollution). It wraps 20+ data sources behind three primary functions: download_data(), process_covariates(), and calculate_covariates().
- Dispatch pattern: Wrapper functions (
download_data,process_covariates,calculate_covariates) route to source-specific implementations via string matching ondataset_name. - File layout:
R/download.R+R/download_auxiliary.R— download wrappers and source-specific download functionsR/process.R+R/process_auxiliary.R— process wrappers and source-specific process functionsR/calculate_covariates.R+R/calculate_covariates_auxiliary.R— extraction wrappers and source-specific calc functionsR/manipulate_spacetime_data.R— spatiotemporal utilitiesR/ignore.R— miscellaneous helpers
- Spatial stack:
terra(primary raster/vector),sf,stars,exactextractr
- Full Roxygen2 documentation on all exported functions with
@param,@return,@author,@seealso,@examples character(1),logical(1),numeric(1)scalar type annotations in@paramdocs- Use
data.table,dplyr,tidyrfor tabular data; avoid base R loops where vectorized alternatives exist httr2for HTTP requests- Linting via
lintr;nolint start/endblocks used sparingly for long URLs - Tests use
testthat(edition 3) withtestthat::test_that()wrappers
- Test files live in
tests/testthat/namedtest-<dataset>.R. Live API tests live alongside astest-<dataset>-live.Rand are gated byskip_if_no_live_tests(). - Shared mock/fixture helpers live in
tests/testthat/helper-*.R(auto-loaded by testthat):helper-mocks-download.R,helper-mocks-process.R,helper-fixtures.R,helper-skips.R. - Run mocked tests with
devtools::test(); run live tests withAMADEUS_LIVE_TESTS=true devtools::test(filter = "-live$"). The scheduled workflow.github/workflows/test-live.yamlruns live tests weekly. - Test descriptions must use the form
"<fn>(<arg=value>, ...): <expected behavior>"so failures identify the input combination under test. - Prefer typed expectations (
expect_s4_class,expect_gt,expect_length) overexpect_true(inherits(...)),expect_true(length(x) > 0), orexpect_no_error()wrappers. - See
vignettes/testing.Rmdfor full conventions and thetests/test_report/test_report.htmlquality scorecard.
- Add a
download_<name>()function indownload_auxiliary.R - Add the dataset name string(s) to the dispatch block in
download_data()indownload.R - Repeat for
process_<name>()/process_covariates()andcalc_<name>()/calculate_covariates()as needed - Export new functions in
NAMESPACE(via@exportroxygen tag +devtools::document()) - Add
test-<name>.R(mocked, CRAN-safe) using thehelper-mocks-*factories, andtest-<name>-live.R(gated byskip_if_no_live_tests()) for real-API verification
terraobjects are not serializable across parallel workers — use file paths, not in-memory objects, across workers- Always validate
acknowledgement = TRUEat the top of download functions before any side effects - CRS must be standardized to
EPSG:4326(or documented otherwise) in process functions