Skip to content

Commit

Permalink
Add tests for correctness of land/ocean average temperatures.
Browse files Browse the repository at this point in the history
Increment version number to 2.2.1
  • Loading branch information
rplzzz committed Apr 23, 2019
1 parent a0dba86 commit 2819a2b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hector
Title: The Hector Simple Climate Model
Version: 2.2.0
Version: 2.2.1
Authors@R: c(person("Robert", "Link", email = "[email protected]", role = c("aut", "cre")),
person("Corinne", "Hartin", email = "[email protected]", role = "aut"),
person("Ben", "Bond-Lamberty", email = "[email protected]", role = "aut"),
Expand All @@ -21,6 +21,8 @@ Suggests:
knitr,
rmarkdown,
ggplot2,
tidyr (>= 0.7),
dplyr (>= 0.7),
hectortools
Remotes:
jgcri/hectortools
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Hector 2.2.1
============
* Report global averages for land temperature, ocean air
temperature, and ocean surface temperature.
* Fix bug that prevented CH4 emissions from being read.

Hector 2.2.0
============
* Add a new parameter: VOLCANIC_SCALE. This parameter adjusts the
Expand Down
2 changes: 1 addition & 1 deletion inst/include/h_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* \brief The model version number to be included in logs and outputs.
* \note This must be updated manually when the model version changes.
*/
#define MODEL_VERSION "2.2.0"
#define MODEL_VERSION "2.2.1"

#define OUTPUT_DIRECTORY "output/"

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_scenarios.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ context('Verify correctness of hector scenarios')
inputdir <- system.file('input', package='hector')
sampledir <- system.file('output', package='hector')
testvars <- c(ATMOSPHERIC_CO2(), RF_TOTAL(), GLOBAL_TEMP())
tempvars <- c(GLOBAL_TEMP(), OCEAN_AIR_TEMP(), LAND_TEMP())
fland <- 0.29 # Global land area fraction
dates <- 2000:2300


Expand All @@ -14,6 +16,7 @@ test_that('RCP scenarios are correct', {
expect_true(inherits(hc, 'hcore'))
run(hc)
outdata <- fetchvars(hc, dates, testvars, scen)
tempdata <- fetchvars(hc, dates, tempvars, scen)

## Get the comparison data
sampleoutfile <- sprintf('sample_outputstream_rcp%s.csv', rcp)
Expand All @@ -29,6 +32,11 @@ test_that('RCP scenarios are correct', {
outdata$value <- signif(outdata$value, 4)

expect_equivalent(outdata, sampledata, info=sprintf("Output doesn't match for scenario rcp%s", rcp))

td <- dplyr::select(tempdata, year, variable, value) %>% tidyr::spread(variable, value)
tgcomp <- fland*td$Tgav_land + (1.0-fland)*td$Tgav_ocean_air
expect_equal(tgcomp, td$Tgav, info=sprintf("Global temperature doesn't add up for scenario rcp%s", rcp))

hc <- shutdown(hc)
}
})
Expand Down

1 comment on commit 2819a2b

@bpbond
Copy link
Member

@bpbond bpbond commented on 2819a2b Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good idea.

Please sign in to comment.