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

Next revision
Previous revision
Next revision Both sides next revision
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/20 19:33]
deryn.crockett created
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/20 20:23]
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. 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.
  
-<code - myfile.t> +<code - mapMin.t> 
-local uce2020[uce2020,uce2020] = diag (1.0; dim=unitCodeE2020+localinformant plantID[] = create (; object=set, data="​Plant1 Plant2"​) 
-local uce2020Mask[t,​cidsc->​unsc,uce2020] = boolne (dimtran (uce2020[uce2020,uce2020]; +localinformant unitID[] = create (; object=set, data="​Unit1 Unit2 Unit3 Unit4 Unit5"​) 
- map1=E2020UnitCodeIndx[t,​cidsc->​unsc], newDims=2, checkData=off),​0) + 
-local comYrsSCx[t,cidsc->​unsc,​uce2020] = reorder (comYrsSC[cidsc->​unsc,​t]; time, cidscCOunsc) ​+! map containing index value into plantID for each element of unitID to implement the mapping: 
- uce2020Mask[t,​cidsc->​unsc,uce2020+! Unit1 -> Plant1 
-local comYrsSCOffset[t,cidsc->​unsc,​uce2020] = booleq (comYrsSCx[t,cidsc->​unsc,​uce2020],0) * 9999 +! Unit2 -> Plant2 
-local comYrsSCy[t,cidsc->​unsc,uce2020] = comYrsSCx[t,cidsc->​unsc,​uce2020+ comYrsSCOffset[t,cidsc->​unsc,​uce2020]+! Unit3 -> Plant1 
 +! Unit4 -> Plant1 
 +! Unit5 -> Plant2 
 +local unitToPlantMap[uid] = create (; dataType=integer,​ dim=unitID, data="​1 2 1 1 2") 
 + 
 +! variable that contains commissioning years by unit id 
 +local unitComYr[uid] = create (; dim=unitID, data="​1990 1975 1980 1995 2000"​) 
 + 
 +local pid[pid,pid] = diag (1.0; dim=plantID
 +local plantIDMask[uid,pid] = boolne (dimtran (pid[pid,pid]; map1=unitToPlantMap[uid], newDims=1, checkData=off),​0) 
 +local unitComYrx[uid,pid] = unitComYr[uid] * plantIDMask[uid,pid] 
 + 
 +! add offset to remove 0's before taking minimum 
 +local unitComYry[uid,pid] = booleq (unitComYrx[uid,pid],0) * 9999 + unitComYrx[uid,pid] 
 + 
 +! variable that contains online datewhich is the earliest commissioning year of the units that comprise the plant, by plant id 
 +local plantOnlineDate[pid] = coordmin (reorder (unitComYry[uid,pid]; plantIDunitID); numDims=1) 
 +table (plantOnlineDate[pid])
  
-local e2020OnlineDatex[uce2020,​t] = coordmin (reorder (comYrsSCy[t,​cidsc->​unsc,​uce2020];​ unitCodeE2020,​time,​cidscCOunsc);​ numDims=1) 
-e2020OnlineDate[uce2020,​t] = boolne (e2020OnlineDatex[uce2020,​t],​9999) * e2020OnlineDatex[uce2020,​t] 
 </​code>​ </​code>​
howtos/toolcoding/many_to_one_mapping_with_non_summation_aggregation_rule.txt · Last modified: 2011/06/13 16:20 by chris.strashok