Skip to content

Commit

Permalink
Merge pull request #44 from pascal-sauer/master
Browse files Browse the repository at this point in the history
replace speed_aggregate, remove luscale dependency
  • Loading branch information
pascal-sauer authored May 7, 2024
2 parents 902a123 + c2aaf90 commit e1d770c
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '28963480'
ValidationKey: '29179500'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'mrmagpie: madrat based MAgPIE Input Data Library'
version: 1.46.0
date-released: '2024-04-25'
version: 1.47.0
date-released: '2024-05-07'
abstract: Provides functions for MAgPIE country and cellular input data generation.
authors:
- family-names: Karstens
Expand Down
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrmagpie
Title: madrat based MAgPIE Input Data Library
Version: 1.46.0
Date: 2024-04-25
Version: 1.47.0
Date: 2024-05-07
Authors@R: c(
person("Kristine", "Karstens", , "[email protected]", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -38,7 +38,6 @@ Imports:
ggplot2,
lpjclass,
luplot (>= 3.56.0),
luscale,
magpiesets,
mstools,
ncdf4,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ importFrom(dplyr,select)
importFrom(ggplot2,ggsave)
importFrom(lpjclass,read.LPJ_input)
importFrom(luplot,plotregionscluster)
importFrom(luscale,speed_aggregate)
importFrom(madrat,calcOutput)
importFrom(madrat,getConfig)
importFrom(madrat,readSource)
Expand Down
4 changes: 2 additions & 2 deletions R/calcClusterKMeans.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' for the cluster distribution, e.g. weight=c(AFR=3,EUR=0.5).
#' weight > 1 will grant more cluster to a region and
#' weight < 1 less cluster than by default.
#' @param cpr cells-per-region information as returned by cluster_per_region.
#' @param cpr cells-per-region information as returned by toolClusterPerRegionManual.
#' Weight and ncluster are ignored in case that cpr is provided!
#' @param seed a single value, interpreted as an integer, or NULL, to define seed for random calculations
#' @param clusterdata similarity data to be used to determine clusters: yield_airrig (current default)
Expand All @@ -21,7 +21,7 @@
#' @return A mapping between regions and clusters
#' @author Jan Philipp Dietrich
#' @importFrom stats kmeans
#' @seealso \code{\link{toolClusterPerRegion}}, \code{\link{calcClusterHierarchical}}
#' @seealso \code{\link{toolClusterPerRegionManual}}, \code{\link{calcClusterHierarchical}}
#' @export

calcClusterKMeans <- function(regionscode, ncluster, weight = NULL, cpr = NULL, seed = 42,
Expand Down
5 changes: 1 addition & 4 deletions R/calcClusterTreeHierarchical.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@
#' @author Jan Philipp Dietrich
#' @importFrom magclass getCells ncells getRegions getItems
#' @importFrom stats hclust cutree
#' @seealso \code{\link{cluster_per_region}}, \code{\link{mag_kmeans}},
#' \code{\link{clusterspam}}
#' @export

calcClusterTreeHierarchical <- function(regionscode, mode = "h", weight = NULL,
lpjml = c(natveg = "LPJmL4", crop = "LPJmL5"), clusterdata = "yield_airrig") {

# read in cluster base data
cdata <- toolApplyRegionNames(cdata = calcOutput("ClusterBase", lpjml = lpjml,
clusterdata = clusterdata, aggregate = FALSE),
clusterdata = clusterdata, aggregate = FALSE),
regionscode = regionscode)
# transform to array
cdata <- as.array(cdata)[, , ]
Expand Down
4 changes: 1 addition & 3 deletions R/readMAPSPAM.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#' @author Edna J. Molina Bacca, Felicitas Beier
#' @param subtype It can be either "harvested" or "physical" area
#' @importFrom terra rast values crds aggregate
#' @importFrom luscale speed_aggregate
#' @importFrom mrcommons toolGetMappingCoord2Country
#' @importFrom magpiesets findset
#' @importFrom magclass new.magpie
Expand Down Expand Up @@ -128,8 +127,7 @@ readMAPSPAM <- function(subtype = "harvested") {

.convertMag <- function(x) {
spam2Magpie <- spam2Magpie[spam2Magpie$SPAM %in% getNames(x), ]
x <- luscale::speed_aggregate(x, rel = spam2Magpie,
from = "SPAM", to = "Magpie", dim = 3)
x <- toolAggregate(x, rel = spam2Magpie, from = "SPAM", to = "Magpie", dim = 3)
return(x)
}

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# madrat based MAgPIE Input Data Library

R package **mrmagpie**, version **1.46.0**
R package **mrmagpie**, version **1.47.0**

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

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Kristine Karstens <karstens@pik-p

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

Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi:10.5281/zenodo.4319612 <https://doi.org/10.5281/zenodo.4319612>, R package version 1.46.0, <https://github.com/pik-piam/mrmagpie>.
Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi:10.5281/zenodo.4319612 <https://doi.org/10.5281/zenodo.4319612>, R package version 1.47.0, <https://github.com/pik-piam/mrmagpie>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,8 +48,8 @@ A BibTeX entry for LaTeX users is
title = {mrmagpie: madrat based MAgPIE Input Data Library},
author = {Kristine Karstens and Jan Philipp Dietrich and David Chen and Michael Windisch and Marcos Alves and Felicitas Beier and Alexandre Köberle and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Sauer},
year = {2024},
note = {R package version 1.46.0},
doi = {10.5281/zenodo.4319612},
note = {R package version 1.47.0},
url = {https://github.com/pik-piam/mrmagpie},
doi = {10.5281/zenodo.4319612},
}
```
4 changes: 2 additions & 2 deletions man/calcClusterKMeans.Rd

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

4 changes: 0 additions & 4 deletions man/calcClusterTreeHierarchical.Rd

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

0 comments on commit e1d770c

Please sign in to comment.