Skip to content

Commit

Permalink
Merge pull request #54 from emolinab/master
Browse files Browse the repository at this point in the history
clean up fit functions
  • Loading branch information
emolinab authored Feb 29, 2024
2 parents b8044c6 + e5e583e commit 361b14a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '237997242'
ValidationKey: '238175280'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'magpie4: MAgPIE outputs R package for MAgPIE version 4.x'
version: 1.203.1
version: 1.204.0
date-released: '2024-02-29'
abstract: Common output routines for extracting results from the MAgPIE framework
(versions 4.x).
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: magpie4
Title: MAgPIE outputs R package for MAgPIE version 4.x
Version: 1.203.1
Version: 1.204.0
Date: 2024-02-29
Authors@R: c(
person("Benjamin Leon", "Bodirsky", , "[email protected]", role = c("aut", "cre")),
Expand Down
9 changes: 7 additions & 2 deletions R/cellularFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ cellularFit <- function(gdx, file=NULL, level="cell", statistic="MAE",variable="

#Map file between different spatial resolution
dir <- gsub("fulldata.gdx", "", gdx)

if (!file.exists(paste0(dir, "/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")
}

map_file <- Sys.glob(file.path(dir, "clustermap_*.rds"))
mapping <- readRDS(map_file)

Expand Down Expand Up @@ -91,7 +96,7 @@ cellularFit <- function(gdx, file=NULL, level="cell", statistic="MAE",variable="

magpieSub <- magpie[magpie$Region == r & magpie$Year == y & magpie$Data1 == n, ]
historicalSub <- historical[historical$Region == r & historical$Year == y & historical$Data1 == n, ]
data<-merge(magpieSub,historicalSub,by=c("Cell","Region","Year","Data1","Scenario"))
data<-merge(magpieSub,historicalSub,by=c("Cell","Region","Year","Data1"))

if(statistic=="R2"){
stat <- round(cor(data$Value.x, data$Value.y)^2, 3)
Expand Down Expand Up @@ -120,7 +125,7 @@ cellularFit <- function(gdx, file=NULL, level="cell", statistic="MAE",variable="
#Calculation of global parameters
magpieSub <- magpie[magpie$Year == y & magpie$Data1 == n, ]
historicalSub <- historical[historical$Year == y & historical$Data1 == n, ]
data <- merge(magpieSub, historicalSub, by = c("Cell", "Region", "Year", "Data1", "Scenario"))
data <- merge(magpieSub, historicalSub, by = c("Cell", "Region", "Year", "Data1"))

if (statistic == "R2") {
stat <- round(cor(data$Value.x, data$Value.y)^2, 3)
Expand Down
1 change: 1 addition & 0 deletions R/getReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ getReport <- function(gdx, file = NULL, scenario = NULL, filter = c(1, 2, 7),
"reportDemand(gdx,detail=detail)",
"reportDemandBioenergy(gdx,detail=detail)",
"reportFeed(gdx,detail=detail)",
"reportFit(gdx,type='MAPE')",
"reportProduction(gdx,detail=detail)",
"reportProductionBioenergy(gdx,detail=detail)",
"reportTrade(gdx,detail=detail)",
Expand Down
2 changes: 1 addition & 1 deletion R/reportFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' }
#'

reportFit<-function(gdx,type="MPE"){
reportFit<-function(gdx,type="MAPE"){

# Land types fit/error indicators

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MAgPIE outputs R package for MAgPIE version 4.x

R package **magpie4**, version **1.203.1**
R package **magpie4**, version **1.204.0**

[![CRAN status](https://www.r-pkg.org/badges/version/magpie4)](https://cran.r-project.org/package=magpie4) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158582.svg)](https://doi.org/10.5281/zenodo.1158582) [![R build status](https://github.com/pik-piam/magpie4/workflows/check/badge.svg)](https://github.com/pik-piam/magpie4/actions) [![codecov](https://codecov.io/gh/pik-piam/magpie4/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magpie4) [![r-universe](https://pik-piam.r-universe.dev/badges/magpie4)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky <bodirsky@

To cite package **magpie4** in publications use:

Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2024). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi: 10.5281/zenodo.1158582 (URL: https://doi.org/10.5281/zenodo.1158582), R package version 1.203.1, <URL: https://github.com/pik-piam/magpie4>.
Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M (2024). _magpie4: MAgPIE outputs R package for MAgPIE version 4.x_. doi: 10.5281/zenodo.1158582 (URL: https://doi.org/10.5281/zenodo.1158582), R package version 1.204.0, <URL: https://github.com/pik-piam/magpie4>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {magpie4: MAgPIE outputs R package for MAgPIE version 4.x},
author = {Benjamin Leon Bodirsky and Florian Humpenoeder and Jan Philipp Dietrich and Miodrag Stevanovic and Isabelle Weindl and Kristine Karstens and Xiaoxi Wang and Abhijeet Mishra and Felicitas Beier and Jannes Breier and Amsalu Woldie Yalew and David Chen and Anne Biewald and Stephen Wirth and Patrick {von Jeetze} and Debbora Leip and Michael Crawford and Marcos Alves},
year = {2024},
note = {R package version 1.203.1},
note = {R package version 1.204.0},
doi = {10.5281/zenodo.1158582},
url = {https://github.com/pik-piam/magpie4},
}
Expand Down
2 changes: 1 addition & 1 deletion man/reportFit.Rd

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

0 comments on commit 361b14a

Please sign in to comment.