inst/tests/test_fCalcPotRadiation.R

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#+++ Unit tests for fConvertTimeToPosix functions +++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Author: AMM, TW
#require(testthat)
context("fCalcPotRadiation")
# Furher context: fCheckColNames, fCheckColNumeric, fCheckOutsideRange


#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

test_that("Regression test",{
			hour <- seq(8,16, by=1)
			potRadSolar <- fCalcPotRadiation(160, hour, 39.94, -5.77, TimeZone=+1)
			expect_warning(potRadLocal <- fCalcPotRadiation(160, hour, 39.94, -5.77, TimeZone=+1, useSolartime.b = FALSE))
		expSolar <- structure(c(484.152670743821, 717.876981534078, 925.130678985721, 
						1091.78976612035, 1206.4967015669, 1261.43439723686, 1252.85893995917, 
						1181.35473297567, 1051.79466982602), varnames = "PotRad", units = "W_m-2")
		expLocal <- structure(c(797.589402859243, 991.498827921097, 1140.29076299454, 
						1233.82528359462, 1265.72816671554, 1233.82528359462, 1140.29076299454, 
						991.498827921097, 797.589402859243), varnames = "PotRad", units = "W_m-2")
	expect_that( potRadSolar, equals(expSolar) )
	expect_that( potRadLocal, equals(expLocal) )
})

test_that("warn on non-matching day-hour length",{
			hour <- seq(8,16, by=0.1)
			expect_warning( potRadSolar <- fCalcPotRadiation(160:161, hour, 39.94, -5.77, TimeZone=+1) )
		})

Try the REddyProc package in your browser

Any scripts or data that you put into this service are public.

REddyProc documentation built on May 2, 2019, 5:19 p.m.