Skip to content

Commit

Permalink
update to 0.18.3 to put package back on CRAN
Browse files Browse the repository at this point in the history
* update to 0.18.1 to delete rhdf5 package reference EVERY WHERE

* delete package suggest dependencies hexbin

* clean reference to rhdf5 package EVERYWHERE

* delete in doc function "\link" to prevent CRAN NOTE + build site updated

* up version to fix last reference to rhdf5 pacakge

* Bump to 0.18.3
revdep check ok

* update licence file to GLP 3

* exchangesStack() documentation example updated + cran comments + news

* revdep check ok
  • Loading branch information
berthetclement authored Dec 4, 2024
1 parent 2f801e6 commit 4d17d74
Show file tree
Hide file tree
Showing 128 changed files with 12,253 additions and 6,874 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ inst/examples
^revdep$
^README\.Rmd$
^CRAN-SUBMISSION$
^LICENSE\.md$
19 changes: 9 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: antaresViz
Type: Package
Title: Antares Visualizations
Version: 0.18.0
Version: 0.18.3
Authors@R: c(
person("Tatiana", "Vargas", email = "[email protected]", role = c("aut", "cre")),
person("Jalal-Edine", "Zawam", role = "aut"),
person("Francois", "Guillem", role = "aut"),
person("Benoit", "Thieurmel", role = "aut"),
person("Titouan", "Robert", role = "aut"),
person("Paul", "Plessiez", role = "aut"),
person("Jalal-Edine", "Zawam", role = "ctb"),
person("Francois", "Guillem", role = "ctb"),
person("Benoit", "Thieurmel", role = "ctb"),
person("Titouan", "Robert", role = "ctb"),
person("Paul", "Plessiez", role = "ctb"),
person("Baptiste", "Seguinot", role = "ctb"),
person("RTE", role = "cph")
)
Expand All @@ -19,7 +19,7 @@ Description: Visualize results generated by Antares, a powerful open source soft
'Antares' users visually explore the results of their simulations.
URL: https://github.com/rte-antares-rpackage/antaresViz
BugReports: https://github.com/rte-antares-rpackage/antaresViz/issues
License: GPL (>= 2) | file LICENSE
License: GPL (>= 3)
Encoding: UTF-8
Depends:
antaresRead (>= 2.2.9),
Expand All @@ -45,14 +45,13 @@ Imports:
leaflet.minicharts (>= 0.5.3),
assertthat,
rAmCharts,
utils
utils,
lifecycle
RoxygenNote: 7.2.2
Suggests:
testthat,
covr,
rhdf5 (>= 2.20.2),
ggplot2,
hexbin,
knitr,
visNetwork,
rmarkdown
Expand Down
595 changes: 595 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ importFrom(grDevices,rainbow)
importFrom(grDevices,rgb)
importFrom(graphics,par)
importFrom(graphics,plot.default)
importFrom(lifecycle,deprecate_warn)
importFrom(lifecycle,deprecated)
importFrom(lifecycle,is_present)
importFrom(methods,is)
importFrom(plotly,add_bars)
importFrom(plotly,add_heatmap)
Expand Down
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
Copyright 2016 RTE Reseau de transport d'electricite

# antaresViz 0.18.3
* The package has been accepted but archived as version 0.18.2.
New version for distribution on CRAN
* Licence file updated and documentation for `exchangesStack()` updated

# antaresViz 0.18.2
* fix cran issue on test not skip well

# antaresViz 0.18.1
* delete package dependecies `rhdf5`

# antaresViz 0.18.0
* fix deprecated dependencies (issue #200)
* packages `rgeos`, `raster` removed and replaced by `sf`
Expand Down
65 changes: 0 additions & 65 deletions R/graph_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,71 +289,6 @@
}




#' List of h5 params
#'
#' @param X_I, list
#' @param xyCompare, character
#'
#' @noRd
.h5ParamList <- function(X_I, xyCompare, h5requestFilter = NULL){
listParam <- lapply(1:length(X_I), function(i){
x <- X_I[[i]]
if (.isSimOpts(x)){
tmp <- .h5Inf(x)
h5_filter <- h5requestFilter[[i]]
h5_tables <- c("areas", "districts", "clusters", "links")
if (!is.null(h5_filter)){
if (!(is.null(h5_filter$areas) & is.null(h5_filter$districts) &
is.null(h5_filter$links) & is.null(h5_filter$clusters))){
h5_tables <- c("areas", "districts", "clusters", "links")
h5_tables <- h5_tables[which(c(!is.null(h5_filter$areas), !is.null(h5_filter$districts),
!is.null(h5_filter$clusters), !is.null(h5_filter$links)))]
}
}
tmp$tabl <- intersect(tmp$tabl, h5_tables)
rhdf5::H5close()
tmp
}else{
mcY <- unique(unlist(lapply(x, function(y){unique(y$mcYears)})))
timeStepS <- attributes(x)$timeStep
tabl <- names(x)
list(
timeStepS = timeStepS,
mcYearS = mcY,
tabl = tabl
)
}
})
res <- lapply(.transposeL(listParam), function(x){
.compareOperation(x, xyCompare)
})

res$h5requestFilter <- h5requestFilter
res
}

#' Load information from h5 file
#'
#' @param x, opts
#'
#' @noRd
.h5Inf <- function(x){
fid <- rhdf5::H5Fopen(x$h5path)
timeStepS <- .getTimeStep(fid)
timeStepS <- as.character(timeStepS)
mcYearS <- x$mcYears
tabl <- .getTableInH5(fid, timeStepS[1])
rhdf5::H5Fclose(fid)
xPart = list(
timeStepS = timeStepS,
mcYearS = mcYearS,
tabl = tabl
)
}


.transposeL <- function(data){
do.call(c, apply(do.call(rbind, data), 2, list))
}
Expand Down
198 changes: 99 additions & 99 deletions R/h5_utils.R
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
.convertH5Filtering <- function(h5requestFiltering, x)
{
if (length(h5requestFiltering) > 0)
{
if (!is.list(h5requestFiltering[[1]])){
if (!any(c("simOptions", "antaresDataTable") %in% class(x)))
{
h5requestFiltering <- rep(list(h5requestFiltering), length(x))
}else{
h5requestFiltering <- list(h5requestFiltering)
}
}else{
if (inherits(x, "list")){
if (length(h5requestFiltering) != length(x)){
h5requestFiltering <- h5requestFiltering[1:length(x) %% length(h5requestFiltering) + 1]
}
}
}
}else{
if (!any(c("simOptions", "antaresDataTable") %in% class(x)))
{
h5requestFiltering <- replicate(length(x), list())
}else{
h5requestFiltering <- replicate(1, list())
}
}
h5requestFiltering
}
# .convertH5Filtering <- function(h5requestFiltering, x)
# {
# if (length(h5requestFiltering) > 0)
# {
# if (!is.list(h5requestFiltering[[1]])){
# if (!any(c("simOptions", "antaresDataTable") %in% class(x)))
# {
# h5requestFiltering <- rep(list(h5requestFiltering), length(x))
# }else{
# h5requestFiltering <- list(h5requestFiltering)
# }
# }else{
# if (inherits(x, "list")){
# if (length(h5requestFiltering) != length(x)){
# h5requestFiltering <- h5requestFiltering[1:length(x) %% length(h5requestFiltering) + 1]
# }
# }
# }
# }else{
# if (!any(c("simOptions", "antaresDataTable") %in% class(x)))
# {
# h5requestFiltering <- replicate(length(x), list())
# }else{
# h5requestFiltering <- replicate(1, list())
# }
# }
# h5requestFiltering
# }



.getTableInH5 <- function(fid, timeStep){
dataExist <- NULL
if (rhdf5::H5Lexists(fid, paste0(timeStep, "/areas")))
{
dataExist <- c(dataExist, "areas")
}
if (rhdf5::H5Lexists(fid, paste0(timeStep, "/links")))
{
dataExist <- c(dataExist, "links")
}
if (rhdf5::H5Lexists(fid, paste0(timeStep, "/clusters")))
{
dataExist <- c(dataExist, "clusters")
}
if (rhdf5::H5Lexists(fid, paste0(timeStep, "/districts")))
{
dataExist <- c(dataExist, "districts")
}
dataExist
}
# .getTableInH5 <- function(fid, timeStep){
# dataExist <- NULL
# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/areas")))
# {
# dataExist <- c(dataExist, "areas")
# }
# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/links")))
# {
# dataExist <- c(dataExist, "links")
# }
# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/clusters")))
# {
# dataExist <- c(dataExist, "clusters")
# }
# if (rhdf5::H5Lexists(fid, paste0(timeStep, "/districts")))
# {
# dataExist <- c(dataExist, "districts")
# }
# dataExist
# }

.getVariablesH5 <- function(fid, timeStep, tables){
sapply(tables, function(X){
struct <- .getstructure(fid, paste0(timeStep, "/", X, "/mcInd/", "/structure"))$variable
if ("timeId" %in% struct){
struct <- struct[struct != "timeId"]
}
struct
}, simplify = FALSE)
}
# .getVariablesH5 <- function(fid, timeStep, tables){
# sapply(tables, function(X){
# struct <- .getstructure(fid, paste0(timeStep, "/", X, "/mcInd/", "/structure"))$variable
# if ("timeId" %in% struct){
# struct <- struct[struct != "timeId"]
# }
# struct
# }, simplify = FALSE)
# }

.getClustersNames <- function(fid, timeStep){
unique(unlist(lapply(strsplit(.getstructure(fid, paste0(timeStep, "/clusters/mcInd/structure"))$cluster, "/"), function(X)X[1])))
}
# .getClustersNames <- function(fid, timeStep){
# unique(unlist(lapply(strsplit(.getstructure(fid, paste0(timeStep, "/clusters/mcInd/structure"))$cluster, "/"), function(X)X[1])))
# }

.getElements <- function(opts, tables, fid, timeStep){
elements <- list()
if ("areas" %in% tables) elements$areas <- opts$areaList
if ("links" %in% tables) elements$links <- opts$linkList
if ("districts" %in% tables) elements$districts <- opts$districtList
if ("clusters" %in% tables){
elements$clusters <- .getClustersNames(fid, timeStep)
}
elements
}
# .getElements <- function(opts, tables, fid, timeStep){
# elements <- list()
# if ("areas" %in% tables) elements$areas <- opts$areaList
# if ("links" %in% tables) elements$links <- opts$linkList
# if ("districts" %in% tables) elements$districts <- opts$districtList
# if ("clusters" %in% tables){
# elements$clusters <- .getClustersNames(fid, timeStep)
# }
# elements
# }
#
# .getDateRange <- function(opts, timeStep){
# tim <- .timeIdToDate(sort(
# unique(
# antaresRead::.h5ReadAntares(opts$h5path, timeStep = timeStep, select = "timeId",
# areas = opts$areaList[1], mcYears = opts$mcYears[1], perf = FALSE)$timeId)
# ), timeStep = timeStep, opts = opts)
# dt <- as.Date(range(tim))
# dt
# }
#
#
# .getGraphFunction <- function(type){
# switch(type,
# "ts" = .plotTS,
# "barplot" = .barplot,
# "monotone" = .plotMonotone,
# "density" = .density,
# "cdf" = .cdf,
# "heatmap" = .heatmap,
# stop("Invalid type")
# )
# }

.getDateRange <- function(opts, timeStep){
tim <- .timeIdToDate(sort(
unique(
antaresRead::.h5ReadAntares(opts$h5path, timeStep = timeStep, select = "timeId",
areas = opts$areaList[1], mcYears = opts$mcYears[1], perf = FALSE)$timeId)
), timeStep = timeStep, opts = opts)
dt <- as.Date(range(tim))
dt
}


.getGraphFunction <- function(type){
switch(type,
"ts" = .plotTS,
"barplot" = .barplot,
"monotone" = .plotMonotone,
"density" = .density,
"cdf" = .cdf,
"heatmap" = .heatmap,
stop("Invalid type")
)
}

.getTimeStep <- function(fid){
timeSteps <- sapply(c("hourly", "daily", "weekly", "monthly", "annual"), function(X){
rhdf5::H5Lexists(fid, X)
})
names(timeSteps[which(timeSteps == TRUE)])
}
# .getTimeStep <- function(fid){
# timeSteps <- sapply(c("hourly", "daily", "weekly", "monthly", "annual"), function(X){
# rhdf5::H5Lexists(fid, X)
# })
# names(timeSteps[which(timeSteps == TRUE)])
# }

.compareOperation <- function(a, opType){
if (length(a) == 1) return(unlist(unique(a)))
Expand Down
32 changes: 16 additions & 16 deletions R/h5_utils_plot.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@



.getstructure <- function(fid, strgp){
gid <- rhdf5::H5Gopen(fid, strgp)
data <- rhdf5::h5dump(gid)
rhdf5::H5Gclose(gid)
if(length(which(data$reCalcVar!="")) > 0)
{
data$reCalcVar <- data$reCalcVar[which(data$reCalcVar!="")]
data$variable <- c(data$variable, data$reCalcVar)
data$reCalcVar <- NULL
}
data
}

.tryCloseH5 <- function(){
try(rhdf5::H5close(), silent = TRUE)
}
# .getstructure <- function(fid, strgp){
# gid <- rhdf5::H5Gopen(fid, strgp)
# data <- rhdf5::h5dump(gid)
# rhdf5::H5Gclose(gid)
# if(length(which(data$reCalcVar!="")) > 0)
# {
# data$reCalcVar <- data$reCalcVar[which(data$reCalcVar!="")]
# data$variable <- c(data$variable, data$reCalcVar)
# data$reCalcVar <- NULL
# }
# data
# }
#
# .tryCloseH5 <- function(){
# try(rhdf5::H5close(), silent = TRUE)
# }

Loading

0 comments on commit 4d17d74

Please sign in to comment.