Skip to content

Commit

Permalink
Merge pull request magpiemodel#534 from pfuehrlich-pik/develop
Browse files Browse the repository at this point in the history
magpie release 4.6.4
  • Loading branch information
pfuehrlich-pik authored Feb 22, 2023
2 parents 48cc3b8 + 91f0de9 commit ff1b1bf
Show file tree
Hide file tree
Showing 209 changed files with 3,823 additions and 3,140 deletions.
14 changes: 3 additions & 11 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) {

# bootstrapping, will only run once after this repo is freshly cloned
if (isTRUE(rownames(installed.packages(priority = "NA")) == "renv")) {
if (file.exists("DESCRIPTION") && !identical(readLines("DESCRIPTION"), readLines("DEPENDENCIES"))) {
warning("Unexpected DESCRIPTION file found, try removing it. Will not install dependencies.")
} else {
message("R package dependencies are not installed in this renv, installing now...")
renv::install("yaml", prompt = FALSE) # yaml is required to find dependencies in Rmd files
# renv will only consider a file called DESCRIPTION, so rename DEPENDENCIES
file.copy("DEPENDENCIES", "DESCRIPTION")
renv::hydrate() # auto-detect and install all dependencies
file.remove("DESCRIPTION")
message("Finished installing R package dependencies.")
}
message("R package dependencies are not installed in this renv, installing now...")
renv::hydrate() # auto-detect and install all dependencies
message("Finished installing R package dependencies.")
}

# source global .Rprofile (very important to load user specific settings)
Expand Down
33 changes: 21 additions & 12 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
#!/usr/bin/env Rscript

if(!requireNamespace("gms", quietly = TRUE)) install.packages("gms", repos = c("https://rse.pik-potsdam.de/r/packages/", "https://cloud.r-project.org"))
gmsRequiredVersion <- "0.24.1"
if (tryCatch(utils::packageVersion("gms") < gmsRequiredVersion, error = function(error) TRUE)) {
message("gms >= ", gmsRequiredVersion, " is required, installing now...")
install.packages("gms")
}

message("Checking files for tabs... ", appendLF = FALSE)
gms::checkNoTabs(pattern = "\\.(R|Rprofile|gms|cfg|bib)$", excludeFolders = c("output", "renv", ".git"))
message("done.")

# run codeCheck
null <- gms::codeCheck(strict=TRUE)
invisible(gms::codeCheck(strict = TRUE))
message("")

# make sure that files are not too big

maxfilesize <- function(max=512) {
files <- union(system("git ls-tree -r HEAD --name-only", intern=TRUE),
system("git diff --cached --name-only", intern=TRUE))
out <- data.frame(files=files,size=round(file.size(files)/1024,2))
out <- out[!is.na(out$size),]
out <- out[out$size > max,]
if(nrow(out)>0) {
stop(nrow(out), " files with size > ",max,"kB detected: \n",paste0(out$files," (", out$size, "kB)", collapse = "\n"))
# make sure that files are not too big
maxfilesize <- function(max) {
files <- union(system("git ls-tree -r HEAD --name-only", intern = TRUE),
system("git diff --cached --name-only", intern = TRUE))
out <- data.frame(files = files, size = round(file.size(files) / 1024, 2))
out <- out[!is.na(out$size), ]
out <- out[out$size > max, ]
if (nrow(out) > 0) {
stop(nrow(out), " files with size > ", max, "kB detected: \n",
paste0(out$files, " (", out$size, "kB)", collapse = "\n"))
}
message("All files are smaller than ",max,"kB\n")
message("All files are smaller than ", max, "kB\n")
}

maxfilesize(250)
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ gamslice.txt
/.lock

/renv.lock
.Rproj.user
4 changes: 2 additions & 2 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "MAgPIE - An Open Source land-use modeling framework",
"version": "4.6.3",
"version": "4.6.4",
"creators": [
{
"name": "Dietrich, Jan Philipp",
Expand Down Expand Up @@ -109,5 +109,5 @@
"license": {
"id": "AGPL-3.0-or-later"
},
"publication_date": "2023-01-19"
"publication_date": "2023-02-22"
}
43 changes: 42 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,46 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [4.6.4] - 2023-02-22

### changed
- **15_food** Interpret EAT-Lancet guidelines not as target but as lower/upper limits
- **config** changed order of output scripts. Some functions in rds_report require gridded outputs.
- **config** input data revision to rev4.81 for trade margin bugfix
- **config** scenario_fsec.csv updated input data tgz
- **config** scenario_fsec.csv updated to new biodiversity scenario
- **scripts** fsec.R and project_FSEC_Scenarios.R include capitalSubst and landscapeElements scenarios
- **scripts** highres.R changed default resolution to c1000
- **scripts** recalibrate.R and recalibrate_realization were modified to always use best_calib for the yield calibration.
- **scripts** updated FSEC scenario start and output scripts
- **scripts** when manually running output scripts for multiple runs the lockfile is only created once
- **sticky_labor** changed labor cost share constraint from regional to cellular level
- **sticky_labor** renamed equation `q38_labor_capital_ratio` to `q38_labor_share_target`

### added
- **15_food** half_overweight scenario added
- **21_trade** New Bilateral trade realization selfsuff_reduced_bilat22 for bilateral trade within selffsuff constraints
- **32_forestry** added switch `s32_aff_prot` for protection of afforested areas (0=until end of planning horizon 1=forever)
- **56_ghg_policy** added two scenarios for GHG emission pricing and options for afforestation
- **config** added options for afforestation assumptions and updated additional data to 4.38
- **config** added setting cfg$keep_restarts which controls whether restart files should be kept after a run finished
- **config** changed default for `s_use_gdx` from 2 to 0
- **scripts** added restart points after each time step from which the model can now be restarted if the simulation aborts at some point
- **scripts** added SLURM dayMax submission type for standby QOS
- **sticky_labor** `nl_fix`, `nl_relax` and `nl_release` added

### removed
- **42_water_demand** removed fm_multicropping factor because of fallow inconsistency

### fixed
- **14_yields** nl_fix updated to current equation
- **32_forestry** pm_land_conservation(t,j,"secdforest","restore") now accounts for the rotation length in timber plantations to avoid infeasibilities
- **44_biodiversity** added regional layer `i` in `bii_target` realisation to make it compatible with the high-resolution parallel optimization output script
- **59_som** division by zero prevented by if condition
- **scripts** fixed a bug where renvs for high resolution runs were missing some packages
- **scripts** fixed in the calc_calib.R script the saving of calib_factors used in each iteration to ensure that they correspond to the divergence reported. Changed divergence from zero to NA for those iterations where calib_factors are above the limit. The best_calib selection criterion was changed from selecting the factors of the iteration with the lowest standard deviation to the selection, for each region, of the factor of the iteration with the lowest divergence. Also, factors from the first iteration are now not considered, and if two different factors had the same divergence for a region, the one of the latest iteration is picked.


## [4.6.3] - 2023-01-19

### changed
Expand Down Expand Up @@ -612,7 +652,8 @@ This release version is focussed on consistency between the MAgPIE setup and the
First open source release of the framework. See [MAgPIE 4.0 paper](https://doi.org/10.5194/gmd-12-1299-2019) for more information.


[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.3...develop
[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.4...develop
[4.6.4]: https://github.com/magpiemodel/magpie/compare/v4.6.3...v4.6.4
[4.6.3]: https://github.com/magpiemodel/magpie/compare/v4.6.2...v4.6.3
[4.6.2]: https://github.com/magpiemodel/magpie/compare/v4.6.1...v4.6.2
[4.6.1]: https://github.com/magpiemodel/magpie/compare/v4.6.0...v4.6.1
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ authors:
email: [email protected]

title: MAgPIE - An Open Source land-use modeling framework
version: 4.6.3
date-released: 2023-01-19
version: 4.6.4
date-released: 2023-02-22
repository-code: https://github.com/magpiemodel/magpie
keywords:
- landuse
Expand Down
7 changes: 6 additions & 1 deletion DEPENDENCIES → DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Package: magpiemodel
Description: Refer to README.md for a description of the MAgPIE model.
This file only lists dependencies and is called DESCRIPTION for
technical reasons.
Imports:
callr,
citation,
Expand All @@ -9,7 +12,7 @@ Imports:
gdxrrw,
ggplot2,
ggrepel,
gms,
gms (>= 0.24.0),
here,
iamc,
lucode2 (>= 0.36.0),
Expand All @@ -35,4 +38,6 @@ Imports:
withr
Suggests:
goxygen,
languageserver,
qgraph
Encoding: UTF-8
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.PHONY: help docs update-renv update-all-renv check check-fix
.PHONY: help docs update-renv update-renv-all archive-renv restore-renv check check-fix start output
.DEFAULT_GOAL := help

# extracts the help text and formats it nicely
HELP_PARSING = 'm <- readLines("Makefile");\
m <- grep("\#\#", m, value=TRUE);\
command <- sub("^([^ ]*) *\#\#(.*)", "\\1", m);\
help <- sub("^([^ ]*) *\#\#(.*)", "\\2", m);\
cat(sprintf("%-8s%s", command, help), sep="\n")'
cat(sprintf("%-18s%s", command, help), sep="\n")'

help: ## Show this help.
@Rscript -e $(HELP_PARSING)
Expand All @@ -19,7 +19,7 @@ update-renv: ## Upgrade all pik-piam packages in your renv to the respective
## latest release and write renv.lock to archive.
Rscript -e 'piamenv::updateRenv()'

update-all-renv: ## Upgrade all packages (including CRAN packages) in your renv
update-renv-all: ## Upgrade all packages (including CRAN packages) in your renv
## to the respective latest release and write renv.lock to archive.
Rscript -e 'renv::update(exclude = "renv"); piamenv::archiveRenv()'

Expand All @@ -38,3 +38,9 @@ check-fix: ## Check if the GAMS code follows the coding etiquette
## and offer fixing any problems directly if possible
## using gms::codeCheck.
Rscript -e 'invisible(gms::codeCheck(strict = TRUE, interactive = TRUE))'

start: ## Start a MAgPIE run.
Rscript start.R

output: ## Run an output script.
Rscript output.R
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ https://www.pik-potsdam.de/research/projects/activities/land-use-modelling/magpi
A framework description paper has been published in
Geoscientific Model Development (GMD): https://doi.org/10.5194/gmd-12-1299-2019

The model documentation for version 4.6.3 can be found at
https://rse.pik-potsdam.de/doc/magpie/4.6.3/
The model documentation for version 4.6.4 can be found at
https://rse.pik-potsdam.de/doc/magpie/4.6.4/

A most recent version of the documentation can also be extracted from the
model source code via the R package goxygen
Expand Down Expand Up @@ -188,7 +188,7 @@ [email protected]
Please contact [email protected]

## CITATION
See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.6.3/#how-to-cite) in the model documentation for information how to cite the model.
See file CITATION.cff or the [How-to-Cite section](https://rse.pik-potsdam.de/doc/magpie/4.6.4/#how-to-cite) in the model documentation for information how to cite the model.

## AUTHORS
See list of authors in CITATION.cff
Expand Down
Loading

0 comments on commit ff1b1bf

Please sign in to comment.