Skip to content

Commit

Permalink
update develop
Browse files Browse the repository at this point in the history
  • Loading branch information
caviddhen committed Sep 23, 2023
2 parents fdd30c3 + 4834073 commit 4a5a731
Show file tree
Hide file tree
Showing 90 changed files with 1,460 additions and 510 deletions.
9 changes: 9 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ Sys.setenv(RENV_PATHS_LIBRARY = "renv/library")

source("renv/activate.R")

renvVersion <- "0.16.0"
if (packageVersion("renv") != renvVersion) {
renvLockExisted <- file.exists(renv::paths$lockfile())
renv::upgrade(version = renvVersion, reload = TRUE, prompt = FALSE)
if (!renvLockExisted) {
unlink(renv::paths$lockfile())
}
}

if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) {
options(repos = c(getOption("repos"), pik = "https://rse.pik-potsdam.de/r/packages"))
}
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/test-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Remove .Rprofile
run: rm .Rprofile

- uses: r-lib/actions/setup-r@v2
with:
extra-repositories: https://cloud.r-project.org https://rse.pik-potsdam.de/r/packages/

- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: gms
extra-packages: gms
use-public-rspm: true
extra-repositories: "https://rse.pik-potsdam.de/r/packages"

- name: pre-commit Hook
run: source(".githooks/pre-commit")
Expand Down
23 changes: 0 additions & 23 deletions .snapshot.Rprofile

This file was deleted.

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.7dev",
"version": "4.6.11dev",
"creators": [
{
"name": "Dietrich, Jan Philipp",
Expand Down Expand Up @@ -109,5 +109,5 @@
"license": {
"id": "AGPL-3.0-or-later"
},
"publication_date": "2023-05-10"
"publication_date": "2023-09-05"
}
71 changes: 67 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,78 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### changed
- **scripts** start_functions.R can now handle clusters per region flexibly
-

### added
- **18_residues** Included cluster-level residue realization, for cluster-level production of residues (but balancing of recycling and burning budgets remains at region-level, for computational lightness)
- **14_yields/config** Added option for considering impacts of land degradation on yields. If `s14_degradation` is switched to 1, MAgPIE will include cluster-specific information on the state of nature's contributions to people relevant for yields `./modules/14_yields/input/f14_yld_ncp_report.cs3`.

### removed
-

### fixed
-


## [4.6.11] - 2023-09-05

### changed
- **scripts** All time steps between 2015 and 2050 are now reported to SEALS

### fixed
- **70_livestock** fixed division by zero that could occur depending on the scenario set-up


## [4.6.10] - 2023-08-16

### changed
- **config** update preprocessing to newest input data v4.88 with new transport costs
- **GitHub action** the github action is now faster, because it installs binary packages from Posit Package Manager
- **scenario_config.csv** update preprocessing to newest input data v4.88
- **scripts** output.R is now faster, because it no longer searches runfolder renvs for full.gms files

### fixed
- **scripts** check_config does not warn about c_input_gdx_path anymore while running empty model
- **scripts** fixed erronoeous if clause in output.R
- **scripts** fixed output/extra/disaggregation_LUH2.R. The script was not working any more because magpie4::protectedArea was changed to return protected area for all land types. Moreover, the script now also works for runs without dynamic forestry (default run) but with a warning message.


## [4.6.9] - 2023-07-27

### fixed
- **70_livestock** consideration of milk demand in the calculation of the pasture management factor
- **scripts** Fixed inaccuracies and inconsistent application of SNV policies during disaggregation in luscale::interpolateAvlCroplandWeighted(), which is called in extra/disaggregation.R


## [4.6.8] - 2023-07-17

### changed
- **41_area_equipped_for_irrigation** new AEI data (Mehta2022) replacing old Siebert data
- **80_optimization** printing of solprint when solver status is 7 re-activated
- **scripts** start_functions.R can now handle clusters per region flexibly
- **scripts** the REMIND-MAgPIE coupling now uses renv

### added
- **scenario_config.csv** added a scenario for the NGFS project
- **31_past** added `cc`, `nocc` and `nocc_hist` options for `c31_past_suit_scen` and `c31_grassl_yld_scenario`
- **32_carbon** added `nocc` and `nocc_hist` option for `c52_land_carbon_sink_rcp`
- **71_disagg_lvst** added new realisation `foragebased_jul23` which solves GAMS issues at higher spatial resolutions
- **config** added `cfg$results_folder_highres` which allows to modify the output folder used in the `highres.R` output script
- **config** new area equipped for irrigation (AEI) data in preprocessing (4.87)
- **scenario_config.csv** added a scenario for the NGFS project
- **scripts** New output script for reporting disaggregated land use patterns to the SEALS (Spatial Economic Allocation Landscape Simulator) downscaling model

### removed
-
- **config** `s80_num_nonopt_allowed`
- **scripts** removed .snapshot.Rprofile and the Rprofile.R script, renv now fully supersedes snapshots

### fixed
- **30_crop** corrected q30_cropland in module realization rotation_apr22, where fallow land was on the wrong side of the equation
- **71_disagg_lvst** reworked `foragebased_aug18` (including removal of linear version and correction of balance flow calculation)
- **80_optimization** resolve was not working in nlp_par realization due to `s80_num_nonopt_allowed`
- **config** corrected wrong names of parameters for peatland costs
- **config** updated scenario configs to newest preprocessing (4.87)


## [4.6.7] - 2023-05-10

### changed
Expand Down Expand Up @@ -717,7 +776,11 @@ 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.7...develop
[Unreleased]: https://github.com/magpiemodel/magpie/compare/v4.6.11...develop
[4.6.11]: https://github.com/magpiemodel/magpie/compare/v4.6.10...v4.6.11
[4.6.10]: https://github.com/magpiemodel/magpie/compare/v4.6.9...v4.6.10
[4.6.9]: https://github.com/magpiemodel/magpie/compare/v4.6.8...v4.6.9
[4.6.8]: https://github.com/magpiemodel/magpie/compare/v4.6.7...v4.6.8
[4.6.7]: https://github.com/magpiemodel/magpie/compare/v4.6.6...v4.6.7
[4.6.6]: https://github.com/magpiemodel/magpie/compare/v4.6.5...v4.6.6
[4.6.5]: https://github.com/magpiemodel/magpie/compare/v4.6.4...v4.6.5
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.7dev
date-released: 2023-05-10
version: 4.6.11dev
date-released: 2023-09-05
repository-code: https://github.com/magpiemodel/magpie
keywords:
- landuse
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Imports:
iamc,
lucode2 (>= 0.36.0),
luplot,
luscale,
luscale (>= 2.27.9),
lusweave,
m4fsdp,
madrat,
Expand Down
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.7 can be found at
https://rse.pik-potsdam.de/doc/magpie/4.6.7/
The model documentation for version 4.6.11 can be found at
https://rse.pik-potsdam.de/doc/magpie/4.6.11/

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.7/#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.11/#how-to-cite) in the model documentation for information how to cite the model.

## AUTHORS
See list of authors in CITATION.cff
Expand Down
62 changes: 45 additions & 17 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ cfg$model <- "main.gms" #def = "main.gms"
#### input settings ####

# which input data sets should be used?
cfg$input <- c(regional = "rev4.87_h12_magpie.tgz",
cellular = "rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz",
validation = "rev4.87_h12_validation.tgz",
additional = "additional_data_rev4.43.tgz",
calibration = "calibration_H12_per_ton_fao_may22_glo_23Mar23.tgz")
cfg$input <- c(regional = "rev4.88_h12_magpie.tgz",
cellular = "rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz",
validation = "rev4.88_h12_validation.tgz",
additional = "additional_data_rev4.45.tgz",
calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz")

# NOTE: It is recommended to recalibrate the model when changing cellular input data
# as well as for any other setting that would affect initial values in the model,
Expand Down Expand Up @@ -95,7 +95,7 @@ cfg$restart_landconversion_cost <- FALSE # def = FALSE
# calibration factor in each calibration iteration (0-1)
cfg$damping_factor_landconversion_cost <- 0.96 # def= 0.96
# Set upper limit for cropland calibration factor
cfg$cost_calib_max_landconversion_cost <- 3 # def= 3
cfg$cost_calib_max_landconversion_cost <- 3 # def= 3
# Set lower limit for cropland calibration factor
cfg$cost_calib_min_landconversion_cost <- 0.05 # def= 0.05
# Selection type of calibration factors.
Expand Down Expand Up @@ -307,6 +307,15 @@ cfg$gms$s14_limit_calib <- 1 # def = 1
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$s14_calib_ir2rf <- 1 # def = 1

# * Switch to include yield impacts of land degradation.
# * The state of yield-relevant nature's contributions to people (NCP)
# * is reported through ./modules/14_yields/input/f14_yld_ncp_report.cs3
# * based on estimated outcomes for soil loss or pollination sufficiency
# * per cluster from an existing model run.
# * options: 1 (yields are reduced based on yield reduction coefficients)
# * 0 (land degradation is switched off)
cfg$gms$s14_degradation <- 0 # def = 0

# ***--------------------- 15_food ---------------------------------------
# * (anthropometrics_jan18): estimates food using scenario dependent regression
# * and demography drivers
Expand Down Expand Up @@ -694,8 +703,17 @@ cfg$gms$s31_fac_req_past <- 1 # def = 1
# * reflecting that not all pasture area is grazed.
cfg$gms$s31_unequal <- 1 # def = 1

# * Scenario for grassland and pasture yields (only take effect for realization grasslands_apr22)
# * options: cc (climate change)
# * nocc (no climate change)
# * nocc_hist (no climate change after year defined by sm_fix_cc)
cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc"


# * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22)
# * options: ssp126, ssp245, ssp370, ssp460, ssp585
# * nocc (fixed to values from 1995),
# * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter)
cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370"

# * Switch that allows selecting how yield calibration factors will be calculated.
Expand Down Expand Up @@ -1277,7 +1295,9 @@ cfg$gms$nitrogen <- "rescaled_jan21" # def = rescaled_jan21
cfg$gms$carbon <- "normal_dec17" # def = normal_dec17

# * RCP scenario of land carbon sink adjustment factor, from Grassi et al 2021
# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU
# * options: RCP19, RCP26, RCP34, RCP45, RCP60, RCPBU,
# * nocc (fixed to values from 1995),
# * nocc_hist (RCPBU until year defined in sm_fix_cc, fixed thereafter)
cfg$gms$c52_land_carbon_sink_rcp <- "RCPBU"


Expand Down Expand Up @@ -1519,8 +1539,8 @@ cfg$gms$peatland <- "on" # def = on
cfg$gms$s58_rewetting_switch <- Inf # def = Inf

# * One-time and recurring costs for peatland rewetting (USD05MER per ha)
cfg$gms$s58_rewet_cost_onetime <- 7000 # def = 7000
cfg$gms$s58_rewet_cost_recur <- 200 # def = 200
cfg$gms$s58_cost_rewet_onetime <- 7000 # def = 7000
cfg$gms$s58_cost_rewet_recur <- 200 # def = 200

# * One-time and recurring costs for peatland degradation (USD05MER per ha)
# * Can be used to test area-based incentives for peatland protection and restoration,
Expand All @@ -1529,8 +1549,8 @@ cfg$gms$s58_rewet_cost_recur <- 200 # def = 200
# * Therefore, one-time costs can used to incentivize the protection of intact peatlands.
# * Recurring costs apply on the level of degraded peatland. Therefore, recurring costs,
# * in combination with one-time costs, can be used to incentivize peatland restoration.
cfg$gms$s58_degrad_cost_onetime <- 0 # def = 0
cfg$gms$s58_degrad_cost_recur <- 0 # def = 0
cfg$gms$s58_cost_degrad_onetime <- 0 # def = 0
cfg$gms$s58_cost_degrad_recur <- 0 # def = 0

# * Artificial cost for balance variables (USD05MER per ha)
# * The balance variables in the peatland module avoid infeasibilities due to
Expand Down Expand Up @@ -1724,7 +1744,10 @@ cfg$gms$c70_fac_req_regr <- "glo" # def = glo
# * (off): default
# * (foragebased_aug18): Disaggregation of livestock to cells
# * with high pasture and fodder availability
cfg$gms$disagg_lvst <- "foragebased_aug18" # def = foragebased_aug18
# * (foragebased_jul23): Disaggregation of livestock to cells
# * with high pasture and fodder availability
# * (improved and flexibitized)
cfg$gms$disagg_lvst <- "foragebased_jul23" # def = foragebased_jul23


# ***--------------------- 73_timber -----------------------------------
Expand Down Expand Up @@ -1812,11 +1835,6 @@ cfg$gms$s80_maxiter <- 30
# * (conopt4+conopt3): conopt4 followed by conopt3
cfg$gms$c80_nlp_solver <- "conopt4" # def = conopt4

# number of allowed non-optimal variables
# Should be set to 0 for GAMS version 25.x.x or earlier
# Should be set to Inf for GAMS version 26.x.x or later
cfg$gms$s80_num_nonopt_allowed <- Inf

# * 1: using optfile for specified solver settings
# * 0: default settings (optfile will be ignored)
cfg$gms$s80_optfile <- 1
Expand Down Expand Up @@ -1870,6 +1888,12 @@ cfg$output <- c("output_check", "extra/disaggregation", "rds_report")
# :title: is a placeholder for the current run title (cfg$title)
cfg$results_folder <- "output/:title::date:"

# Results folder used by the "highres.R" output script
# If NULL, the default set in "highres.R" is used (currently a subfolder in "output")
# To place highres runs directly in the "output" folder, change to "output"
# To place highres runs in a specific subfolder change to "output/HR"
cfg$results_folder_highres <- NULL

# Which files should be copied into the output folder?
cfg$files2export <- list()
# Files that should be copied before MAgPIE is started
Expand Down Expand Up @@ -1900,6 +1924,10 @@ cfg$files2export$start <- c("input/info.txt",
# Files that should be copied after the MAgPIE run is finished
cfg$files2export$end <- NULL

# Expert use only, should not be set manually. Path to a renv.lock file
# defining the package environment for newly started runs.
cfg$renv_lock <- NULL

# Folder run statistics should be submitted to
cfg$runstatistics <- "/p/projects/rd3mod/models/statistics/magpie"

Expand Down
7 changes: 4 additions & 3 deletions config/scenario_config.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ gms$c30_bioen_water;;;;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;rainfed;a
gms$s30_snv_shr;;;;0;0;0;0;0;0;0;0;0;0.2;;;;;;;0;;0.2;0.2;0.2;0.2;0.2;;;;;;;;;;;;;;;;;;;
gms$s30_snv_shr_noselect;;;;;;;;;;;;;;;;;;;;;;0;0;0.2;0;0.2;;;;;;;;;;;;;;;;;;;
gms$s30_snv_scenario_target;;;;;;;;;;;;;2030;;;;;;;;;2030;2030;2030;2030;2030;;;;;;;;;;;;;;;;;;;
gms$c31_past_suit_scen;;;;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585;
gms$c31_past_suit_scen;;nocc;nocc_hist;ssp126;ssp245;ssp245;ssp370;ssp460;ssp585;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ssp126;ssp126;ssp245;ssp460;ssp370;ssp585;
gms$c31_grassl_yld_scenario;cc;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s32_aff_plantation;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s32_aff_bii_coeff;;;;0;0;0;0;0;0;0;1;0;0;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;
gms$s32_max_aff_area;;;;Inf;Inf;Inf;Inf;Inf;Inf;500;350;0;700;;;;;;;500;;Inf;Inf;Inf;500;500;;;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -78,8 +79,8 @@ gms$s73_timber_demand_switch;;;;;;;;;;;;;;;;;;;;;;1;1;1;1;1;;;;;1;1;0;;;;;;;;;;;
gms$s35_forest_damage;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4;4;4;4;4;;;;;;;
gms$c32_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;;
gms$c35_shock_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;none;002lin2030;004lin2030;008lin2030;016lin2030;;;;;;;
input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.87_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.87_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.87_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.87_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.87_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.87_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;
gms$c52_land_carbon_sink_rcp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU;
input['cellular'];;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;rev4.88_h12_0bd54110_cellularmagpie_c200_MRI-ESM2-0-ssp119_lpjml-8e6c5eb1.tgz;rev4.88_h12_6819938d_cellularmagpie_c200_MRI-ESM2-0-ssp126_lpjml-8e6c5eb1.tgz;rev4.88_h12_1b5c3817_cellularmagpie_c200_MRI-ESM2-0-ssp245_lpjml-8e6c5eb1.tgz;rev4.88_h12_3c888fa5_cellularmagpie_c200_MRI-ESM2-0-ssp460_lpjml-8e6c5eb1.tgz;rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz;rev4.88_h12_09a63995_cellularmagpie_c200_MRI-ESM2-0-ssp585_lpjml-8e6c5eb1.tgz;
gms$c52_land_carbon_sink_rcp;;nocc;nocc_hist;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RCP19;RCP26;RCP45;RCP60;RCPBU;RCPBU;
gms$c57_macc_version;;;;;;;;;;;;;;;;;;;;;;;;;;;PBL_2022;PBL_2022;PBL_2022;PBL_2022;;;;;;;;;;;;;;;
gms$c57_macc_scenario;;;;;;;;;;;;;;;;;;;;;;;;;;;Default;Optimistic;Default;Optimistic;;;;;;;;;;;;;;;
gms$s58_rewetting_switch;;;;;;;;;;;;;;;;;;;;;;;;;;;0;1;0;1;;;;;;;;;;;;;;;
4 changes: 2 additions & 2 deletions core/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sets
CHA_7*CHA_23,
EUR_24*EUR_32,
IND_33*IND_40,
JPN_41,
JPN_41*JPN_41,
LAM_42*LAM_85,
MEA_86*MEA_111,
NEU_112*NEU_118,
Expand All @@ -73,7 +73,7 @@ sets
CHA . (CHA_7*CHA_23)
EUR . (EUR_24*EUR_32)
IND . (IND_33*IND_40)
JPN . (JPN_41)
JPN . (JPN_41*JPN_41)
LAM . (LAM_42*LAM_85)
MEA . (MEA_86*MEA_111)
NEU . (NEU_112*NEU_118)
Expand Down
Loading

0 comments on commit 4a5a731

Please sign in to comment.