Skip to content

Commit

Permalink
Merge pull request magpiemodel#710 from tscheypidi/develop
Browse files Browse the repository at this point in the history
replaced gdx with gdx2 in output scripts
  • Loading branch information
tscheypidi authored Aug 8, 2024
2 parents 5843931 + 7fce62f commit e38329e
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **script** scripts/start_functions.R decide individually for demand and price whether they are read from a REMIND report.
- **80_optimization** abort GAMS in case of execution errors
- **script** updated EATLancet project start scripts
- **script** replaced gdx package with gdx2 package calls

### added
- **scripts** added output report `EU_report.R` that uses `EU_report.Rmd`
Expand Down
5 changes: 3 additions & 2 deletions scripts/calibration/calc_calib.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ calibration_run <- function(putfolder, calib_magpie_name, logoption = 3) {
get_areacalib <- function(gdx_file) {
require(magclass)
require(magpie4)
require(gdx)
require(gdx2)
data <- readGDX(gdx_file, "pm_land_start")[, , c("crop", "past")]
data <- dimSums(data, dim = 1.2)
magpie <- land(gdx_file)[, , c("crop", "past")]
Expand All @@ -54,7 +54,7 @@ get_areacalib <- function(gdx_file) {

get_yieldcalib <- function(gdx_file) {
require(magclass)
require(gdx)
require(gdx2)
require(luscale)

prep <- function(x) {
Expand All @@ -81,6 +81,7 @@ update_calib <- function(gdx_file, calib_accuracy = 0.1, calibrate_pasture = TRU
n_maxcalib = 20, best_calib = FALSE) {
require(magclass)
require(magpie4)
require(gdx2)
if (!(modelstat(gdx_file)[1, 1, 1] %in% c(1, 2, 7))) stop("Calibration run infeasible")

area_factor <- get_areacalib(gdx_file)
Expand Down
3 changes: 2 additions & 1 deletion scripts/calibration/landconversion_cost.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ calibration_run <- function(putfolder, calib_magpie_name, logoption = 3, s_use_g
getCalibFactor <- function(gdx_file, mode = "cost", calib_accuracy = 0.05, lowpass_filter = 1) {
require(magclass)
require(magpie4)
require(gdx)
require(gdx2)
y <- readGDX(gdx_file,"t")
magpie <- land(gdx_file)[, y, "crop"]
hist <- dimSums(readGDX(gdx_file, "f10_land")[, , "crop"], dim = 1.2)
Expand Down Expand Up @@ -94,6 +94,7 @@ getHistCrop <- function() {
update_calib <- function(gdx_file, calib_accuracy = 0.05, lowpass_filter = 1, calib_file, cost_max = 3, cost_min = 0.05, calibration_step = "", n_maxcalib = 40, best_calib = FALSE) {
require(magclass)
require(magpie4)
require(gdx2)
if (!(modelstat(gdx_file)[1, 1, 1] %in% c(1, 2, 7))) stop("Calibration run infeasible")

y <- readGDX(gdx_file,"t")
Expand Down
1 change: 1 addition & 0 deletions scripts/output/extra/disaggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ library(luscale)
library(madrat)
library(dplyr)
library(gms)
library(gdx2)

# =============================================
# Basic configuration
Expand Down
2 changes: 1 addition & 1 deletion scripts/output/extra/highres.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Author: Florian Humpenoeder

library(magclass)
library(gdx)
library(gdx2)
library(magpie4)
library(lucode2)
library(gms)
Expand Down
2 changes: 1 addition & 1 deletion scripts/output/extra/out_of_bounds_check.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#########################
# Version 1.0, Florian Humpenoeder
#
library(gdx)
library(gdx2)
library(lucode2)
library(magclass)

Expand Down
2 changes: 1 addition & 1 deletion scripts/output/extra/reportMAgPIE2SEALS.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# 1.00: first working version

library(gms)
library(gdx)
library(gdx2)
library(magpie4)

message("Starting to report gridded MAgPIE land use for SEALS")
Expand Down
2 changes: 1 addition & 1 deletion scripts/output/projects/FSDP_collect.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ library(magclass)
library(gms)
library(magpiesets)
library(data.table)
library(gdx)
library(gdx2)
library(quitte)
library(m4fsdp)
library(stringr)
Expand Down
2 changes: 1 addition & 1 deletion scripts/output/projects/FSDP_collect2.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ library(magclass)
library(gms)
library(magpiesets)
library(data.table)
library(gdx)
library(gdx2)
library(quitte)
library(m4fsdp)
library(stringr)
Expand Down
2 changes: 1 addition & 1 deletion scripts/output/projects/peatland.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
library(lucode2)
library(magpie4)
library(luscale)

library(gdx2)
library(luplot)
library(ggplot2)
library(luscale)
Expand Down
1 change: 1 addition & 0 deletions scripts/output/validation_cell.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ library(luscale)
library(luplot)
library(lusweave)
library(magpiesets)
library(gdx2)

############################# BASIC CONFIGURATION ##############################
if (!file.exists(paste0(outputdir, "/LUH2_croparea_0.5.mz"))) stop("Cell validation is not possible. LUH2_croparea_0.5.mz and MAPSPAM_croparea_0.5.mz files are missing")
Expand Down
2 changes: 1 addition & 1 deletion scripts/start/extra/input_REMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

library(gms)
library(magclass)
library(gdx)
library(gdx2)

# Load start_run(cfg) function which is needed to start MAgPIE runs
source("scripts/start_functions.R")
Expand Down
2 changes: 1 addition & 1 deletion scripts/start/projects/paper_peatland.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

library(gms)
library(magclass)
library(gdx)
library(gdx2)
library(luscale)
library(magpie4)

Expand Down
2 changes: 1 addition & 1 deletion scripts/start/projects/project_ABCDR.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
library(lucode2)
library(gms)
library(magclass)
library(gdx)
library(gdx2)

# Load start_run(cfg) function which is needed to start MAgPIE runs
source("scripts/start_functions.R")
Expand Down
2 changes: 1 addition & 1 deletion scripts/start/projects/project_BEST.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ version <- "V13"

library(lucode2)
library(magclass)
library(gdx)
library(gdx2)
library(magpie4)
library(gms)

Expand Down
2 changes: 1 addition & 1 deletion scripts/start/projects/project_LAMACLIMA_WP4.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

library(gms)
library(magclass)
library(gdx)
library(gdx2)

# Load start_run(cfg) function which is needed to start MAgPIE runs
source("scripts/start_functions.R")
Expand Down

0 comments on commit e38329e

Please sign in to comment.