context("saveInventory")
test_that("saving the NetCDF", {
grinded_so2 <- readRDS(paste0(system.file("extdata",package="inventory"),"/grid_so2.Rds"))
dir.create(file.path(tempdir(), "INV"))
saveInventory(grinded_so2,filename = paste0(file.path(tempdir(), "INV"),"test.nc"),
variable = "so2", dates = '2010-01-01')
grinded_no <- grinded_so2
names(grinded_no) <- c("NO","geometry")
saveInventory(grinded_no,filename = paste0(file.path(tempdir(), "INV"),"test.nc"),
variable = "NO", dates = '2010-01-01')
netcdef <- ncdf4::nc_open(paste0(file.path(tempdir(), "INV"),"test.nc"))
so2 <- ncdf4::ncvar_get(netcdef,"so2")
soma <- grinded_so2
sf::st_geometry(soma) <- NULL
soma <- sum(soma)
expect_equal(sum(so2), soma)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.