Information

Transformation:

Weighted

Transformation Group:

InterpolationSpatial

Description:

For each time step this transformation calculates the weighted average of the input variables. The weights are re-scaled so that the total weight becomes 1. If for a given time an input variable has a missing value, then for that time that input variable is ignored and the weights of the other input variables are re-scaled so that the total weight becomes 1.

Hydrological Information

Purpose and use of Transformation:

This transformation can for example be used to calculate the weighted average of the amount of rainfall of a number of locations in a catchment.

Background and Exceptions:

 

Configuration

There are two possible ways to configure this transformation:

  1. Defining the input time series and the weight of each input time series in the module config file using <weightedInputVariable> elements. 
  2. Using two multi-value attributes of the output time series location to determine the input time series and their weights respectively (available since 2017.02).

The way to configure the input and output variables for these two options will be explained separately. Note that the first option uses the <weightedInputVariable> elements in combination with a regular <outputVariable> element, while the second option uses a single (regular) <inputVariable> element in combination with an <attributedOutputVariable> element. It is not possible to combine the input and output variable element options in a different way.

Both configuration options support an optional element <minInputValuesRequired> which is the minimum number of input variables that should have a non-missing value for the calculation. If for a given time the number of input variables that have a non-missing value is less than this configured minimum, then for that time the output value will be a missing value. This can be used for example to avoid getting output values of calculations for which very few input variables are available, because such calculations would be inaccurate. If <minInputValuesRequired> is not specified, then it will be set to 1.

Configuration using weighted input variables

Input

One or more weighted input variables (<weightedInputVariable> elements). Each input variable has a weight.

Output

Weighted average (a regular <outputVariable> element).

Configuration Example
<transformation id="interpolation spatial weighted">
	<interpolationSpatial>
		<weighted>
			<weightedInputVariable>
				<inputVariable>
					<variableId>location1</variableId>
				</inputVariable>
				<weight>0.3</weight>
			</weightedInputVariable>
			<weightedInputVariable>
				<inputVariable>
					<variableId>location2</variableId>
				</inputVariable>
				<weight>0.2</weight>
			</weightedInputVariable>
			<weightedInputVariable>
				<inputVariable>
					<variableId>location3</variableId>
				</inputVariable>
				<weight>0.1</weight>
			</weightedInputVariable>
			<weightedInputVariable>
				<inputVariable>
					<variableId>location4</variableId>
				</inputVariable>
				<weight>0.4</weight>
			</weightedInputVariable>
			<minInputValuesRequired>2</minInputValuesRequired>
			<outputVariable>
				<variableId>average</variableId>
			</outputVariable>
		</weighted>
	</interpolationSpatial>
</transformation>

Configuration using multi-value attributes

Available since 2017.02. 

Input

A single <inputVariable> element should be configured, with a locationSet containing all possible input locations.

Output

An <attributedOutputVariable> element specifying the <outputVariable> and the attributes <locationIdAttribute> and <weightAttribute> used to determine the input locations and their weights respectively. Note that the attributes should be available for each location if a locationSet is used (the attributeExists constraint can be used to create a new locationSet from an existing locationSet if necessary). Also note that when configuring the multi-value attributes there should never be a an empty value for one of the attribute, otherwise the input locations and weights will not be combined correctly. Finally, note that <locationIdAttribute> should be a text attribute, while <weightAttribute> should be a number attribute. 

Configuration Example
Configuring the transformation in the module config file
<transformation id="interpolation spatial weighted">
	<interpolationSpatial>
		<weighted>
			<inputVariable>
				<variableId>input</variableId>
			</inputVariable>
			<attributedOutputVariable>
				<outputVariable>
					<variableId>output</variableId>
				</outputVariable>
				<locationIdAttribute>LOCS</locationIdAttribute>
				<weightAttribute>WEIGHTS</weightAttribute>
			</attributedOutputVariable>
		</weighted>
	</interpolationSpatial>
</transformation>
The location set used for the output variable
<locationSet id="WeightedWithAttributesOutputLocs">
	<csvFile>
		<file>WeightedWithAttributesOutputLocs.csv</file>
		<id>%ID%</id>
		<x>%X%</x>
		<y>%Y%</y>
		<attributeFile>
			<csvFile>WeightedWithAttributesOutputLocs_Attributes.csv</csvFile>
			<id>%OUTID%</id>
			<attribute id="LOCS">
				<text>%INID%</text>
			</attribute>
			<attribute id="WEIGHTS">
				<number>%WEIGHT%</number>
			</attribute>
		</attributeFile>
	</csvFile>
</locationSet>
WeightedWithAttributesOutputLocations_attributes.csv
OUTID, INID, WEIGHT
output_id_1, input_id_1, 1
output_id_2, input_id_1, 0.5
output_id_2, input_id_2, 0.5
output_id_3, input_id_1, 0.5
output_id_3, input_id_3, 0.5
output_id_4, input_id_1, 0.1
output_id_4, input_id_2, 0.3
output_id_4, input_id_4, 0.6
  • No labels