speed_aggregate: Speed Aggregate

View source: R/speed_aggregate.R

speed_aggregateR Documentation

Speed Aggregate

Description

Aggregates a MAgPIE object from one resolution to another based on a relation matrix

Usage

speed_aggregate(x,rel,fname=NULL,weight=NULL,from=NULL,to=NULL,
dim=1, partrel=FALSE)

Arguments

x

MAgPIE object or file name of a MAgPIE object

rel

relation matrix, file name of a spam relation matrix (".spam" as file ending), or file name of a region mapping (".csv" as file ending, ";" used as separator and with 3 columns: Country Name, Country code and region code)

fname

file name of a file the output should be written to. If fname=NULL the aggregated data is returned by the function

weight

MAgPIE object containing weights which should be considered for a weighted aggregation. Please see the "details" section below for more information

from

Name of the first column to be used in rel if it is a region mapping (if not set the first or second column will be used). This setting is ignored for spam files.

to

Name of the second column to be used in rel if it is a region mapping (if not set the second or third column will be used). This setting is ignored for spam files.

dim

Specifiying the dimension of the MAgPIE object that should be (dis-)aggregated. Either specified as an integer (1=spatial,2=temporal,3=data) or if you want to specify a subdimension specified by name of that dimension or position within the given dimension (e.g. 3.2 means the 2nd data dimension, 3.8 means the 8th data dimension).

partrel

If set to TRUE allowes that the relation matrix does contain less entries than x and vice versa. These values without relation are lost in the output.

Details

Basically speed_aggregate is doing nothing more than a normal matrix multiplication which is taking into account the 3 dimensional structure of MAgPIE objects. So, you can provide any kind of relation matrix you would like. However, for easier usability it is also possible to provide weights for a weighted (dis-)aggregation as a MAgPIE object. In this case rel must be a 1-0-matrix containing the mapping between both resolutions. The weight needs to be provided in the higher spatial aggregation, meaning for aggregation the spatial resolution of your input data and in the case of dissaggregation the spatial resolution of your output data. The temporal and data dimension must be either identical to the resolution of the data set that should be (dis-)aggregated or 1. If the temporal and/or data dimension is 1 this means that the same transformation matrix is applied for all years and/or all data columns. In the case that a column should be just summed up instead of being calculated as a weighted average you either do not provide any weight (than all columns are just summed up) or your set this specific weighting column to NA.

Value

If fname=NULL, the aggregated data, otherwise nothing is returned.

Author(s)

Jan Philipp Dietrich, Ulrich Kreidenweis

Examples


 ## Not run: low_res <- speed_aggregate(high_res,rel)


pik-piam/luscale documentation built on April 27, 2024, 2:11 p.m.