Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 0.18.1 to delete rhdf5 package reference EVERY WHERE #208

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 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.2
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,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
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Copyright 2016 RTE Reseau de transport d'electricite

# 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
Loading