Skip to content

Commit

Permalink
hyfo 1.4.4
Browse files Browse the repository at this point in the history
change package from rgdal to sf due to retirement of rdgal
  • Loading branch information
Yuanchao-Xu committed Jul 19, 2023
1 parent 37791a3 commit 27329d8
Show file tree
Hide file tree
Showing 39 changed files with 361 additions and 192 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
^\.Rproj\.user$
^data-raw$
^\.travis\.yml$
^cran-comments\.md$
^CRAN-SUBMISSION$
126 changes: 63 additions & 63 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -1,66 +1,3 @@
drizzle <- which(frc > minHindcastPreci & frc <= min(hindcast[hindcast > minHindcastPreci], na.rm = TRUE)
& !is.na(frc))
if (length(rain) > 0) {
ecdfFrc <- ecdf(frc[rain])
if (extrapolate == 'constant') {
# This higher and lower index mean the extrapolation part
higherIndex <- which(frc[rain] > max(hindcast, na.rm = TRUE))
lowerIndex <- which(frc[rain] < min(hindcast, na.rm = TRUE))
extrapolateIndex <- c(higherIndex, lowerIndex)
non_extrapolateIndex <- setdiff(1:length(rain), extrapolateIndex)
if (length(higherIndex) > 0) {
maxHindcast <- max(hindcast, na.rm = TRUE)
dif <- maxHindcast - max(obs, na.rm = TRUE)
frc[rain[higherIndex]] <- frc[higherIndex] - dif
}
if (length(lowerIndex) > 0) {
minHindcast <- min(hindcast, na.rm = TRUE)
dif <- minHindcast - min(obs, nna.rm = TRUE)
frc[rain[lowerIndex]] <- frc[lowerIndex] - dif
}
# Here the original function doesn't accout for the situation that extraploateIndex is 0
# if it is 0, rain[-extraploateIndex] would be nothing
# Above has been solved by using setdiff.
frc[rain[non_extrapolateIndex]] <- quantile(obs[which(obs > prThreshold & !is.na(obs))],
probs = ecdfHindcast(frc[rain[non_extrapolateIndex]]),
na.rm = TRUE, type = 4)
} else {
frc[rain] <- quantile(obs[which(obs > prThreshold & !is.na(obs))],
probs = ecdfHindcast(frc[rain]), na.rm = TRUE, type = 4)
}
}
if (length(drizzle) > 0){
# drizzle part is a seperate part. it use the ecdf of frc (larger than minHindcastPreci) to
# biascorrect the original drizzle part
frc[drizzle] <- quantile(frc[which(frc > min(hindcast[which(hindcast > minHindcastPreci)], na.rm = TRUE) &
!is.na(frc))], probs = ecdfFrc(frc[drizzle]), na.rm = TRUE,
type = 4)
}
frc[noRain] <- 0
} else {
# in this condition minHindcastPreci is the max of hindcast, so all hindcast <= minHindcastPreci
# And frc distribution is used then.
noRain <- which(frc <= minHindcastPreci & !is.na(frc))
rain <- which(frc > minHindcastPreci & !is.na(frc))
if (length(rain) > 0) {
ecdfFrc <- ecdf(frc[rain])
frc[rain] <- quantile(obs[which(obs > prThreshold & !is.na(obs))], probs = ecdfFrc(frc[rain]),
na.rm = TRUE, type = 4)
}
frc[noRain]<-0
}
return(frc)
}
biasCorrect_core_gqm <- function(frc, hindcast, obs, prThreshold, minHindcastPreci) {
if (any(obs > prThreshold)) {
ind <- which(obs > prThreshold & !is.na(obs))
obsGamma <- fitdistr(obs[ind],"gamma", lower = c(0, 0))
ind <- which(hindcast > 0 & !is.na(hindcast))
hindcastGamma <- fitdistr(hindcast[ind],"gamma", lower = c(0, 0))
rain <- which(frc > minHindcastPreci & !is.na(frc))
noRain <- which(frc <= minHindcastPreci & !is.na(frc))
probF <- pgamma(frc[rain], hindcastGamma$estimate[1], rate = hindcastGamma$estimate[2])
frc[rain] <- qgamma(probF,obsGamma$estimate[1], rate = obsGamma$estimate[2])
frc[noRain] <- 0
} else {
warning('All the observations of this cell(station) are lower than the threshold,
Expand Down Expand Up @@ -510,3 +447,66 @@ devtools::check_win_devel()
devtools::check_win_devel()
devtools::build()
devtools::build()
devtools::check_win_devel()
install.packages("sf")
devtools::check_win_devel()
install.packages("sf")
install.packages("sf")
devtools::check_win_devel()
devtools::check_win_devel()
devtools::check_win_devel()
devtools::check_win_devel()
devtools::build()
devtools::build()
devtools::check(remote = T, cran = T)
devtools::document()
devtools::check(remote = T, cran = T)
devtools::check_win_devel()
devtools::check_win_devel()
install.packages("devtools")
install.packages("devtools")
install.packages("devtools")
install.packages("devtools")
install.packages("devtools")
install.packages("devtools")
install.packages("devtools")
devtools::document()
install.packages("cli")
install.packages("cli")
devtools::document()
devtools::check(remote = T, cran = T)
library(cli)
devtools::document()
library(devtools)
devtools::document()
library(rlang)
devtools::document()
devtools::check(remote = T, cran = T)
devtools::build()
?devtools
devtools::build(binary = T)
devtools::build()
devtools::submit_cran()
devtools::use_cran_comments()
use_cran_comments()
usethis::use_cran_comments()
devtools::submit_cran()
devtools::submit_cran()
devtools::submit_cran()
devtools::build()
devtools::submit_cran()
debug(devtools::build())
debug(submit_cran)
debug(devtools::submit_cran)
devtools::submit_cran()
devtools::submit_cran()
r
new_url
new_url$query$submit == "1"
new_url$query$submit
new_url$query
r$url
httr::parse_url(r$url)
devtools::submit_cran()
undebug(devtools::submit_cran)
devtools::submit_cran()
11 changes: 4 additions & 7 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
C:/hyfo/DESCRIPTION="E115FF50"
C:/hyfo/R/getSpatialMap.R="360D9F5D"
C:/hyfo/R/ncdf.R="6981B7D0"
C:/hyfo/README.md="BBF5FB5B"
C:/hyfo/man/getSpatialMap.Rd="B8BD6975"
C:/hyfo/man/writeNcdf.Rd="665DA26C"
C:/hyfo/vignettes/hyfo.Rmd="4D6D9459"
/Users/yuanchaoxu/Documents/GitHub/hyfo/.travis.yml="3AC61E6F"
/Users/yuanchaoxu/Documents/GitHub/hyfo/NAMESPACE="11200187"
/Users/yuanchaoxu/Documents/GitHub/hyfo/NEWS="40156A70"
/Users/yuanchaoxu/Documents/GitHub/hyfo/cran-comments.md="E91D33FC"
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ apt_packages:
- libproj0

#r_binary_packages:
# - rgdal
# - rgeos
# - sf
# - data.table
#r_packages:
# - data.table
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 1.4.4
Date: 2023-07-19 14:24:10 UTC
SHA: 37791a34a0676a9a05cb6ee87291561f702e1bc7
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: hyfo
Type: Package
Title: Hydrology and Climate Forecasting
Version: 1.4.3
Date: 2020-8-26
Version: 1.4.4
Date: 2023-7-12
Authors@R: person("Yuanchao", "Xu", email = "[email protected]",
role = c("aut", "cre"))
Description: Focuses on data processing and visualization in hydrology and
Expand All @@ -19,13 +19,12 @@ Imports:
ggplot2 (>= 1.0.1),
reshape2 (>= 1.4.1),
zoo (>= 1.7-12),
rgdal (>= 0.8-16),
sf (>= 1.0-12),
plyr (>= 1.8.3),
moments (>= 0.14),
lmom (>= 2.5),
maps(>= 2.3-9),
maptools (>= 0.8-36),
rgeos (>= 0.3-8),
ncdf4 (>= 1.14.1),
MASS (>= 7.3-39),
methods,
Expand All @@ -39,4 +38,4 @@ LazyData: true
URL: https://yuanchao-xu.github.io/hyfo/
BugReports: https://github.com/Yuanchao-Xu/hyfo/issues
Repository: CRAN
RoxygenNote: 6.1.1
RoxygenNote: 7.2.3
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import(maps)
import(maptools)
import(ncdf4)
import(plyr)
import(rgdal)
import(rgeos)
import(sf)
importFrom(MASS,fitdistr)
importFrom(data.table,rbindlist)
importFrom(grDevices,rainbow)
Expand All @@ -49,6 +48,7 @@ importFrom(methods,setMethod)
importFrom(moments,kurtosis)
importFrom(moments,skewness)
importFrom(reshape2,melt)
importFrom(sf,st_read)
importFrom(stats,aggregate)
importFrom(stats,coef)
importFrom(stats,cor)
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ Date: 2015-12-15
NOTE:
====
- for hyfo$Data part, when load and write using ncdf4, there will be very little differences compared to the original, which cannot be addressed. If you first load an ncdf file, then write it, then load it again. The data part may have very little difference, less than 10E-5.
hyfo 1.4.4
==========
Date: 2023-07-12

- change package from rgdal to sf due to retirement of rdgal



Expand Down
2 changes: 1 addition & 1 deletion R/dataDocument.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@


#' testCat
#' @format A catchment file generated by library rgdal.
#' @format A catchment file generated by library sf.
#' \describe{
#' \item{class}{Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots}
#' ...
Expand Down
4 changes: 2 additions & 2 deletions R/getSpatialMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ getSpatialMap <- function(dataset, method = NULL, member = 'mean', ...) {
#' # More examples can be found in the user manual on https://yuanchao-xu.github.io/hyfo/
#'
#' @export
#' @import ggplot2 plyr maps maptools rgeos
#' @import ggplot2 plyr maps maptools sf
#' @importFrom stats median
#' @importFrom reshape2 melt
#' @references
Expand All @@ -246,7 +246,7 @@ getSpatialMap <- function(dataset, method = NULL, member = 'mean', ...) {
#' Objects. R package version 0.8-36. https://CRAN.R-project.org/package=maptools
#'
#' \item Roger Bivand and Colin Rundel (2015). rgeos: Interface to Geometry Engine - Open Source (GEOS). R
#' package version 0.3-11. https://CRAN.R-project.org/package=rgeos
#' package version 0.3-11. https://CRAN.R-project.org/package=sf
#'
#' }
#'
Expand Down
8 changes: 4 additions & 4 deletions R/shp2cat.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @param filePath A string representing the path of the shape file.
#' @return A catchment object can be used in \code{getSpatialMap()}.
#' @export
#' @details This function is based on the package \code{rgdal} and \code{sp}, and the output comes from the package
#' @details This function is based on the package \code{sf} and \code{sp}, and the output comes from the package
#' \code{sp}
#' @examples
#' #open internal file
Expand All @@ -11,13 +11,13 @@
#'
#' # More examples can be found in the user manual on https://yuanchao-xu.github.io/hyfo/
#'
#' @import rgdal
#' @importFrom sf st_read
#' @importFrom utils tail
#' @references
#'
#' \itemize{
#' \item Roger Bivand, Tim Keitt and Barry Rowlingson (2015). rgdal: Bindings for the Geospatial Data
#' Abstraction Library. R package version 1.0-4. https://CRAN.R-project.org/package=rgdal
#' Abstraction Library. R package version 1.0-4. https://CRAN.R-project.org/package=sf
#'
#' \item R Core Team (2015). R: A language and environment for statistical computing. R Foundation for
#' Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
Expand Down Expand Up @@ -46,6 +46,6 @@ shp2cat <- function(filePath) {
}

if (length(folderName) == 0) stop('No shape file found, make sure the shp file is selected.')
catchment <- readOGR(folderName, catName1)
catchment <- st_read(folderName, catName1)
return(catchment)
}
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
9 changes: 3 additions & 6 deletions man/applyBiasFactor.Rd

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

46 changes: 33 additions & 13 deletions man/biasCorrect.Rd

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

3 changes: 1 addition & 2 deletions man/collectData.Rd

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

Loading

0 comments on commit 27329d8

Please sign in to comment.