Skip to content

Commit 1a97519

Browse files
load_epe() reshaping (#270)
* 2 * energy_consumption_per_class Resolvido Issue 1/2 * download matriz balanço energetico Download da matriz de balanço energito raw, corrigindo caminho e método. Sem desenvolvimento mais a fundo a esperar contato do victor hugo. Optado pelo balaço consolidado por organização dos dados. * dataset ajustados * Ajuste aos pedido * final Adicionada a limpeza completa do balanço e realizados os preparativos fianis. Notas: Revisar se a versão colocada é a correta (estava diferente em DESCRIPTION e em NEWS. Chega se formatação do README está correta. devtools_check() apresentou apenas 2 "Notes", sem warning ou error. * binding global vars + readme * removing redundant code, making it faster --------- Co-authored-by: Igor Rigolon <igor.rilave@hotmail.com> Co-authored-by: IgorRigolon <77173467+IgorRigolon@users.noreply.github.com>
1 parent c2fd5dd commit 1a97519

File tree

8 files changed

+274
-485
lines changed

8 files changed

+274
-485
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Authors@R: c(
1717
person("Francisco", "de Lima Cavalcanti", , "francisco.lima.cavalcanti@gmail.com", role = "aut"),
1818
person("Maria", "Mittelbach", , "mariamittelbach@gmail.com", role = "aut"),
1919
person("Felipe", "de Moraes Nunes", , "felipedmoraesn@gmail.com", role = "aut"),
20-
person("Joao Paulo","Santos P. Barbosa",,"joao.31582129@gmail.com", role = "aut")
20+
person("Joao Paulo","Santos P. Barbosa",,"joao.31582129@gmail.com", role = "aut"),
21+
person("Bernardo","Furlanetto Sieira",,"bernardo.sieira@gmail.com", role = "aut")
2122
)
2223
Description: Functions to download and treat data regarding the Brazilian
2324
Amazon region from a variety of official sources.

NEWS.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# datazoom.amazonia 1.1.3.9000 (development version)
22

3-
* Added support for four new SIH datasets in the load_datasus() function:
4-
"datasus_sih_rd" – Reduced AIHs (summary of hospitalizations)
5-
"datasus_sih_sp" – Professional Services performed during hospitalizations
6-
"datasus_sih_rj" – Rejected AIHs with general rejection reasons
7-
"datasus_sih_er" – Rejected AIHs with specific error codes
3+
* Updated `download.R` to read the data now avaiable at the EPE website.
4+
5+
* Updated `load_epe` which has now 3 parameters following the split of `energy_consumption_per_class` in `industrial_energy_consumption` and `consumer_energy_consumption`.
86

7+
* Added support for four new SIH datasets in the load_datasus() function:
8+
* "datasus_sih_rd" – Reduced AIHs (summary of hospitalizations)
9+
* "datasus_sih_sp" – Professional Services performed during hospitalizations
10+
* "datasus_sih_rj" – Rejected AIHs with general rejection reasons
11+
* "datasus_sih_er" – Rejected AIHs with specific error codes
12+
913
# datazoom.amazonia 1.1.2.9000 (development version)
1014

1115
* Updated `load_mapbiomas` to download the newest Mapbiomas Collections and to warn about the currently unavailable download URL of the datasets water and irrigation. Also added the Indigenous Lands option to the `"mapbiomas_cover"` dataset.

R/download.R

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,6 @@ external_download <- function(dataset = NULL, source = NULL, year = NULL,
466466
if (source == "imazon") {
467467
file_extension <- ".rds"
468468
}
469-
if (source == "epe") {
470-
if (param$dataset == "national_energy_balance") {
471-
file_extension <- ".csv"
472-
}
473-
}
474469
if (source == "aneel") {
475470
if (dataset == "energy_development_budget") {
476471
file_extension <- ".rds"
@@ -504,11 +499,6 @@ external_download <- function(dataset = NULL, source = NULL, year = NULL,
504499
options(timeout = 1000) # increase timeout limit
505500
}
506501
}
507-
if (source == "epe") {
508-
if (dataset == "national_energy_balance") {
509-
download_method <- "googledrive"
510-
}
511-
}
512502
if (source %in% c("deter", "terraclimate", "baci", "sigmine", "mapbiomas")) {
513503
download_method <- "curl"
514504
quiet <- FALSE
@@ -608,37 +598,22 @@ external_download <- function(dataset = NULL, source = NULL, year = NULL,
608598
}
609599
}
610600

611-
if (param$source == "epe" & param$dataset == "energy_consumption_per_class") {
612-
# param$sheet contains the selected sheets
613-
614-
# Making a list with all the sheets
615-
dat <- purrr::imap(
616-
param$sheet,
617-
function(sheets, number) {
618-
base::message(
619-
paste0("Reading sheet ", number, " out of ", length(param$sheet), " (", sheets, ")")
620-
)
621-
base::suppressMessages(
622-
readxl::read_xls(temp, sheet = sheets)
623-
)
624-
}
625-
)
626-
627-
names(dat) <- param$sheet
628-
}
629601
if (param$source == "aneel") {
630602
if (param$dataset == "energy_enterprises_distributed") {
631603
dat <- data.table::fread(temp, encoding = "Latin-1")
632604
} else if (dataset == "energy_generation") {
633-
dat <- readxl::read_xlsx(temp, sheet = param$sheet, skip = param$skip_rows, na = c("-", ""))
605+
dat <- readxl::read_xlsx(temp, sheet = param$sheet,skip = param$skip_rows,na = c("-", ""))
634606
}
635-
}
636-
637-
if (param$source == "ips") {
607+
} else if (param$source == "ips") {
638608
dat <- param$sheet %>%
639609
purrr::map(
640610
~ readxl::read_xlsx(temp, sheet = .)
641611
)
612+
} else if (param$source == "epe") {
613+
dat <- param$sheet %>%
614+
purrr::map(
615+
~ base::suppressMessages(readxl::read_xlsx(temp, sheet = .))
616+
)
642617
}
643618

644619
## Now the rest of the functions
@@ -953,8 +928,9 @@ datasets_link <- function(source = NULL, dataset = NULL, url = FALSE) {
953928

954929
## EPE
955930

956-
"epe", "energy_consumption_per_class", NA, "2004-2021", "Region, Subsystem, State", "https://www.epe.gov.br/sites-pt/publicacoes-dados-abertos/publicacoes/Documents/CONSUMO%20MENSAL%20DE%20ENERGIA%20EL%c3%89TRICA%20POR%20CLASSE.xls",
957-
"epe", "national_energy_balance", NA, "2011-2022", NA, "https://drive.google.com/file/d/1_JTYyAPdbQayR-nrURts6OmbKcm2cLix/view?usp=share_link",
931+
"epe", "industrial_energy_consumption", NA, "2004-2025", "Region, Subsystem, State", "https://www.epe.gov.br/sites-pt/publicacoes-dados-abertos/dados-abertos/Documents/Dados_abertos_Consumo_Mensal.xlsx",
932+
"epe", "consumer_energy_consumption", NA, "2004-2025", "Region, Subsystem, State", "https://www.epe.gov.br/sites-pt/publicacoes-dados-abertos/dados-abertos/Documents/Dados_abertos_Consumo_Mensal.xlsx",
933+
"epe", "national_energy_balance", NA, "2003-2023", NA, "https://www.epe.gov.br/sites-pt/publicacoes-dados-abertos/publicacoes/PublicacoesArquivos/publicacao-819/topico-716/Anexo%20IX%20-%20Balan%C3%A7os%20Consolidados%20(em%20tep)%201970%20a%202023.xlsx",
958934

959935
## Shapefile from github repository
960936

0 commit comments

Comments
 (0)