Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/testdata/._cws_fake.csv
Binary file not shown.
1 change: 1 addition & 0 deletions tests/testdata/area_rect.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added tests/testdata/area_rect.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/testdata/area_rect.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
Binary file added tests/testdata/area_rect.shp
Binary file not shown.
Binary file added tests/testdata/area_rect.shx
Binary file not shown.
3,034 changes: 3,034 additions & 0 deletions tests/testdata/cws_fake.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/testdata/plot_shp.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added tests/testdata/plot_shp.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/testdata/plot_shp.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
Binary file added tests/testdata/plot_shp.shp
Binary file not shown.
Binary file added tests/testdata/plot_shp.shx
Binary file not shown.
221,185 changes: 221,185 additions & 0 deletions tests/testdata/pred_fake.csv

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions tests/testthat/test-bayesian_spatiotemporal_model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
test_that("inference function works as expected", {
data <- "../testdata/cws_fake.csv" |>
testthat::test_path() |>
read.csv()
pred <- "../testdata/pred_fake.csv" |>
testthat::test_path() |>
read.csv()
data$time <- as.POSIXct(data$time, tz = "UTC", format = "%Y-%m-%d %H:%M:%S")
pred$time <- as.POSIXct(pred$time, tz = "UTC", format = "%Y-%m-%d %H:%M:%S")
polygon <- "../testdata/area_rect.shp" |>
testthat::test_path() |>
terra::vect()
# Run inference
result <- inference(
data = data,
pred = pred,
polygon = polygon,
ts = lubridate::ymd_hms("1000-07-28 00:00:00"),
te = lubridate::ymd_hms("1000-07-28 02:00:00"),
verbose = TRUE,
debug = FALSE
)
# Assertions
expect_type(result, "list")
expect_named(result, c("pred", "mod", "info"))
expect_s3_class(result$pred, "data.frame")
expect_true(
all(
c(
"pred_mean",
"pred_ll",
"pred_ul",
"pred_sd"
) %in% colnames(result$pred)
)
)
expect_s3_class(result$mod, "inla")
expect_s3_class(result$info, "data.frame")
expect_true(
all(
c(
"mesh_max_edge",
"mesh_cutoff",
"pcrange_thresh",
"pcrange_proba",
"pcsigma_thresh",
"pcsigma_proba",
"pccor1_thresh",
"pccor1_proba",
"s2n_data_prior",
"s2x_data_prior",
"prior_a2",
"prior_b2",
"int_mean",
"era5_t2m_mean",
"era5_rh_mean",
"era5_tp_mean",
"era5_u10_mean",
"era5_v10_mean",
"era5_tcc_mean",
"local_hour19:elev_mean",
"local_hour20:elev_mean",
"local_hour21:elev_mean",
"local_hour19:fch_mean",
"local_hour20:fch_mean",
"local_hour21:fch_mean",
"local_hour19:imp_mean",
"local_hour20:imp_mean",
"local_hour21:imp_mean",
"int_sd",
"era5_t2m_sd",
"era5_rh_sd",
"era5_tp_sd",
"era5_u10_sd",
"era5_v10_sd",
"era5_tcc_sd",
"local_hour19:elev_sd",
"local_hour20:elev_sd",
"local_hour21:elev_sd",
"local_hour19:fch_sd",
"local_hour20:fch_sd",
"local_hour21:fch_sd",
"local_hour19:imp_sd",
"local_hour20:imp_sd",
"local_hour21:imp_sd",
"prec_gaussian_obs_mean",
"range_gaussian_obs_mean",
"stdev_s_mean",
"grouprho_s_mean",
"prec_gaussian_obs_sd",
"range_gaussian_obs_sd",
"stdev_s_sd",
"grouprho_s_sd"
) %in% colnames(result$info)
)
)
})