-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from felipe-treistman/validacoes
Validacoes
- Loading branch information
Showing
14 changed files
with
213 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: smapOnsR | ||
Title: SMAP/ONS | ||
Version: 0.2.2 | ||
Version: 0.3.0 | ||
Authors@R: | ||
person("Felipe", "Treistman", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0001-9948-8680")) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# VALIDACAO DE ENTRADA | ||
|
||
#' valida_previsao_etp | ||
#' | ||
#' Validador de arquivo de previsao de etp | ||
#' | ||
#' @param evapotranspiracao_prevista data.table com a evapotranspiracao prevista com as colunas | ||
#' \itemize{ | ||
#' \item{data_rodada - data da rodada do modelo que gerou a previsao} | ||
#' \item{data_previsao - data da previsao} | ||
#' \item{cenario - codigo do cenario} | ||
#' \item{nome - nome da sub bacia} | ||
#' \item{valor - valor da previsao de precipitacao} | ||
#' } | ||
#' @param precipitacao_prevista data.table com a precipitacao prevista com as colunas | ||
#' \itemize{ | ||
#' \item{data_rodada - data da rodada do modelo que gerou a previsao} | ||
#' \item{data_previsao - data da previsao} | ||
#' \item{cenario - codigo do cenario} | ||
#' \item{nome - nome da sub bacia} | ||
#' \item{valor - valor da previsao de precipitacao} | ||
#' } | ||
#' @export | ||
valida_previsao_etp <- function(evapotranspiracao_prevista, precipitacao_prevista) { | ||
|
||
valida_cenarios(evapotranspiracao_prevista, precipitacao_prevista) | ||
} | ||
|
||
#' valida_cenarios | ||
#' | ||
#' Valida se para cada valor unico de nome, data_previsao e data_rodada existem os mesmos | ||
#' cenarios | ||
#' | ||
#' @param evapotranspiracao_prevista data.table com a evapotranspiracao prevista com as colunas | ||
#' \itemize{ | ||
#' \item{data_rodada - data da rodada do modelo que gerou a previsao} | ||
#' \item{data_previsao - data da previsao} | ||
#' \item{cenario - codigo do cenario} | ||
#' \item{nome - nome da sub bacia} | ||
#' \item{valor - valor da previsao de precipitacao} | ||
#' } | ||
#' @param precipitacao_prevista data.table com a precipitacao prevista com as colunas | ||
#' \itemize{ | ||
#' \item{data_rodada - data da rodada do modelo que gerou a previsao} | ||
#' \item{data_previsao - data da previsao} | ||
#' \item{cenario - codigo do cenario} | ||
#' \item{nome - nome da sub bacia} | ||
#' \item{valor - valor da previsao de precipitacao} | ||
#' } | ||
#' @export | ||
valida_cenarios <- function(evapotranspiracao_prevista, precipitacao_prevista) { | ||
|
||
merged_data <- merge(precipitacao_prevista, evapotranspiracao_prevista, | ||
by = c("data_previsao", "nome", "data_rodada", "cenario"), all = TRUE) | ||
|
||
if (nrow(merged_data[is.na(valor.x)]) != 0) { | ||
stop(paste0("falta o cenario ", merged_data$cenario, " para a data de previsao ", | ||
merged_data$data_previsao, " da sub-bacia ", merged_data$nome, | ||
" do caso de ", merged_data$data_rodada, " no arquivo de previsao de precipitacao. \n")) | ||
} | ||
|
||
if (nrow(merged_data[is.na(valor.y)]) != 0) { | ||
stop(paste0("falta o cenario ", merged_data$cenario, " para a data de previsao ", | ||
merged_data$data_previsao, " da sub-bacia ", merged_data$nome, | ||
" do caso de ", merged_data$data_rodada, " no arquivo de previsao de evapotranspiracao. \n")) | ||
} | ||
} |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.