Skip to content

Commit

Permalink
Doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Jun 8, 2018
1 parent 6a6a978 commit 73ef4fd
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 79 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Suggests:
visualizeR
Type: Package
Title: An R package for climate data manipulation and transformation
Version: 1.3.3
Date: 2018-04-24
Version: 1.4.0
Date: 2018-06-08
Authors@R: as.person(c(
"Santander Meteorology Group <http://meteo.unican.es> [cph]",
"Jorge Bano Medina <bmedina@ifca.unican.es> [ctb]",
"Jorge Baño Medina <bmedina@ifca.unican.es> [ctb]",
"Joaquin Bedia <bediaj@unican.es> [aut, cre]",
"Matteo De Felice <matteo.defelice@enea.it> [ctb]",
"Jose Manuel Gutierrez <gutierjm@unican.es> [ctb]",
Expand Down
7 changes: 3 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
transformeR 1.3.3
transformeR 1.4.0
=================

* Renamed `localScaling` to `scaleGrid`
* Update variable names/levels in built-in datasets for consistency (NCEP, CMIP5)
* Other minor doc updates and internal changes
* New function `intersectGrid`, for calculating spatiotemporal intersections among grids
* Optional flag to skip seasonal check in `scaleGrid`



Expand Down
12 changes: 6 additions & 6 deletions R/intersectGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#' @family subsetting
#' @seealso \code{\link{subsetGrid}}
#' @export
#' @example {
# data("EOBS_Iberia_tas")
# a <- subsetGrid(EOBS_Iberia_tas, lonLim = c(-8,-1), latLim = c(37, 40))
# b <- subsetGrid(EOBS_Iberia_tas, lonLim = c(-4,3), latLim = c(39, 43))
# z <- intersectGrid(a, b, type = "spatial", which.return = 1)
# }
#' @examples {
#' data("EOBS_Iberia_tas")
#' a <- subsetGrid(EOBS_Iberia_tas, lonLim = c(-8,-1), latLim = c(37, 40))
#' b <- subsetGrid(EOBS_Iberia_tas, lonLim = c(-4,3), latLim = c(39, 43))
#' z <- intersectGrid(a, b, type = "spatial", which.return = 1)
#' }

intersectGrid <- function(..., type = c("temporal", "spatial"), which.return = 1) {
type <- match.arg(type, choices = c("temporal", "spatial"))
Expand Down
22 changes: 1 addition & 21 deletions R/overGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,8 @@
#'
#' @return A grid
#' @author M. Iturbide
#' @family subsetting
#' @export
#' @examples
#' library(visualizeR)
#' data("PRUDENCEregions")
#' library(loadeR)
#' grid <- loadGridData(
#' "http://opendap.knmi.nl/knmi/thredds/dodsC/e-obs_0.25regular/tx_0.25deg_reg_v17.0.nc",
#' var = "tx", years = 1983, season = 12)
#'
#' iberia <- overGrid(grid, PRUDENCEregions[2, ])
#' iberia2 <- overGrid(grid, PRUDENCEregions[2,], subset = TRUE)
#' allregions <- overGrid(grid, PRUDENCEregions, subset = TRUE)
#'
#' spatialPlot(climatology(grid),
#' sp.layout = list(list(PRUDENCEregions, first = FALSE)))
#' spatialPlot(climatology(iberia),
#' sp.layout = list(list(PRUDENCEregions, first = FALSE)))
#' spatialPlot(climatology(iberia2),
#' sp.layout = list(list(PRUDENCEregions, first = FALSE)))
#' spatialPlot(climatology(allregions),
#' sp.layout = list(list(PRUDENCEregions, first = FALSE)))


overGrid <- function(grid, layer, subset = FALSE) {
Expand All @@ -44,7 +25,6 @@ overGrid <- function(grid, layer, subset = FALSE) {
# grid <- redim(grid, runtime = TRUE)
loc <- "loc" %in% getDim(grid)
grid <- redim(grid, loc = loc)
dimNames <- getDim(grid)
# n.run <- getShape(grid)["runtime"]
n.mem <- getShape(grid)["member"]
if (loc) {
Expand Down
18 changes: 12 additions & 6 deletions R/scaleGrid.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#' and \code{"daily"}, for a julian day-based approach. See details.
#' @param type Character string. Either \code{"center"}, \code{"standardize"} or \code{"ratio"}, depending on wheter the correction factor are anomalies (e.g. temperature...),
#' estandardized anomalies or applied as a ratio (e.g. precipitation, wind speed...). See details
#' @param skip.season.check Logical flag. Should the internal checker \code{\link{checkSeason}} be skipped?. By
#' default, the function undertakes an automatic seasonal check. This can be skipped if needed, mainly for internal use
#' (e.g. in cross-validation setups)
#'
#' @template templateParallelParams
#' @details In the \code{type = "center"} set up the reference grid (\code{ref}) is used to correct the input grid, as follows:
Expand Down Expand Up @@ -177,13 +180,15 @@ scaleGrid <- function(grid,
type = "center",
parallel = FALSE,
max.ncores = 16,
ncores = NULL) {
ncores = NULL,
skip.season.check = FALSE) {
time.frame <- match.arg(time.frame, choices = c("none", "monthly", "daily"))
type <- match.arg(type, choices = c("center", "standardize", "ratio"))
spatial.frame <- match.arg(spatial.frame, choices = c("gridbox", "field"))
stopifnot(is.logical(skip.season.check))
if (time.frame == "none") {
message("[", Sys.time(), "] - Scaling ...")
out <- gridScale.(grid, base, ref, clim.fun, by.member, type, parallel, max.ncores, ncores, spatial.frame)
out <- gridScale.(grid, base, ref, clim.fun, by.member, type, parallel, max.ncores, ncores, spatial.frame, skip.season.check)
message("[", Sys.time(), "] - Done")
} else if (time.frame == "monthly") {
message("[", Sys.time(), "] - Scaling by months ...")
Expand All @@ -200,7 +205,7 @@ scaleGrid <- function(grid,
} else {
NULL
}
gridScale.(grid1, base1, ref1, clim.fun, by.member, type, parallel, max.ncores, ncores, spatial.frame)
gridScale.(grid1, base1, ref1, clim.fun, by.member, type, parallel, max.ncores, ncores, spatial.frame, skip.season.check)
})
out <- do.call("bindGrid.time", aux.list)
message("[", Sys.time(), "] - Done")
Expand Down Expand Up @@ -245,7 +250,8 @@ scaleGrid <- function(grid,
#' @importFrom parallel stopCluster
#' @author J Bedia

gridScale. <- function(grid, base, ref, clim.fun, by.member, type, parallel, max.ncores, ncores, spatial.frame) {
gridScale. <- function(grid, base, ref, clim.fun, by.member, type, parallel, max.ncores, ncores,
spatial.frame, skip.season.check) {
grid <- redim(grid)
if (is.null(base)) {
base.m <- suppressMessages({
Expand All @@ -269,7 +275,7 @@ gridScale. <- function(grid, base, ref, clim.fun, by.member, type, parallel, max
}

} else {
# checkSeason(grid, base)
if (!skip.season.check) checkSeason(grid, base)
checkDim(grid, base, dimensions = c("lat", "lon"))
base.m <- suppressMessages({
climatology(base, clim.fun, by.member, parallel, max.ncores, ncores)
Expand All @@ -293,7 +299,7 @@ gridScale. <- function(grid, base, ref, clim.fun, by.member, type, parallel, max
}
if (!is.null(ref)) {
checkDim(grid, ref, dimensions = c("lat", "lon"))
# checkSeason(grid, ref)
if (!skip.season.check) checkSeason(grid, ref)
ref.m <- suppressMessages({
climatology(ref, clim.fun, by.member, parallel, max.ncores,ncores)
}) %>% redim()
Expand Down
2 changes: 1 addition & 1 deletion man/getTemporalIntersection.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/gridScale..Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/intersectGrid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/intersectGrid.spatial.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/intersectGrid.time.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 10 additions & 20 deletions man/overGrid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/scaleGrid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/subsetDimension.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetGrid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetMembers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetRuntime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetSeason.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetSpatial.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetStation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetVar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subsetYears.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73ef4fd

Please sign in to comment.