This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howtos:toolcoding:multiple_scenario_display_views [2011/02/11 22:01] marcus.williams created |
howtos:toolcoding:multiple_scenario_display_views [2011/02/15 21:27] (current) marcus.williams |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Here we go. | + | Display views - read-only views which manipulate and present scenario data, and can be though of as reporting scripts - are generally most useful when they support multiple scenarios for comparison alongside each another. |
+ | |||
+ | Below is an example of a simple multi-scenario display view which calculates average energy intensities across states. Note the use of: | ||
+ | * ''localview'' objects, which are arrays of tool objects. These are analogous to ''local'' object declarations in single-scenario views - but these are declared before the ''$numScns'' for loop. | ||
+ | * ''$numScns'' is an environmental variable, which as its name implies, lists the number of scenarios selected (including the history) | ||
+ | |||
+ | <code> | ||
+ | view energyUsed[st,ind,ts][] | ||
+ | view GDP[st,ind,ts][] | ||
+ | |||
+ | boolean $answer | ||
+ | if $history == false | ||
+ | say ("This view requires a history.") | ||
+ | listen (" enter to continue >> ",$answer) | ||
+ | quit (-1) | ||
+ | endif | ||
+ | |||
+ | localview energyUsed_T[ind,ts][] | ||
+ | localview GDP_T[ind,ts][] | ||
+ | localview energyInt[ind,ts][] | ||
+ | |||
+ | say ("working on") | ||
+ | integer $i | ||
+ | for $i from 1 upto $numScns | ||
+ | |||
+ | say (" ", $scnDescs[$i]) | ||
+ | |||
+ | energyUsed_T[ind,ts][$i] = sum (energyUsed[st,ind,ts][$i]; dim=state) | ||
+ | GDP_T[ind,ts][$i] = sum (energyUsed[st,ind,ts][$i]; dim=state) | ||
+ | energyInt[ind,ts][$i] = energyUsed_T[ind,ts][$i] / GDP_T[ind,ts][$i] | ||
+ | |||
+ | endfor | ||
+ | |||
+ | graph (energyInt[ind,ts][all]; \ | ||
+ | window1=$numScns, \ | ||
+ | objColours=$scnColours[all], \ | ||
+ | title1="Average energy intensity in BTU/$") | ||
+ | |||
+ | </code> | ||
+ | |||
+ |