Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: SantanderMetGroup/transformeR
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.2.3
Choose a base ref
...
head repository: SantanderMetGroup/transformeR
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: devel
Choose a head ref
  • 5 commits
  • 5 files changed
  • 2 contributors

Commits on Aug 28, 2024

  1. minor in fillGrid.R

    Override season attribute if present when filling dates
    anacv authored Aug 28, 2024
    Copy the full SHA
    5745bcd View commit details
  2. minor in helpers.R

    In getYearsAsINDEX, only omit first year if season starts with December
    anacv authored Aug 28, 2024
    Copy the full SHA
    6b4e93a View commit details

Commits on Nov 21, 2024

  1. Copy the full SHA
    2b921f8 View commit details
  2. Copy the full SHA
    6032136 View commit details
  3. new refineGrid function

    miturbide committed Nov 21, 2024
    Copy the full SHA
    33622c9 View commit details
Showing with 91 additions and 1 deletion.
  1. +1 −0 NAMESPACE
  2. +1 −0 R/fillGrid.R
  3. +1 −1 R/helpers.R
  4. +53 −0 R/refineGrid.R
  5. +35 −0 man/refineGrid.Rd
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@ export(pattern2grid)
export(persistence)
export(prinComp)
export(redim)
export(refineGrid)
export(reorderStation)
export(rescaleGrid)
export(scaleGrid)
1 change: 1 addition & 0 deletions R/fillGrid.R
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@ fillGridDates <- function(grid, tz = "") {
}
grid <- redim(grid, drop = TRUE)
grid <- redim(grid, loc = station, member = FALSE)
if ("season" %in% names(attributes(grid$Dates))) attr(grid$Dates, "season") <- NULL
return(grid)
}
# end
2 changes: 1 addition & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
@@ -244,7 +244,7 @@ getYearsAsINDEX <- function(obj) {
yrs <- yrs + 1
}
} else {
if (!identical(season, sort(season))) {
if (!identical(season, sort(season)) & season[1]==12) {
yy <- unique(yrs)[-1]
aux <- match(mon, season)
brks <- c(1, which(diff(aux) < 0) + 1, length(aux) + 1)
53 changes: 53 additions & 0 deletions R/refineGrid.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# refineGrid.R Horizontal resolution refining
#
# Copyright (C) 2018 Santander Meteorology Group (http://www.meteo.unican.es)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


#' @title Horizontal grid refining
#' @description Increasing the grid coordinate density without altering the original pixel values.
#' @param grid a grid or multigrid to be aggregated.
#' @param times Refinement times. For instance, if the resolution of \code{grid}
#' is 1 degree and \code{times = 2}, the resolution of the output grid will be 0.5
#' degrees.
#' @return A grid or multigrid.
#'
#' @author M. Iturbide
#' @export
#' @examples \dontrun{
#' require(climate4R.datasets)
#' data("EOBS_Iberia_pr")
#' library(visualizeR)
#' spatialPlot(climatology(EOBS_Iberia_pr))
#' newgrid <- refineGrid(redim(EOBS_Iberia_pr),
#' times = 2)
#' spatialPlot(climatology(newgrid))
#' }


refineGrid <- function(grid, times = 5) {
x <- grid$xyCoords$x
res <- (x[2] - x[1]) / times
new.x <- seq((x[1] - (res * (times - 1))), (rev(x)[1] + (res * (times - 1))), res)
y <- grid$xyCoords$y
res <- (y[2] - y[1]) / times
new.y <- seq((y[1] - (res * (times - 1))), (rev(y)[1] + (res * (times - 1))), res)
out <- interpGrid(grid, new.coordinates = list(x = new.x, y = new.y))
return(out)
}

#end


35 changes: 35 additions & 0 deletions man/refineGrid.Rd

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