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
Last revision Both sides next revision
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/23 18:24]
deryn.crockett
howtos:toolcoding:many_to_one_mapping_with_non_summation_aggregation_rule [2010/04/23 18:41]
deryn.crockett
Line 4: Line 4:
 The following example demonstrates how to implement this logic. The following example demonstrates how to implement this logic.
  
 +===== Background =====
 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: 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:
 <​code>​ <​code>​
Line 26: Line 27:
 </​code>​ </​code>​
  
-The desired mapping from unitID to plantID is:\\+The variable unitComYr contains commissioning years by unitID 
 + 
 +{{:​howtos:​toolcoding:​unitcomyr.png|}} 
 + 
 +===== Implementation ===== 
 +1. Create the following ​desired mapping from unitID to plantID is:\\
  
 Unit1 -> Plant1\\ Unit1 -> Plant1\\
Line 34: Line 40:
 Unit5 -> Plant2 Unit5 -> Plant2
  
-which is implemented by the following code: 
 <​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>​
  
-<​code>​ 
-! variable that contains commissioning years by unit id 
-local unitComYr[uid] = create (; dim=unitID, data="​1990 1975 1980 1995 2000") 
  
 +2. Create a mask that will expand unitComYr to include plantID
 +
 +<​code>​
 local pid[pid,​pid] = diag (1.0; dim=plantID) 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 plantIDMask[uid,​pid] = boolne (dimtran (pid[pid,​pid];​ map1=unitToPlantMap[uid],​ newDims=1, checkData=off),​0)
 +</​code>​
 +{{:​howtos:​toolcoding:​plantidmask.png|}}
 +
 +<​code>​
 local unitComYrx[uid,​pid] = unitComYr[uid] * plantIDMask[uid,​pid] local unitComYrx[uid,​pid] = unitComYr[uid] * plantIDMask[uid,​pid]
 +</​code>​
 +{{:​howtos:​toolcoding:​unitcomyrx.png|}}
  
-! add offset to remove 0's before taking minimum+ 
 +3. Add offset to remove 0's before taking minimum 
 +<​code>​
 local unitComYry[uid,​pid] = booleq (unitComYrx[uid,​pid],​0) * 9999 + unitComYrx[uid,​pid] local unitComYry[uid,​pid] = booleq (unitComYrx[uid,​pid],​0) * 9999 + unitComYrx[uid,​pid]
 +</​code>​
  
-! variable that contains online date, which is the earliest commissioning year of the units that comprise the plant, by plant id 
-local plantOnlineDate[pid] = coordmin (reorder (unitComYry[uid,​pid];​ plantID, unitID); numDims=1) 
-table (plantOnlineDate[pid]) 
  
 +4. Use coordmin to create a variable that contains online date, which is the earliest commissioning year of the units that comprise the plant, by plantId
 +<​code>​
 +local plantOnlineDate[pid] = coordmin (reorder (unitComYry[uid,​pid];​ plantID, unitID); numDims=1)
 </​code>​ </​code>​
 +{{:​howtos:​toolcoding:​plantonlinedate.png|}}
 +
 +Click {{:​howtos:​toolcoding:​mapmin.t|here}} to download the tool file that encapsulates the above example.
howtos/toolcoding/many_to_one_mapping_with_non_summation_aggregation_rule.txt · Last modified: 2011/06/13 16:20 by chris.strashok