Skip to content
Merged
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
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

NEW FEATURES :

* `createClusterST()`/`editClusterST()` : Parameter `group` is now dynamic and have no restriction
* `createClusterST()`/`editClusterST()` :
- **New properties** (*efficiencywithdrawal*, *penalize-variation-injection*, *penalize-variation-withdrawal*, see list of properties according to study version of Antares with `storage_values_default()`)
- **New optional time series** (cost-injection, cost-withdrawal, cost-level, cost-variation-injection, cost-variation-withdrawal)

### Breaking changes :
- `createClusterST()`/`editClusterST()` : parameter `group` is now dynamic and have no restriction
- `createClusterST()` : for a study < 9.2, execution will be STOP if `group` is not included in list (see doc)
- `createClusterST()` : For a study < *v9.2*, execution will be STOP if `group` is not included in list (see doc)
- `updateAdequacySettings()` : Two parameters (*enable-first-step*, *set-to-null-ntc-between-physical-out-for-first-step*) are `deprecated` and removed. Parameters are forced to `NULL` with study >= v9.2.


### DOC :
Expand Down
6 changes: 1 addition & 5 deletions R/RES.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
#' appropriate structure for RES clusters.
#' @param quietly Display or not a message to the user if success.
#'
#' @param opts
#' List of simulation parameters returned by the function
#' \code{antaresRead::setSimulationPath}
#'
#' @return An updated list containing various information about the simulation.
#' @template opts
#' @export
#'
#' @examples
Expand Down
1 change: 0 additions & 1 deletion R/createClusterST.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
#' "my_cluster",
#' storage_parameters = my_parameters)
#'
#'
#' # time series
#' ratio_value <- matrix(0.7, 8760)
#'
Expand Down
36 changes: 32 additions & 4 deletions R/updateAdequacySettings.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,45 @@ updateAdequacySettings <- function(include_adq_patch = NULL,
new_params <- new_params[!names(new_params) %in% properties_850]
}

if (opts[["antaresVersion"]] >= 860) {
if (opts[["antaresVersion"]] >= 860 &&
opts[["antaresVersion"]] <920) {
if ("enable_first_step" %in% names(new_params)) {
message("Property enable_first_step is disabled for the moment. Set to FALSE.\n")
new_params[["enable_first_step"]] <- FALSE
}
}

new_params <- lapply(X = new_params, FUN = .format_ini_rhs)
names(new_params) <- sapply(names(new_params), dicoAdequacySettings, USE.NAMES = FALSE)
# display a warning for these parameters
if (opts[["antaresVersion"]] >= 920) {
short_name <- set_to_null_ntc_between_physical_out_for_first_step
if (!is.null(enable_first_step)){
lifecycle::deprecate_warn(
when = "2.9.2",
what = "antaresEditObject::updateAdequacySettings(enable_first_step)",
details = "This parameter are no longer supported for an Antares version >= '9.2', the values will be ignored."
)
new_params[["enable_first_step"]] <- NULL
}
if(!is.null(short_name)){
lifecycle::deprecate_warn(
when = "2.9.2",
what = "antaresEditObject::updateAdequacySettings(set_to_null_ntc_between_physical_out_for_first_step)",
details = "This parameter are no longer supported for an Antares version >= '9.2', the values will be ignored."
)
new_params[["set_to_null_ntc_between_physical_out_for_first_step"]] <- NULL
}
}

new_params <- lapply(X = new_params,
FUN = .format_ini_rhs)

names(new_params) <- sapply(names(new_params),
dicoAdequacySettings,
USE.NAMES = FALSE)

res <- update_generaldata_by_section(opts = opts, section = "adequacy patch", new_params = new_params)
res <- update_generaldata_by_section(opts = opts,
section = "adequacy patch",
new_params = new_params)

invisible(res)
}
Expand Down
21 changes: 12 additions & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,15 @@ generate_cluster_name <- function(area, cluster_name, add_prefix) {
#' @importFrom antaresRead readIniFile
update_generaldata_by_section <- function(opts, section, new_params) {

if (is_api_study(opts = opts)) {
if (is_api_study(opts = opts))
writeIni(listData = new_params,
pathIni = sprintf("settings/generaldata/%s", section),
opts = opts)

writeIni(listData = new_params, pathIni = sprintf("settings/generaldata/%s", section), opts = opts)

} else {

generaldatapath <- file.path(opts[["studyPath"]], "settings", "generaldata.ini")
else {
generaldatapath <- file.path(opts[["studyPath"]],
"settings",
"generaldata.ini")
generaldata <- readIniFile(file = generaldatapath)

if (section %in% names(generaldata)) {
Expand All @@ -199,9 +201,10 @@ update_generaldata_by_section <- function(opts, section, new_params) {
l_section <- new_params
}
generaldata[[section]] <- l_section

writeIni(listData = generaldata, pathIni = generaldatapath, overwrite = TRUE, opts = opts)
writeIni(listData = generaldata,
pathIni = generaldatapath,
overwrite = TRUE,
opts = opts)
}

return(update_opts(opts = opts))
}
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<img src="man/figures/antares_simulator.png" align="right" width=250 />
# antaresEditObject <img src="man/figures/antares_simulator.png" align="right" alt="" width=250 />
<br/>

# antaresEditObject


> Edit an Antares study before running a simulation.

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/antaresEditObject)](https://CRAN.R-project.org/package=antaresEditObject)
[![cranlogs](https://cranlogs.r-pkg.org/badges/antaresEditObject)](https://cran.r-project.org/package=antaresEditObject)
Expand All @@ -15,6 +10,8 @@
[![Codecov test coverage](https://codecov.io/gh/rte-antares-rpackage/antaresEditObject/graph/badge.svg)](https://app.codecov.io/gh/rte-antares-rpackage/antaresEditObject)
<!-- badges: end -->

> Edit an Antares study before running a simulation.


## Installation

Expand Down
4 changes: 2 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ development:
mode: auto
destination: docs/release920
template:
params:
bootswatch: readable
bootstrap: 5
light-switch: true

2 changes: 1 addition & 1 deletion man/activateRES.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/createClusterST.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions tests/testthat/test-updateAdequacyPatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,31 @@ test_that("Update an adequacy parameter for an Antares version 860", {

unlink(x = opts$studyPath, recursive = TRUE)
})

# >= v920 ----
suppressWarnings(
createStudy(path = tempdir(),
study_name = "st-storage9.2",
antares_version = "9.2"))

test_that("Properties removed", {
lifecycle::expect_deprecated(
updateAdequacySettings(
set_to_null_ntc_between_physical_out_for_first_step = FALSE),
regexp = "The `set_to_null_ntc_between_physical_out_for_first_step` argument"
)

lifecycle::expect_deprecated(
updateAdequacySettings(enable_first_step = FALSE),
regexp = "The `enable_first_step` argument"
)

# read general parameters
parameters <- readIni("settings/generaldata")
params <- parameters[["adequacy patch"]]

# tests if NULL are well forced
expect_equal(length(params), 0)
})

deleteStudy()
8 changes: 4 additions & 4 deletions vignettes/Antares_new_features_v860.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ Full documentation is available in the function `writeInputTS()`. We will see fu

Checks depends of values of parameters in `hydro.ini` file.

```{r schema combinatoire , echo=FALSE, fig.cap="", out.width = '50%', fig.align='center'}
knitr::include_graphics("schemas/mingen_hydro_rules.png")
```{r schema combinatoire , echo=FALSE, fig.cap="", out.width = '40%', fig.alt="hydro params", fig.align='center'}
knitr::include_graphics("mingen_hydro_rules.png")
```

```{r schema, echo=FALSE, fig.cap="", out.width = '75%', fig.align='center'}
```{r schema, echo=FALSE, fig.cap="", out.width = '100%', fig.alt="mingen schema", fig.align='center'}
# path_image <- sourcedir860 <- system.file("doc/schemas", package = "antaresEditObject")
# knitr::include_graphics(file.path(path_image,"mingen.png"))
knitr::include_graphics("schemas/mingen_draw.png")
knitr::include_graphics("mingen_draw.png")
```

After creating study, `.txt` files containing time series are empty. We will describe steps to edit `mingen.txt`.
Expand Down
3 changes: 1 addition & 2 deletions vignettes/api-variant-management.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ writeVariantCommands("path/to/commands.json")

Below are listed all functions from {antaresEditObject} that can be used with the API. These functions will include the following badge in their documentation:

![](https://img.shields.io/badge/Antares%20API-OK-green)

<img src="https://img.shields.io/badge/Antares%20API-OK-green" alt=""/>

### Create an area

Expand Down
File renamed without changes