Skip to content

Commit

Permalink
update to 0.18.1 to delete rhdf5 package reference EVERY WHERE
Browse files Browse the repository at this point in the history
  • Loading branch information
berthetclement committed Jun 24, 2024
1 parent 2f801e6 commit 3474fd0
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 262 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: antaresViz
Type: Package
Title: Antares Visualizations
Version: 0.18.0
Version: 0.18.1
Authors@R: c(
person("Tatiana", "Vargas", email = "tatiana.vargas@rte-france.com", role = c("aut", "cre")),
person("Jalal-Edine", "Zawam", role = "aut"),
Expand Down Expand Up @@ -45,12 +45,12 @@ 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,
Expand Down
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Copyright 2016 RTE Reseau de transport d'electricite

# 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
126 changes: 63 additions & 63 deletions R/h5_utils.R
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
.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])))
Expand Down Expand Up @@ -98,12 +98,12 @@
)
}

.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 3474fd0

Please sign in to comment.