Title: | Estimating Climate Stability from Climate Model Data |
---|---|
Description: | Climate stability measures are not formalized in the literature and tools for generating stability metrics from existing data are nascent. This package provides tools for calculating climate stability from raster data encapsulating climate change as a series of time slices. The methods follow Owens and Guralnick <doi:10.17161/bi.v14i0.9786> Biodiversity Informatics. |
Authors: | Hannah Owens [aut, cre] |
Maintainer: | Hannah Owens <[email protected]> |
License: | GPL-3 |
Version: | 0.1.4 |
Built: | 2024-11-19 05:27:26 UTC |
Source: | https://github.com/hannahlowens/climatestability |
A function to calculate mean values of a 'SpatRaster' at the absolute value of latitude, at the resolution of the given raster layer.
absLatitudinalMean(rasterForCalculation)
absLatitudinalMean(rasterForCalculation)
rasterForCalculation |
A 'SpatRaster' that contains data for plotting according to latitudinal value |
A vector of mean values for each absolute latitude value.
Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786
latitudinalMean
for calculating mean values of rasters for all latitudinal bands.
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation alm <- absLatitudinalMean(rasterForCalculation = precipStability) plot(alm, main = "Precipitation Stability by Absolute Latitude", ylab = "Relative Stability", type = "l")
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation alm <- absLatitudinalMean(rasterForCalculation = precipStability) plot(alm, main = "Precipitation Stability by Absolute Latitude", ylab = "Relative Stability", type = "l")
A function that reads time-slice rasters of data for a given climate (typically processed data from a climate model run, such as the results of an analysis using PaleoView (Fordham, *et al.* 2017, Ecography)) in a given directory and calculates average deviation per year across time slices.
deviationThroughTime(variableDirectory, timeSlicePeriod, fileExtension = "asc")
deviationThroughTime(variableDirectory, timeSlicePeriod, fileExtension = "asc")
variableDirectory |
A directory containing at least two time slice rasters for a given climate variable. |
timeSlicePeriod |
Either a single number, in years, representing the time period elapsed between temporally-even climate variable raster slices, or a vector corresponding to periods, in years, between temporally-uneven time slices. |
fileExtension |
a character that describes a fileExtension corresponding to one of the suported drivers in
|
Make sure that files in the 'variableDirectory' are read into 'R' in order.
If you are specifying temporally-uneven time slices with 'timeSlicePeriod', make sure that each number corresponds to the number of years elapsed *between* time slices, *in the same order as the files were read into 'R'*. There should be one less number than the number of files, and you must have at least three files in the directory.
See 'precipDeviation.asc' and 'temperatureDeviation.asc' for examples of rasters created using this function. See reference for data source details.
A raster showing the geographic distribution of climate deviation through time for a particular climate variable.
Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786
# Generate sample data td <- tempdir() suppressWarnings(x <- terra::rast(nrows=20, ncols=20, xmin=0, xmax=10, ymin=0, ymax=10, vals = c(10,10,10,10,20))) x2 <- x * 1.01 rastStack <- c(x, x2, x) terra::writeRaster(rastStack, filename = paste0(td, "/raster", 1:terra::nlyr(rastStack), ".tif"), overwrite = TRUE) # Even time slices testResult <- deviationThroughTime(td, timeSlicePeriod = 100, fileExtension = "tif") # Uneven time slices testResult <- deviationThroughTime(variableDirectory = td, timeSlicePeriod = c(25, 100), fileExtension = "tif") # Delete temporary files unlink(td)
# Generate sample data td <- tempdir() suppressWarnings(x <- terra::rast(nrows=20, ncols=20, xmin=0, xmax=10, ymin=0, ymax=10, vals = c(10,10,10,10,20))) x2 <- x * 1.01 rastStack <- c(x, x2, x) terra::writeRaster(rastStack, filename = paste0(td, "/raster", 1:terra::nlyr(rastStack), ".tif"), overwrite = TRUE) # Even time slices testResult <- deviationThroughTime(td, timeSlicePeriod = 100, fileExtension = "tif") # Uneven time slices testResult <- deviationThroughTime(variableDirectory = td, timeSlicePeriod = c(25, 100), fileExtension = "tif") # Delete temporary files unlink(td)
A function to calculate mean values of a raster at every line of latitude, at the resolution of a given raster layer. Put another way, for each row in the raster, it calculates a mean.
latitudinalMean(rasterForCalculation)
latitudinalMean(rasterForCalculation)
rasterForCalculation |
A raster that contains data for plotting according to latitudinal value |
A vector of raster values for each absolute value of latitude.
Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786
absLatitudinalMean
to calculate mean value for each absolute value of latitude.
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation latMean <- latitudinalMean(rasterForCalculation = precipStability) plot(latMean, main = "Precipitation Stability by Latitude", ylab = "Relative Stability", type = "l")
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation latMean <- latitudinalMean(rasterForCalculation = precipStability) plot(latMean, main = "Precipitation Stability by Latitude", ylab = "Relative Stability", type = "l")
A function to rescale a raster from 0 to 1. This is done using the formula (value-min)/(max-min).
rescale0to1(rasterForCalculation)
rescale0to1(rasterForCalculation)
rasterForCalculation |
A 'SpatRaster' that contains data to be rescaled |
A raster that has been rescaled from 0 to 1
Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation relativeClimateStability <- rescale0to1(precipStability)
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- 1/precipDeviation relativeClimateStability <- rescale0to1(precipStability)
A function to calculate stability based on the results of 'deviationThroughTime'.
stabilityCalc(rasterForCalculation)
stabilityCalc(rasterForCalculation)
rasterForCalculation |
A 'SpatRaster' object that contains data from which stability is to be calculated. |
This formula takes the inverse of the raster and rescales it from 0 to 1.This function is necessary in cases where there is no deviation in some cells. If time slices are very close together, it's possible that some cells may have values equal to zero, at which point if you simply divide 1 by the raster and rescale the result, you can end up with a raster full of zeroes.
A raster
Owens, H.L., Guralnick, R., 2019. climateStability: An R package to estimate climate stability from time-slice climatologies. Biodiversity Informatics 14, 8–13. https://doi.org/10.17161/bi.v14i0.9786
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- stabilityCalc(precipDeviation)
precipDeviation <- terra::rast(system.file("extdata/precipDeviation.asc", package = "climateStability")) precipStability <- stabilityCalc(precipDeviation)