User Tools

Site Tools


howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/20 20:23]
deryn.crockett
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/23 18:24]
deryn.crockett
Line 1: Line 1:
-The map tool can perform an index mapping in which multiple elements of informant X are mapped to the same element of informant Y.  To aggregate multiple elements into one, the map tool sums the values of the composite elements. ​ However, there may be a need to use a different aggregation function such as minimum, maximum, or average.  ​The following code demonstrates how to implement this logic.+====== Many to One Mapping with Non-Summation Aggregation Rule ====== 
 +The map tool can perform an index mapping in which multiple elements of informant X are mapped to the same element of informant Y.  To aggregate multiple elements into one, the map tool sums the values of the composite elements. ​ However, there may be a need to use a different aggregation function such as minimum, maximum, or average.  ​
  
-<code - mapMin.t> +The following example demonstrates how to implement this logic.
-localinformant plantID[] = create (; object=set, data="​Plant1 Plant2"​) +
-localinformant unitID[] = create (; object=set, data="​Unit1 Unit2 Unit3 Unit4 Unit5"​)+
  
-! map containing index value into plantID for each element of unitID to implement ​the mapping: +In this example, the a variable indexed by the informant ​unitID ​will be mapped ​to a variable indexed by the informant plantID. ​ The contents of these informants are: 
-! Unit1 -> Plant1 +<​code>​ 
-! Unit2 -> Plant2 +plantID[]: set 
-! Unit3 -> Plant1 + ​version:​ 3 
-! Unit4 -> Plant1 + ​desc: ​   localinformant plantID[] = create (; object=set, data="​Plant1 Plant2"​) 
-! Unit5 -> Plant2+ ​data: ​   2 elements 
 +----------------------------------- 
 +1     ​Plant1 ​          
 +2     ​Plant2 ​          
 + 
 +unitID[]: set 
 + ​version:​ 3 
 + ​desc: ​   localinformant unitID[] = create (; object=set, data="​Unit1 Unit2 Unit3 Unit4 Unit5"​) 
 + ​data: ​   5 elements 
 +----------------------------------- 
 +1     ​Unit1 ​           
 +2     ​Unit2 ​           
 +3     ​Unit3 ​           
 +4     ​Unit4 ​           
 +5     ​Unit5 ​           
 +</​code>​ 
 + 
 +The desired ​mapping ​from unitID to plantID is:\\ 
 + 
 +Unit1 -> Plant1\\ 
 +Unit2 -> Plant2\\ 
 +Unit3 -> Plant1\\ 
 +Unit4 -> Plant1\\ 
 +Unit5 -> Plant2 
 + 
 +which is implemented by the following code: 
 +<​code>​
 local unitToPlantMap[uid] = create (; dataType=integer,​ dim=unitID, data="​1 2 1 1 2") local unitToPlantMap[uid] = create (; dataType=integer,​ dim=unitID, data="​1 2 1 1 2")
 +</​code>​
  
 +<​code>​
 ! variable that contains commissioning years by unit id ! variable that contains commissioning years by unit id
 local unitComYr[uid] = create (; dim=unitID, data="​1990 1975 1980 1995 2000") local unitComYr[uid] = create (; dim=unitID, data="​1990 1975 1980 1995 2000")
howtos/toolcoding/many_to_one_mapping_with_non_summation_aggregation_rule.txt · Last modified: 2011/06/13 16:20 by chris.strashok