Skip to content

Commit

Permalink
New onAttach functionality added
Browse files Browse the repository at this point in the history
Automatic version check and startup messages
Other minor documentation changes
  • Loading branch information
jbedia committed Jul 15, 2014
1 parent 2ab84e1 commit ba1fefc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Package: downscaleR
Depends:
downscaleR.java,
utils,
RCurl,
rJava,
abind,
fields,
R(>= 3.0.0)
Type: Package
Title: R package for climate data analysis and downscaling
Version: 0.0-0
Date: 11-Jul-2014
Version: 0.1-0
Date: 15-Jul-2014
Author: Santander Meteorology Group <http://www.meteo.unican.es>
Maintainer: Joaquin Bedia <[email protected]>
BugReports: https://github.com/SantanderMetGroup/downscaleR/issues
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export(timeBounds)
export(toDD)
import(abind)
import(rJava)
importFrom(RCurl,getURL)
importFrom(downscaleR.java,javaCalendarDate2rPOSIXlt)
importFrom(downscaleR.java,javaString2rChar)
importFrom(fields,image.plot)
importFrom(fields,interp.surface.grid)
importFrom(fields,world)
importFrom(utils,packageDescription)
7 changes: 5 additions & 2 deletions R/interpGridData.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#' @importFrom fields interp.surface.grid
#'
#'
#' @param gridData An object coming from \code{\link{loadGridData}} or the \code{ecomsUDG.Raccess} package function
#' \code{\link[ecomsUDG.Raccess]{loadECOMS}}.
#' @param gridData A grid data object coming from \code{\link{loadGridData}} or the \pkg{ecomsUDG.Raccess}
#' package function \code{\link[ecomsUDG.Raccess]{loadECOMS}}.
#' @param new.grid.x Definition of the x coordinates of the grid to interpolate.
#' This is a vector of length three with components \emph{from}, \emph{to} and \emph{by},
#' in this order, similar as the arguments passed to the \code{\link[base]{seq}} function, giving the
Expand All @@ -26,8 +26,11 @@
#' The output has special attributes in the \code{xyCoords} element that indicate that the object
#' has been interpolated. These attributes are \code{interpolation}, which indicates the method used and
#' \code{resX} and \code{resY}, for the grid-cell resolutions in the X and Y axes respectively.
#' It is also possible to pass the interpolator the grid of a previously existing grid dataset using the
#' \code{\link{getGrid}} method.
#' @note To avoid unnecessary NA values, the function will not extrapolate using a new grid outside the
#' current extent of the dataset, returning an error message.
#' @family loading.grid
#' @author J. Bedia \email{joaquin.bedia@@gmail.com}
#' @export
#' @examples \dontrun{
Expand Down
24 changes: 24 additions & 0 deletions R/onAttach.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' @importFrom utils packageDescription
#' @importFrom RCurl getURL

.onAttach <- function(...) {
pkgname <- "downscaleR"
lib <- system.file(package = pkgname)
ver <- packageDescription(pkgname)$Version
builddate <- packageDescription(pkgname)$Date
mess <- paste(pkgname, " version ", ver, " (", builddate,") is loaded", sep = "")
packageStartupMessage(mess)
url <- "https://raw.githubusercontent.com/SantanderMetGroup/downscaleR/stable/DESCRIPTION"
a <- getURL(url)
b <- readLines(textConnection(a))
latest.ver <- package_version(gsub("Version: ", "", b[grep("Version", b)]))
if (ver < latest.ver) {
ver.mess1 <- paste("WARNING: Your current version of ", pkgname, " (v", ver, ") is not up-to-date", sep = "")
ver.mess <- paste("Get the latest stable version (", latest.ver, ") using <devtools::install_github('SantanderMetGroup/downscaleR@stable'>)", sep = "")
ver.mess
packageStartupMessage(ver.mess1)
packageStartupMessage(ver.mess)
}
}
# End

8 changes: 4 additions & 4 deletions man/interpGridData.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interpGridData(gridData, new.grid.x = NULL, new.grid.y = NULL,
method = "bilinear")
}
\arguments{
\item{gridData}{A grid data object coming from \code{\link{loadGridData}} or the \code{ecomsUDG.Raccess}
package function \code{\link[ecomsUDG.Raccess]{loadECOMS}}.}
\item{gridData}{A grid data object coming from \code{\link{loadGridData}} or the \pkg{ecomsUDG.Raccess}
package function \code{\link[ecomsUDG.Raccess]{loadECOMS}}.}

\item{new.grid.x}{Definition of the x coordinates of the grid to interpolate.
This is a vector of length three with components \emph{from}, \emph{to} and \emph{by},
Expand Down Expand Up @@ -38,8 +38,8 @@ In case of default definition of either x, y or both grid coordinates, the defau
The output has special attributes in the \code{xyCoords} element that indicate that the object
has been interpolated. These attributes are \code{interpolation}, which indicates the method used and
\code{resX} and \code{resY}, for the grid-cell resolutions in the X and Y axes respectively.
It is also possible to pass the interpolator the grid of a previously existing grid dataset using the
\code{\link{getGrid}} method.
It is also possible to pass the interpolator the grid of a previously existing grid dataset using the
\code{\link{getGrid}} method.
}
\note{
To avoid unnecessary NA values, the function will not extrapolate using a new grid outside the
Expand Down

0 comments on commit ba1fefc

Please sign in to comment.