Skip to content

Commit

Permalink
Merge pull request #41 from EvolEcolGroup/paleopgem2
Browse files Browse the repository at this point in the history
Paleopgem2
  • Loading branch information
dramanica authored Sep 19, 2023
2 parents 1160c0b + 3f4c6f1 commit 7416aa8
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 60 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# development
* Add Barreto et al 2023 (based on PALEO-PGEM, covering the last 5 M years),
and all the WorldClim data (present, and future projections with multiple models
and emission scenarios).
* Improve `get_ice_mask()`, `get_land_mask()`, and `distance_from_sea()` to work
on series rather than just on slices.
* Speed up `region_*()` functions when subsetting the extent/cropping.

# pastclim 1.2.4
* Updates on how time is handled to stay in sync with changes in `terra`.
Expand Down
55 changes: 49 additions & 6 deletions R/datasets_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ NULL
#' Documentation for the WorldClim datasets
#'
#' WorldClim version 2.1 is a database of high spatial resolution global weather and
#' climate data, covering both the present and future projections.
#' climate data, covering both the present and future projections. If you use this
#' dataset, make sure to cite the original publication:
#'
#' Fick, S.E. and R.J. Hijmans, 2017. WorldClim 2: new 1km spatial resolution
#' climate surfaces for global land areas. International Journal of Climatology 37 (12): 4302-4315.
#' \doi{doi.org/10.1002/joc.5086}
#'
#' **Present-day reconstructions** are based on the mean for the period 1970-2000,
#' and are available at multiple resolutions of
Expand Down Expand Up @@ -116,11 +121,6 @@ NULL
#' are automatically downloaded for each combination of GCM model and SSP, and are selected
#' as usual by defining the time in functions such as [region_slice()].
#'
#' If you use this dataset, make sure to cite the original publication:
#'
#' Fick, S.E. and R.J. Hijmans, 2017. WorldClim 2: new 1km spatial resolution
#' climate surfaces for global land areas. International Journal of Climatology 37 (12): 4302-4315.
#' \doi{doi.org/10.1002/joc.5086}
#'
#' @name WorldClim_2.1
NULL
Expand All @@ -140,3 +140,46 @@ NULL
NULL
#> NULL

#' Documentation for the Barreto et al 2023 dataset
#'
#' Spatio-temporal series of monthly temperature and precipitation and 17
#' derived bioclimatic variables covering the last 5 Ma (Pliocene–Pleistocene),
#' at intervals of 1,000 years, and a spatial resolution of 1
#' degrees (see Barreto et al., 2023 for details).
#'
#' PALEO-PGEM-Series is downscaled to 1° × 1° spatial resolution from the
#' outputs of the PALEO-PGEM emulator (Holden et al., 2019), which emulates
#' reasonable and extensively validated global estimates of monthly temperature
#' and precipitation for the Plio-Pleistocene every 1 kyr at a spatial
#' resolution of ~5° × 5° (Holden et al., 2016, 2019).
#'
#' PALEO-PGEM-Series includes the mean and the standard deviation (i.e.,
#' standard error) of the emulated climate over 10 stochastic GCM emulations
#' to accommodate aspects of model uncertainty. This allows users to estimate
#' the robustness of their results in the face of the stochastic aspects of
#' the emulations. For more details, see Section 2.4 in Barreto et al. (2023).
#'
#' Note that this is a very large dataset, with 5001 time slices. It takes
#' approximately 1 minute to set up each variable when creating a region_slice or
#' region_series. However, once the object has been created, other operations tend
#' to be much faster (especially if you subset the dataset to a small number
#' of time steps of interest).
#'
#' If you use this dataset, make sure to cite the original publications:
#'
#' Barreto, E., Holden, P. B., Edwards, N. R., & Rangel, T. F. (2023).
#' PALEO-PGEM-Series: A spatial time series of the global climate over the
#' last 5 million years (Plio-Pleistocene). Global Ecology and
#' Biogeography, 00, 1– 12.
#' \doi{doi.org/10.1111/geb.13683}
#'
#' Holden, P. B., Edwards, N. R., Rangel, T. F., Pereira, E. B., Tran, G. T.,
#' and Wilkinson, R. D. (2019): PALEO-PGEM v1.0: a statistical emulator of
#' Pliocene–Pleistocene climate, Geosci. Model Dev., 12, 5137–5155,
#' \doi{doi.org/10.5194/gmd-12-5137-2019}.
#'
#' @name Barreto2023
NULL
#> NULL


23 changes: 15 additions & 8 deletions R/download_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ download_dataset <- function(dataset, bio_variables = NULL, annual = TRUE,
# check the dataset exists
available_datasets <- unique(getOption("pastclim.dataset_list")$dataset)
if (!dataset %in% available_datasets) {
cat("'dataset' must be one of ")
get_available_datasets()
stop(
"'dataset' must be one of ",
paste(available_datasets, collapse = ", ")
"Invalid 'dataset', for a comprehensive list of all possible combinations, use `list_available_datasets()`"
)
}

Expand Down Expand Up @@ -55,13 +56,19 @@ download_dataset <- function(dataset, bio_variables = NULL, annual = TRUE,
)
}

if (dataset %in% c("Krapp2021", "Beyer2020", "Example")){
# add biome to list of variables (we need it to generate the landmask)
if (!"biome" %in% bio_variables) {
bio_variables <- c(bio_variables, "biome")
}
}
# if (dataset %in% c("Krapp2021", "Beyer2020", "Example")){
# # add biome to list of variables (we need it to generate the landmask)
# if (!"biome" %in% bio_variables) {
# bio_variables <- c(bio_variables, "biome")
# }
# }

# add biome to list of variables (we need it to generate the landmask)
if (all((!"biome" %in% bio_variables),("biome"%in%available_variables))) {
bio_variables <- c(bio_variables, "biome")
}


# special case for the example dataset
# as we have a copy on the package
if (dataset == "Example"){
Expand Down
4 changes: 3 additions & 1 deletion R/region_series.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ region_series <-
time_bp <- check_time_vars(time_bp = time_bp, time_ce = time_ce)

check_dataset_path(dataset = dataset, path_to_nc = path_to_nc)

if (dataset=="Barreto2023"){
message("This is a large dataset, it might take a while...")
}

if (!is.null(ext)){
if(!any(inherits(ext,"SpatExtent"),
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ dev](https://img.shields.io/github/checks-status/EvolEcolGroup/pastclim/dev?labe

This `R` library is designed to provide an easy way to extract and
manipulate palaeoclimate reconstructions for ecological and
anthropological analyses.
anthropological analyses. It is also able to handle timeseries of future
reconstructions.

The functionalities of `pastclim` are described in [Leonardi et al.
(2023)](https://doi.org/10.1111/ecog.06481). Please cite it if you use
Expand Down Expand Up @@ -54,10 +55,12 @@ updated for the `dev` branch of `pastclim` (on the top left of the dev
website, the version number is in red and in the format x.x.x.9xxx,
indicating it is a development version).

Pastclim currently includes data from Beyer et al 2020, a reconstruction
of climate based on the HadCM3 model for the last 120k years, and Krapp
et al 2021, which covers the last 800k years. The reconstructions are
bias-corrected and downscaled to 0.5 degree. More details on these
Pastclim currently includes data from Beyer et al 2020 (a reconstruction
of climate based on the HadCM3 model for the last 120k years), Krapp
et al 2021 (which covers the last 800k years with a statistical emulator of HadCM3),
Barreto et al 2023 (covering the last 5M years using hte PALEO-PGEM emulator),
and the WorldClim data (present, and future projections with a number of models and
emission scenarios). More details on each of these
datasets can be found
[here](https://evolecolgroup.github.io/pastclim/articles/a1_available_datasets.html).
There are also instructions on how to build and use [custom
Expand Down
1 change: 1 addition & 0 deletions data-raw/data_files/.~lock.dataset_list_included.csv#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,am315,zoopc805.biosci.cam.ac.uk,18.09.2023 15:12,file:///home/am315/.config/libreoffice/4;
Loading

0 comments on commit 7416aa8

Please sign in to comment.