! To make this template work for your specific case earch and replace the following to setup the view (example heatSysShr) ! shrVariableName with heatSysShr ! [upperDims, with [rr,dts, ! shrDim, with hs, ! shrDim] with hs] ! dimName with heatSys ! with 1978 ! with 2006 creview shrVariableName[upperDims,shrDim,ts][] boolean $continue if $history == false say ("This view requires a history.") listen (" enter to continue >> ",$continue) quit (-1) endif if $background == false say ("This view requires a background scenario.") listen (" enter to continue >> ",$continue) quit (-1) endif integer $fistHisYear, $lastHisYear, $firstScnYear, $lastScnYear getobjinfo (shrVariableName[upperDims,shrDim,ts][1], $fistHisYear; info=sequenceStart, dim=time) getobjinfo (shrVariableName[upperDims,shrDim,ts][1], $lastHisYear; info=sequenceEnd, dim=time) getobjinfo (shrVariableName[upperDims,shrDim,ts][2], $firstScnYear; info=sequenceStart, dim=time) getobjinfo (shrVariableName[upperDims,shrDim,ts][2], $lastScnYear; info=sequenceEnd, dim=time) integer $lastHisYearP1, $firstHisTime $lastHisYearP1 = $lastHisYear + 1 !saturating linear trend (default) boolean $nonDefault say ("") say ("Default setting are:") say (" first historical time for basing trends = ") say (" percent change from last year of history = 50%") say ("") say (" You can choose to have the projection either join the;") say (" 1) trend line") say (" or") say (" 2) projection of the last 2 years of history") say (" The default is to join the trend line.") say ("") listen ("Do you want to use non-default values? {y n}[n] ",$nonDefault) boolean $joinHis string $percentChange local percentChangex[] if $nonDefault == false percentChangex[] = create (; data=50.0) $firstHisTime = $joinHis = false else say ("") listen ("What is historical starting year for the projection? {..}[] ",$firstHisTime) if $firstHisTime == 0 $firstHisTime = endif if $firstHisTime < AND ($firstHisTime != 0) $firstHisTime = endif if $firstHisTime > $firstHisTime = endif listen ("What percentage change from last year of history do you want to allow? {0..}[50] ",$percentChange) if $percentChange == "" percentChangex[] = create (; data=50.0) else percentChangex[] = create (; data=$percentChange) endif listen ("Do you want to join the projection of the last 2 years of history? {y n}[n] ",$joinHis) endif local variableHis[upperDims,shrDim,t] = shrVariableName[upperDims,shrDim,ts][1] local trendx[upperDims,shrDim,ts], projx[upperDims,shrDim,ts] if $joinHis == true trendx[upperDims,shrDim,ts], projx[upperDims,shrDim,ts] = lintrend (extract (variableHis[upperDims,shrDim,t]; \ time:$firstHisTime..-0); time=$lastScnYear, join=on) else trendx[upperDims,shrDim,ts], projx[upperDims,shrDim,ts] = lintrend (extract (variableHis[upperDims,shrDim,t]; \ time:$firstHisTime..-0); time=$lastScnYear) endif local trend[upperDims,shrDim,ts] = norm (min (max (trendx[upperDims,shrDim,ts], 0), 1); dim=dimName) local proj[upperDims,shrDim,ts] = norm (min (max (projx[upperDims,shrDim,ts], 0), 1); dim=dimName) local base[upperDims,bt] = extract (trend[upperDims,shrDim,ts]; time:-1..-0) local trendp[upperDims,shrDim] = extract (delta (trend[upperDims,shrDim,ts]); time:-0, shrink=on) local positive[upperDims,shrDim] = boolgt (trendp[upperDims,shrDim], 0) local negative[upperDims,shrDim] = boolle (trendp[upperDims,shrDim], 0) local percentChange[] = max (percentChangex[], 0) local firstProjPoint[upperDims,shrDim] = extract (proj[upperDims,shrDim,ts]; time:+0, shrink=on) local asymtotepositive[upperDims,shrDim] = percentChange[] / 100 + 1 * firstProjPoint[upperDims,shrDim] * positive[upperDims,shrDim] local asymtotenegative[upperDims,shrDim] = percentChange[] / 100 * -1 + 1 * firstProjPoint[upperDims,shrDim] * negative[upperDims,shrDim] local asymtote[upperDims,shrDim] = asymtotepositive[upperDims,shrDim] + asymtotenegative[upperDims,shrDim] local satprojx[upperDims,shrDim,ts] = satproj (base[upperDims,bt], asymtote[upperDims,shrDim]; time=$lastScnYear) local satprojection[upperDims,shrDim,ts] = norm (min (max (satprojx[upperDims,shrDim,ts], 0), 1); dim=dimName) local projFirstPoint[upperDims,shrDim] = extract (satprojection[upperDims,shrDim,ts]; time:+0, shrink=on) local trendFLPx[upperDims,shrDim,ts], projFLPx[upperDims,shrDim,ts] if $joinHis == true trendFLPx[upperDims,shrDim,ts], projFLPx[upperDims,shrDim,ts] = lintrend (extract (variableHis[upperDims,shrDim,t]; \ time:-1..-0); time=$lastHisYearP1, join=on) else trendFLPx[upperDims,shrDim,ts], projFLPx[upperDims,shrDim,ts] = lintrend (extract (trend[upperDims,shrDim,ts]; \ time:-1..-0); time=$lastHisYearP1) endif local trendFLP[upperDims,shrDim,ts] = norm (min (max (trendFLPx[upperDims,shrDim,ts], 0), 1); dim=dimName) local projFLP[upperDims,shrDim,ts] = norm (min (max (projFLPx[upperDims,shrDim,ts], 0), 1); dim=dimName) local projFLPy[upperDims,shrDim] projFLPy[upperDims,shrDim] = shrink (projFLP[upperDims,shrDim,ts]) local adjust[upperDims,shrDim] = projFLPy[upperDims,shrDim] / projFirstPoint[upperDims,shrDim] shrVariableName[upperDims,shrDim,ts][3] = norm (min (max (satprojection[upperDims,shrDim,ts] * adjust[upperDims,shrDim], 0), 1); dim=dimName) boolean $seeResults say ("") listen ("Do you want to see the results? ",$seeResults) if $seeResults == true graph (shrVariableName[upperDims,shrDim,ts][all]; \ objColours=$scnColours[all], \ title="historical, background and new shr") endif