From 5d11a9a032bc82af534cfa89fc55475ecb8f9974 Mon Sep 17 00:00:00 2001 From: James Hiebert Date: Thu, 1 Feb 2018 13:18:45 -0800 Subject: [PATCH] Release of v1.0.4 --- CHANGELOG | 3 +++ DESCRIPTION | 6 +++--- man/ClimDown.Rd | 13 ++++++------ man/bccaq.netcdf.wrapper.Rd | 13 +++++++++++- man/ca.netcdf.wrapper.Rd | 10 ++++++++- man/ci.netcdf.wrapper.Rd | 9 +++++++- man/options.Rd | 1 - man/parallelization.Rd | 1 - man/qdm.netcdf.wrapper.Rd | 16 +++++++++++++- man/rerank.netcdf.wrapper.Rd | 41 +++++++++++++++++++++++++++++++++--- 10 files changed, 95 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a5784fe..d77243c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +## [1.0.4] - 2018-02-01 +### Addresses comments from the Journal of Open Source Software review + ## [1.0.3] - 2017-06-07 ### Adds paper for The Journal of Open Source Software diff --git a/DESCRIPTION b/DESCRIPTION index 12b3db8..1f0d036 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ClimDown -Version: 1.0.3 -Date: 2017-06-07 +Version: 1.0.4 +Date: 2018-02-01 Title: Climate Downscaling Library for Daily Climate Model Output Authors@R: c(person("Alex Cannon", role = "aut", email = "acannon@uvic.ca"), person("James Hiebert", role = c("aut", "cre"), email = "hiebert@uvic.ca"), @@ -29,4 +29,4 @@ License: GPL-3 | file LICENSE URL: https://www.r-project.org LazyData: yes BugReports: https://github.com/pacificclimate/ClimDown -RoxygenNote: 5.0.1 +RoxygenNote: 6.0.1 diff --git a/man/ClimDown.Rd b/man/ClimDown.Rd index e35b294..b6aad94 100644 --- a/man/ClimDown.Rd +++ b/man/ClimDown.Rd @@ -4,6 +4,7 @@ \name{ClimDown} \alias{ClimDown} \alias{ClimDown-package} +\alias{ClimDown-package} \title{ClimDown: PCIC's daily Climate Downscaling library} \description{ This package includes PCIC's routines and techniques for @@ -12,11 +13,12 @@ spatial resolution. } \details{ At present, the package only exports high-level wrapper function -that perform each of three downscaling steps: CI, CA, and QDM, as -well as one wrapper that runs the entire pipeline: BCCAQ. In -general, each wrapper simply takes four arguments: GCM file, -gridded observation file, output file, and variable name. However, -see the specific function documentation for specifics. +that perform each of three downscaling steps: CI, CA, QDM, and +rerank as well as one wrapper that runs the entire pipeline: +BCCAQ. In general, each wrapper simply takes four arguments: GCM +file, gridded observation file, output file, and variable +name. However, see the specific function documentation for +specifics. The package also provides five wrapper scripts that allow the user to run each step from the command line (plus the whole pipeline) @@ -27,4 +29,3 @@ Werner, A. T., & Cannon, A. J. (2016). Hydrologic extremes - an intercomparison } \keyword{climate} \keyword{downscaling} - diff --git a/man/bccaq.netcdf.wrapper.Rd b/man/bccaq.netcdf.wrapper.Rd index bcd30d6..78a28ad 100644 --- a/man/bccaq.netcdf.wrapper.Rd +++ b/man/bccaq.netcdf.wrapper.Rd @@ -40,8 +40,19 @@ grid-scale spatial variability inherited from CI/QDM, thereby resulting in a more accurate representation of event-scale spatial gradients; this also prevents the downscaled outputs from drifting too far from the climate model's long-term trend. +} +\examples{ +\dontrun{ +out.nc <- tempfile(fileext='.nc') +options( + calibration.end=as.POSIXct('1972-12-31', tz='GMT'), + cend=as.POSIXct('1972-12-31', tz='GMT') +) +ClimDown::bccaq.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc', out.nc, 'tasmax') +unlink(out.nc) +} + } \references{ Werner, A. T., & Cannon, A. J. (2016). Hydrologic extremes - an intercomparison of multiple gridded statistical downscaling methods. Hydrology and Earth System Sciences, 20(4), 1483-1508. doi: 10.5194/hess-20-1483-2016 } - diff --git a/man/ca.netcdf.wrapper.Rd b/man/ca.netcdf.wrapper.Rd index 71ae860..9c43b88 100644 --- a/man/ca.netcdf.wrapper.Rd +++ b/man/ca.netcdf.wrapper.Rd @@ -27,8 +27,16 @@ timestep in the GCM and searching for the top 30 closest timesteps each of the 30 closest "analogue" timesteps, CA records the integer number of the timestep and a weight for each of the analogues. These are all saved in output.file. +} +\examples{ +\dontrun{ +options( + calibration.end=as.POSIXct('1972-12-31', tz='GMT') +) +analogues <- ClimDown::ca.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc') +} + } \references{ Maurer, E. P., Hidalgo, H. G., Das, T., Dettinger, M. D., & Cayan, D. R. (2010). The utility of daily large-scale climate data in the assessment of climate change impacts on daily streamflow in California. Hydrology and Earth System Sciences, 14(6), 1125-1138. } - diff --git a/man/ci.netcdf.wrapper.Rd b/man/ci.netcdf.wrapper.Rd index fade6b3..294d200 100644 --- a/man/ci.netcdf.wrapper.Rd +++ b/man/ci.netcdf.wrapper.Rd @@ -25,10 +25,17 @@ gridded observations are then grouped into months and a climatology is calculated for each month. Finally the observed climatology is added to the GCM-based climate imprint and the final result is saved to output.file. +} +\examples{ +\dontrun{ +ci.nc <- tempfile(fileext='.nc') +ClimDown::ci.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc', ci.nc) +unlink(ci.nc) +} + } \references{ Hunter, R. D., & Meentemeyer, R. K. (2005). Climatologically aided mapping of daily precipitation and temperature. Journal of Applied Meteorology, 44(10), 1501-1510. Ahmed, K. F., Wang, G., Silander, J., Wilson, A. M., Allen, J. M., Horton, R., & Anyah, R. (2013). Statistical downscaling and bias correction of climate model outputs for climate change impact assessment in the US northeast. Global and Planetary Change, 100, 320-332. } - diff --git a/man/options.Rd b/man/options.Rd index 8bca1d3..9c9d37d 100644 --- a/man/options.Rd +++ b/man/options.Rd @@ -82,4 +82,3 @@ pre-set. Options must be configured using R's \code{\link[base]{options}} function. They can be set by using an .Rprofile file, or on the R session prompt prior to executing any \pkg{ClimDown} wrapper functions. } - diff --git a/man/parallelization.Rd b/man/parallelization.Rd index cf761c2..aeed054 100644 --- a/man/parallelization.Rd +++ b/man/parallelization.Rd @@ -29,4 +29,3 @@ stopImplicitCluster()} \seealso{ \pkg{doParallel} and \pkg{doMPI} } - diff --git a/man/qdm.netcdf.wrapper.Rd b/man/qdm.netcdf.wrapper.Rd index 153163c..cd7247a 100644 --- a/man/qdm.netcdf.wrapper.Rd +++ b/man/qdm.netcdf.wrapper.Rd @@ -22,8 +22,22 @@ inputted high-res gridded observations. It uses the gridded observations plus the GCM-based output of CI as input to the algorithm and then performs a quantile perturbation/quantile mapping bias correction. The output is written out to out.file. +} +\examples{ +\dontrun{ +ci.file <<- tempfile(fileext='.nc') +ClimDown::ci.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc', ci.file, 'tasmax') +out.nc <- tempfile(fileext='.nc') +options( + calibration.end=as.POSIXct('1972-12-31', tz='GMT'), + cend=as.POSIXct('1972-12-31', tz='GMT') +) +ClimDown::qdm.netcdf.wrapper('./tiny_obs.nc', ci.file, out.nc, 'tasmax') +unlink(ci.file) +unlink(out.nc) +} + } \references{ Cannon, A. J., Sobie, S. R., & Murdock, T. Q. (2015). Bias Correction of GCM Precipitation by Quantile Mapping: How Well Do Methods Preserve Changes in Quantiles and Extremes?. Journal of Climate, 28(17), 6938-6959. doi: 10.1175/JCLI-D-14-00754.1 } - diff --git a/man/rerank.netcdf.wrapper.Rd b/man/rerank.netcdf.wrapper.Rd index bdcf080..af73e5d 100644 --- a/man/rerank.netcdf.wrapper.Rd +++ b/man/rerank.netcdf.wrapper.Rd @@ -12,18 +12,53 @@ rerank.netcdf.wrapper(qdm.file, obs.file, analogues, out.file, \item{obs.file}{Filename of high-res gridded historical observations} -\item{analogues}{Temporal analogues... describe this more} +\item{analogues}{Temporal analogues. This is a list of two arrays: +the index values and the fractional weights. Each array is the +length of the number of timesteps by k (typically 30).} \item{out.file}{The file to create (or overwrite) with the final NetCDF output} \item{varname}{Name of the NetCDF variable to downscale (e.g. 'tasmax')} } \description{ -All files (save for the analogues_file) should have the same spatial domain. +Quantile Reranking is the final, critical step in the + BCCAQ pipeline. Its purpose is this: since Climate Analogues + (CA) gets its high resolution information by using a linear + combination of historical daily time series for the domain as a + whole, it ends up reintroducing some bias. This is because the + quantile mapping bias correction step was performed only at + course resolution (of the GCM). Quantile Reranking fixes this + by re-applying a simple quantile mapping bias correction at + each grid box. The advantage of doing this as a final step is + that the downscaling method retains the primary advantage of + BCCA: high spatial consistency (e.g. when a storm or a heat + wave hits a specific area, it probably also hits neighboring + areas, etc.). +} +\details{ +All input files (save for the analogues_file) should have + the same spatial domain. +} +\examples{ +\dontrun{ +options( + calibration.end=as.POSIXct('1972-12-31', tz='GMT') +) +ci.file <- tempfile(fileext='.nc') +ClimDown::ci.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc', ci.file, 'tasmax') +qdm.file <<- tempfile(fileext='.nc') +ClimDown::qdm.netcdf.wrapper('./tiny_obs.nc', ci.file, qdm.file, 'tasmax') +unlink(ci.file) +analogues <<- ClimDown::ca.netcdf.wrapper('./tiny_gcm.nc', './tiny_obs.nc') +out.file <- tempfile(fileext='.nc') +ClimDown::rerank.netcdf.wrapper(qdm.file, './tiny_obs.nc', analogues, out.file, varname='tasmax') +unlink(qdm.file) +unlink(out.file) +} + } \references{ Schefzik, R., Thorarinsdottir, T. L., & Gneiting, T. (2013). Uncertainty quantification in complex simulation models using ensemble copula coupling. Statistical Science, 28(4), 616-640. Wilks, D. S. (2015). Multivariate ensemble Model Output Statistics using empirical copulas. Quarterly Journal of the Royal Meteorological Society, 141(688), 945-952. } -