Commit 68233032 authored by Haffenden Austin's avatar Haffenden Austin
Browse files

Initial commit to gitlab

parents
library(landclimSetup)
context("make_init_file")
# test needs to be created
test_that("test of make_SED_landscape", {
cat("test for make_init_file needs to be created? ")
})
library(landclimSetup)
context("landscape")
#==============================================================================
# take in data
curr_sites <- c("site1", "site2", "site3", "site4")
site_rast <- create_SED_raster(curr_sites)
#==============================================================================
# unit tests
# this ensures that the reference raster is created correctly
test_that("the site_rast is created correctly", {
expect_equal(raster::ncell(site_rast), 4)
})
library(landclimSetup)
context("make_SED_landscape")
# test needs to be created
test_that("test of make_SED_landscape", {
cat("test for make_SED_landscape needs to be created? ")
})
library(landclimSetup)
context("climate_and_lapse")
# take in data
source_dir <- file.path("data")
curr_site <- "site1"
# raw data from site1 climate file
clim_dat <- c(2004, 1.3, 3.2, 4.6, 9, 11.1, 15.1, 16.2,
17.6, 14.3, 10.3, 4.6, 1.2,
173, 52.3, 61.5, 61.8, 57.6, 70.7,
109.8, 172.2, 56, 81.2, 50.3, 79.4,
2005, 2.4, 0.3, 5.2, 8.9, 11.8, 17.1,
17.2, 15.7, 15.1, 12.4, 4.2, 1.7,
76.1, 103.5, 43.8, 60, 61, 58.1,
131.5, 72.9, 51.3, 55.7, 68.3, 77.6,
2006, -0.5, 0.5, 2.8, 7.6, 12.3, 16.3,
21, 14.9, 16.7, 12.7, 7.2, 4.1,
39.5, 98.7, 123, 56.5, 157.5, 31.5,
52, 179.8, 19.8, 78.3, 100.4, 144.7,
2007, 5.1, 5.1, 6, 11, 13.1, 16.3,
15.9, 16, 12.4, 9, 4.8, 2.3,
121.3, 159.7, 106.3, 5.1, 146.4, 122.8,
114.4, 120.2, 64.2, 59.3, 86.3, 130.2,
2008, 4.1, 4.2, 4.4, 7.3, 14.6, 15.1,
16.8, 16.4, 12.2, 8.9, 5.2, 1.4,
139, 100.5, 177.9, 90.2, 64.9, 91,
92.9, 97.4, 71.4, 104, 79.8, 78.2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
clim_dat <- matrix(as.numeric(clim_dat), nrow = 10, ncol = 25, byrow = T)
site1_temp_data <- read_climate_file(source_dir, curr_site)
# this compares the reading of the climate file
# unit tests
test_that("a single climate file is read in correctly ", {
expect_equal(site1_temp_data$lat, 50)
expect_equal(site1_temp_data$ref_elev, 256)
expect_equal(site1_temp_data$temp_lapse, rep(0, 12))
expect_equal(site1_temp_data$precip_lapse, rep(0, 12))
expect_equal(site1_temp_data$n_metres, 1)
expect_equal(site1_temp_data$temp_precip_data, clim_dat)
})
#==============================================================================
# this assesses the lapse adjustments with zero lapses
adj_data <- lapse_adjust_climate(site1_temp_data, 50)
test_that("application of 0 lapse rates are applied correctly", {
expect_equal(site1_temp_data$temp_precip_data, adj_data)
})
# this assesses the lapse adjustments with actual lapses
# this needs to be validated against the landclim output
adj_data <- lapse_adjust_climate(site1_temp_data, 50)
test_that("lapse rates are applied correctly - in line with LandClim", {
cat("\n", "test of correct application of lapse rates missing", "\n")
})
#==============================================================================
# this tests that the correct row and col are added to the climate data
# again this needs to be checked against landclim for effective operation
#site_rast <- raster::raster(file.path(source_dir, "site1_elev.asc"))
test_that("row and column are formulated correctly for SED climate files", {
cat("test of rowcolcell needs to be completed once
the landscape rasters are created")
})
#==============================================================================
# this tests that the SED climate data is written correctly
#
test_that("SED climate files are written correctly", {
cat("\n", "test of writing of SED climate file needs to be completed by
run/comparison with Landclim")
})
library(landclimSetup)
context("make_init_file")
# test needs to be created
test_that("test of write_latitude_to_climate", {
cat("test for test of write_latitude_to_climate needs to be created? ")
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment