Skip to content

Commit 6431cc7

Browse files
authored
Merge pull request #61 from MagicForrest/dev
*** Release v0.9.0 ***
2 parents 72674cb + 964abad commit 6431cc7

File tree

153 files changed

+6990
-3280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+6990
-3280
lines changed

DESCRIPTION

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
Package: DGVMTools
22
Type: Package
3-
Version: 0.8.2
3+
Version: 0.9.0
44
Title: DGVM Processing, Analysis and Plotting Tools
5-
Date: 2019-02-27
5+
Date: 2019-11-01
66
Authors@R: c(person("Matthew", "Forrest", role=c("aut", "cre"), email="[email protected]"),
77
person("Simon", "Scheiter", role=c("aut"), email="[email protected]"),
8-
person("Joerg", "Steinkamp", role=c("aut"), email="[email protected]"))
9-
Author: Matthew Forrest [aut, cre], Simon Scheiter [aut], Joerg Steinkamp [aut]
8+
person("Joerg", "Steinkamp", role=c("aut"), email="[email protected]"),
9+
person("Glenn", "Moncrieff", role=c("aut"), email="[email protected]"))
10+
Author: Matthew Forrest [aut, cre], Simon Scheiter [aut], Joerg Steinkamp [aut], Glenn Moncrieff [aut]
1011
Maintainer: Matthew Forrest <[email protected]>
1112
Description: Read, process, benchmark, analyse and plot output data produced by dynamic global vegetation
12-
models (DGVMs) LPJ-GUESS(-SPITFIRE) and aDGVM2 and potentially soon others, for use in R.
13+
models (DGVMs): LPJ-GUESS(-SPITFIRE), aDGVM and aDGVM2 (and potentially soon others), for use in R.
1314
Also reads many standard datasets as processed by companion 'DGVMData' package.
1415
FireMIP model output is supported with an additional package (FireMIPTools).
1516
Depends:
@@ -21,10 +22,10 @@ Imports:
2122
sp,
2223
raster,
2324
compiler,
25+
fields,
2426
maps,
2527
maptools,
2628
mapdata,
27-
fields,
2829
RColorBrewer,
2930
reshape2,
3031
viridis,
@@ -40,7 +41,7 @@ License: GPL | file LICENSE
4041
URL: https://www.bik-f.de
4142
BugReports: https://github.com/MagicForrest/DGVMTools/issues
4243
NeedsCompilation: no
43-
RoxygenNote: 6.1.1
44+
RoxygenNote: 7.1.0
4445
VignetteBuilder: knitr
4546
Encoding: UTF-8
4647
Collate:
@@ -49,32 +50,35 @@ Collate:
4950
'Format-DGVMData.R'
5051
'Format-GUESS.R'
5152
'Format-aDGVM.R'
53+
'Format-aDGVM2.R'
5254
'Standard-Quantities.R'
5355
'addArea.R'
5456
'addStandardSpatialAttributes.R'
57+
'addTo.R'
5558
'aggregateSpatial.R'
5659
'aggregateSubannual.R'
5760
'aggregateYears.R'
5861
'availableQuantities.R'
5962
'averageFields.R'
6063
'benchmarking.R'
61-
'biome-schemes.R'
6264
'byIDfromList.R'
6365
'calcNewField.R'
66+
'classification-schemes.R'
6467
'commonSTAInfo.R'
6568
'compareLayers.R'
6669
'copyLayers.R'
6770
'crop-methods.R'
71+
'defineLayer.R'
72+
'defineQuantity.R'
6873
'defineSource.R'
6974
'determinePFTs.R'
7075
'export-methods.R'
7176
'extent-methods.R'
72-
'getBiomes.R'
7377
'getDimInfo.R'
7478
'getField.R'
79+
'getScheme.R'
7580
'is-methods.R'
7681
'layerOp.R'
77-
'listPFTs.R'
7882
'lookupQuantity.R'
7983
'makeFieldID.R'
8084
'makePlotTitle.R'
@@ -89,6 +93,7 @@ Collate:
8993
'plotSpatialComparison.R'
9094
'plotSubannual.R'
9195
'plotTemporal.R'
96+
'plotTemporalComparison.R'
9297
'plotting-framework-functions.R'
9398
'renameLayers.R'
9499
'selectDays.R'
@@ -100,5 +105,6 @@ Collate:
100105
'show-methods.R'
101106
'small-utility-functions.R'
102107
'summary-methods.R'
108+
'whichLayers.R'
103109
'writeField-methods.R'
104110
'writeNetCDF-methods.R'

NAMESPACE

+13-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ export(SimpleHeightAdgvm2BiomeScheme)
2020
export(Smith2014BiomeScheme)
2121
export(Standard.quantities)
2222
export(aDGVM)
23+
export(aDGVM2)
24+
export(aDGVMBiomeScheme)
2325
export(addArea)
2426
export(addStandardSpatialAttributes)
27+
export(addTo)
2528
export(aggregateSpatial)
2629
export(aggregateSubannual)
2730
export(aggregateYears)
@@ -38,33 +41,33 @@ export(commonSTAInfo)
3841
export(compareLayers)
3942
export(continuousComparison)
4043
export(copyLayers)
44+
export(defineLayer)
45+
export(defineQuantity)
4146
export(defineSource)
4247
export(determinePFTs)
4348
export(difference.palette)
4449
export(extract.seq)
4550
export(fire.palette)
46-
export(getBiomes)
4751
export(getDimInfo)
4852
export(getField)
49-
export(getStandardQuantity_LPJ)
53+
export(getScheme)
5054
export(gridarea1d)
5155
export(gridarea2d)
5256
export(is.Comparison)
5357
export(is.Field)
5458
export(is.Format)
55-
export(is.PFT)
59+
export(is.Layer)
5660
export(is.Quantity)
5761
export(is.STAInfo)
5862
export(is.Source)
5963
export(is.Statistics)
6064
export(is.leapyear)
6165
export(layerOp)
62-
export(listPFTs)
6366
export(lookupQuantity)
6467
export(makeFieldID)
6568
export(makePlotTitle)
6669
export(makeSPDFfromDT)
67-
export(matchPFTCols)
70+
export(matchLayerCols)
6871
export(periods)
6972
export(plotResidualsHisto)
7073
export(plotScatter)
@@ -74,6 +77,7 @@ export(plotSpatial)
7477
export(plotSpatialComparison)
7578
export(plotSubannual)
7679
export(plotTemporal)
80+
export(plotTemporalComparison)
7781
export(promoteToRaster)
7882
export(proportionsComparison)
7983
export(renameLayers)
@@ -91,16 +95,17 @@ export(selectMonths)
9195
export(selectSeasons)
9296
export(selectYears)
9397
export(setKeyDGVM)
94-
export(supported.biome.schemes)
98+
export(supported.classification.schemes)
9599
export(veg.palette)
96-
exportClasses(BiomeScheme)
100+
export(whichLayers)
97101
exportClasses(Comparison)
98102
exportClasses(Field)
99103
exportClasses(Format)
100-
exportClasses(PFT)
104+
exportClasses(Layer)
101105
exportClasses(Period)
102106
exportClasses(Quantity)
103107
exportClasses(STAInfo)
108+
exportClasses(Scheme)
104109
exportClasses(Source)
105110
exportMethods(as.Raster)
106111
exportMethods(as.array)

NEWS.md

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
# DGVMTools v0.9.0 (2020-08-04)
2+
3+
This is a feature release! Main features are aDGVM1 support, the inclusion of plotTemporalComparison() and the change from PFT objects to the more flexible Layer objects. However there have been many other bug-fixes and tweaks.
4+
5+
## Main features
6+
7+
* aDGVM1 now supported! Thanks Glenn Moncrieff! The original aDGVM Format object, which referred to aDGVM2, has been renamed to ... drum roll please... aDGVM2.
8+
* Biome schemes have been included specifically for aDGVM1.
9+
* plotTemporalComparison() has been added.
10+
* The PFT object has been replaced with a Layer object which is designed to be much more flexible. Where PFT objects had fixed slots to represent their properties, Layer objects feature an R list of properties, which can be user-defined and customised for each supported model. PFTs are now simply defined as Layer objects, but Layers can also be other things (C pools, soils depths, whatever).
11+
* Sources now have slots "predefined.layers" to contain, yes you got it, their pre-defined Layers.
12+
* Facetting has been reworked for plotSpatial() and is now consistent with the other plotXXX() functions. Note that an automatic calls to facet_grid() are no longer done in plotSpatial(), but of course they can be done afterwards by the user. Number of rows or columns of facets in a spatial plot should be specified by suppling arguments "nrow" and "ncol" to plotSpatial() (or plotSpatialComparison()). These are actually completely equivalent to the standard arguments to facet_wrap() in ggplot2.
13+
14+
## Minor features/improvements
15+
16+
* Can now use a map object for selecting gridcells with selectGridcells().
17+
* Functions defineLayer() and defineQuantity() added.
18+
* Added the addTo() function to add Layer or Quantity objects to Format or Source objects. This is simply a user-friendly convience so that users don't need to explicitly access the slots in the S4 class structure, and is designed to work in conjunction with the nee defineLayer() and defineQuantity() function above.
19+
* Added the legend.title argument to plotSpatial().
20+
* Coefficient of variation is now a possible method when aggregating with aggregateSpatial(), aggregateSubannual() or aggregateYears().
21+
* Improved Field to Raster conversion. It now supports multiple Layers, months and years.
22+
23+
## Breaking changes
24+
25+
* Using a string when specifying the format argument to defineSource() has been disabled. Please specify the Format object, i.e. Guess instead of "GUESS" or "LPJ-GUESS".
26+
* BiomeScheme renamed to Scheme, getBiomes() renamed to getScheme().
27+
* Functions copyLayers() and compareLayers() now use a "tolerance" argument instead of "dec.places" which is more intuitive, efficient and reliable.
28+
* Function determinePFTs() has been removed as it was not particularly useful and PFT objects have now been generalised to Layer objects.
29+
* plotScatter() argument names changed to 'x' and 'y' instead of 'field1' and 'field2'
30+
* First argument to plotScatterComparision() and plotResidualComparison() is now called 'comparisons' instead of 'input.CLayers'.
31+
32+
## Under the hood
33+
34+
* In Format-GUESS, crop and aggregating is now done earlier to save memory.
35+
* Precision of Lon and Lat handled better in addArea().
36+
* plotSpatial() now correctly identifies different year periods and puts them in different panels (thanks to Peter Antoni for reporting).
37+
* Removed correct.map.offset internal function because it now seems unnecesary and just caused problems.
38+
39+
40+
141
# DGVMTools v0.8.2 (2019-10-04)
242

343
This is a bug-fix and "feature tweaking" release - i.e. there is no new major functionality but enhanced useability and other tweaks.

R/Format-DGVMData.R

+9-26
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ getField_DGVMData <- function(source,
5353

5454

5555
# Make the filename (if necessary) and check for the file, gunzip if necessary, fail if not present
56-
if(!is.null(file.name)) file.path(source@dir, file.name)
56+
if(!is.null(file.name)) file.name.nc <- file.path(source@dir, file.name)
5757
else file.name.nc <- file.path(source@dir, paste(quant@id, "nc", sep = "."))
5858
file.name.nc.gz <- paste(file.name.nc, "gz", sep = ".")
5959
zipped <- FALSE
@@ -403,7 +403,7 @@ getField_DGVMData <- function(source,
403403
dimnames(this.slice) <- dimension.names
404404

405405
# prepare data.table from the slice (array)
406-
this.slice.dt <- as.data.table(melt(this.slice))
406+
this.slice.dt <- as.data.table(reshape2::melt(this.slice))
407407
rm(this.slice)
408408
gc()
409409
this.slice.dt <- stats::na.omit(this.slice.dt)
@@ -536,10 +536,11 @@ getField_DGVMData <- function(source,
536536
}
537537

538538

539-
540-
# if london.centre is requested, shift to -180 to +180
541-
if(length(all.lons) > 0) {
542-
if(source@london.centre && max(all.lons) >= 180){ dt[, Lon := vapply(dt[,Lon], 1, FUN = LondonCentre)] }
539+
# if london.centre is requested, make sure all longitudes greater than 180 are shifted to negative
540+
if(source@london.centre){
541+
if(max(all.lons) > 180) {
542+
dt[, Lon := LondonCentre(Lon)]
543+
}
543544
}
544545

545546
# set keys
@@ -611,21 +612,6 @@ availableQuantities_DGVMData <- function(source, names){
611612
}
612613

613614

614-
#' Detemine PFTs present in an DGVMData source
615-
#'
616-
#' @param x A Source objects describing a DGVMData source
617-
#' @param variables Some variable to look for to detremine the PFTs present in the run. Not the function automatically searches:
618-
#' "lai", "cmass", "dens" and "fpc". If they are not in your output you should define another per-PFT variable here. Currently ignored.
619-
#' @author Matthew Forrest \email{matthew.forrest@@senckenberg.de}
620-
#' @keywords internal
621-
622-
determinePFTs_DGVMData <- function(x, variables) {
623-
624-
warning("Datasets don't normally have PFTs (or they are not likely to be defined consistently) so I am not looking for them. Instead I am returning the source@[email protected] argument directly (in case you defined some yourself, which would be the way to go in this case)")
625-
return(x@format@pft.set)
626-
627-
}
628-
629615

630616
########################################################
631617
########### DGVMData QUANTITIES ########################
@@ -756,17 +742,14 @@ DGVMData <- new("Format",
756742
# UNIQUE ID
757743
id = "DGVMData",
758744

759-
# FUNCTION TO LIST ALL PFTS APPEARING IN A RUN
760-
determinePFTs = determinePFTs_DGVMData,
761-
762745
# FUNCTION TO LIST ALL QUANTIES AVAILABLE IN A RUN
763746
availableQuantities = availableQuantities_DGVMData,
764747

765748
# FUNCTION TO READ A FIELD
766749
getField = getField_DGVMData,
767750

768-
# DEFAULT GLOBAL PFTS
769-
default.pfts = list(),
751+
# DEFAULT GLOBAL LAYERS
752+
predefined.layers = list(),
770753

771754
# QUANTITIES THAT CAN BE PULLED DIRECTLY FROM LPJ-GUESS RUNS
772755
quantities = DGVMData.quantities

0 commit comments

Comments
 (0)